mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-26 02:58:47 +00:00
🎉 Initial commit
This commit is contained in:
commit
1a8e1c8eaf
349
.gitignore
vendored
Normal file
349
.gitignore
vendored
Normal file
@ -0,0 +1,349 @@
|
|||||||
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
##
|
||||||
|
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.rsuser
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.userosscache
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||||
|
*.userprefs
|
||||||
|
|
||||||
|
# Mono auto generated files
|
||||||
|
mono_crash.*
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Dd]ebugPublic/
|
||||||
|
[Rr]elease/
|
||||||
|
[Rr]eleases/
|
||||||
|
x64/
|
||||||
|
x86/
|
||||||
|
[Aa][Rr][Mm]/
|
||||||
|
[Aa][Rr][Mm]64/
|
||||||
|
bld/
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
[Ll]og/
|
||||||
|
|
||||||
|
# Visual Studio 2015/2017 cache/options directory
|
||||||
|
.vs/
|
||||||
|
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||||
|
#wwwroot/
|
||||||
|
|
||||||
|
# Visual Studio 2017 auto generated files
|
||||||
|
Generated\ Files/
|
||||||
|
|
||||||
|
# MSTest test Results
|
||||||
|
[Tt]est[Rr]esult*/
|
||||||
|
[Bb]uild[Ll]og.*
|
||||||
|
|
||||||
|
# NUnit
|
||||||
|
*.VisualState.xml
|
||||||
|
TestResult.xml
|
||||||
|
nunit-*.xml
|
||||||
|
|
||||||
|
# Build Results of an ATL Project
|
||||||
|
[Dd]ebugPS/
|
||||||
|
[Rr]eleasePS/
|
||||||
|
dlldata.c
|
||||||
|
|
||||||
|
# Benchmark Results
|
||||||
|
BenchmarkDotNet.Artifacts/
|
||||||
|
|
||||||
|
# .NET Core
|
||||||
|
project.lock.json
|
||||||
|
project.fragment.lock.json
|
||||||
|
artifacts/
|
||||||
|
|
||||||
|
# StyleCop
|
||||||
|
StyleCopReport.xml
|
||||||
|
|
||||||
|
# Files built by Visual Studio
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*_h.h
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.obj
|
||||||
|
*.iobj
|
||||||
|
*.pch
|
||||||
|
*.pdb
|
||||||
|
*.ipdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.tmp_proj
|
||||||
|
*_wpftmp.csproj
|
||||||
|
*.log
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
.builds
|
||||||
|
*.pidb
|
||||||
|
*.svclog
|
||||||
|
*.scc
|
||||||
|
|
||||||
|
# Chutzpah Test files
|
||||||
|
_Chutzpah*
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opendb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
*.cachefile
|
||||||
|
*.VC.db
|
||||||
|
*.VC.VC.opendb
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.vspx
|
||||||
|
*.sap
|
||||||
|
|
||||||
|
# Visual Studio Trace Files
|
||||||
|
*.e2e
|
||||||
|
|
||||||
|
# TFS 2012 Local Workspace
|
||||||
|
$tf/
|
||||||
|
|
||||||
|
# Guidance Automation Toolkit
|
||||||
|
*.gpState
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*/
|
||||||
|
*.[Rr]e[Ss]harper
|
||||||
|
*.DotSettings.user
|
||||||
|
|
||||||
|
# JustCode is a .NET coding add-in
|
||||||
|
.JustCode
|
||||||
|
|
||||||
|
# TeamCity is a build add-in
|
||||||
|
_TeamCity*
|
||||||
|
|
||||||
|
# DotCover is a Code Coverage Tool
|
||||||
|
*.dotCover
|
||||||
|
|
||||||
|
# AxoCover is a Code Coverage Tool
|
||||||
|
.axoCover/*
|
||||||
|
!.axoCover/settings.json
|
||||||
|
|
||||||
|
# Visual Studio code coverage results
|
||||||
|
*.coverage
|
||||||
|
*.coveragexml
|
||||||
|
|
||||||
|
# NCrunch
|
||||||
|
_NCrunch_*
|
||||||
|
.*crunch*.local.xml
|
||||||
|
nCrunchTemp_*
|
||||||
|
|
||||||
|
# MightyMoose
|
||||||
|
*.mm.*
|
||||||
|
AutoTest.Net/
|
||||||
|
|
||||||
|
# Web workbench (sass)
|
||||||
|
.sass-cache/
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress/
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
publish/
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
*.[Pp]ublish.xml
|
||||||
|
*.azurePubxml
|
||||||
|
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||||
|
# but database connection strings (with potential passwords) will be unencrypted
|
||||||
|
*.pubxml
|
||||||
|
*.publishproj
|
||||||
|
|
||||||
|
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||||
|
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||||
|
# in these scripts will be unencrypted
|
||||||
|
PublishScripts/
|
||||||
|
|
||||||
|
# NuGet Packages
|
||||||
|
*.nupkg
|
||||||
|
# NuGet Symbol Packages
|
||||||
|
*.snupkg
|
||||||
|
# The packages folder can be ignored because of Package Restore
|
||||||
|
**/[Pp]ackages/*
|
||||||
|
# except build/, which is used as an MSBuild target.
|
||||||
|
!**/[Pp]ackages/build/
|
||||||
|
# Uncomment if necessary however generally it will be regenerated when needed
|
||||||
|
#!**/[Pp]ackages/repositories.config
|
||||||
|
# NuGet v3's project.json files produces more ignorable files
|
||||||
|
*.nuget.props
|
||||||
|
*.nuget.targets
|
||||||
|
|
||||||
|
# Microsoft Azure Build Output
|
||||||
|
csx/
|
||||||
|
*.build.csdef
|
||||||
|
|
||||||
|
# Microsoft Azure Emulator
|
||||||
|
ecf/
|
||||||
|
rcf/
|
||||||
|
|
||||||
|
# Windows Store app package directories and files
|
||||||
|
AppPackages/
|
||||||
|
BundleArtifacts/
|
||||||
|
Package.StoreAssociation.xml
|
||||||
|
_pkginfo.txt
|
||||||
|
*.appx
|
||||||
|
*.appxbundle
|
||||||
|
*.appxupload
|
||||||
|
|
||||||
|
# Visual Studio cache files
|
||||||
|
# files ending in .cache can be ignored
|
||||||
|
*.[Cc]ache
|
||||||
|
# but keep track of directories ending in .cache
|
||||||
|
!?*.[Cc]ache/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
ClientBin/
|
||||||
|
~$*
|
||||||
|
*~
|
||||||
|
*.dbmdl
|
||||||
|
*.dbproj.schemaview
|
||||||
|
*.jfm
|
||||||
|
*.pfx
|
||||||
|
*.publishsettings
|
||||||
|
orleans.codegen.cs
|
||||||
|
|
||||||
|
# Including strong name files can present a security risk
|
||||||
|
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||||
|
#*.snk
|
||||||
|
|
||||||
|
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||||
|
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||||
|
#bower_components/
|
||||||
|
|
||||||
|
# RIA/Silverlight projects
|
||||||
|
Generated_Code/
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file
|
||||||
|
# to a newer Visual Studio version. Backup files are not needed,
|
||||||
|
# because we have git ;-)
|
||||||
|
_UpgradeReport_Files/
|
||||||
|
Backup*/
|
||||||
|
UpgradeLog*.XML
|
||||||
|
UpgradeLog*.htm
|
||||||
|
ServiceFabricBackup/
|
||||||
|
*.rptproj.bak
|
||||||
|
|
||||||
|
# SQL Server files
|
||||||
|
*.mdf
|
||||||
|
*.ldf
|
||||||
|
*.ndf
|
||||||
|
|
||||||
|
# Business Intelligence projects
|
||||||
|
*.rdl.data
|
||||||
|
*.bim.layout
|
||||||
|
*.bim_*.settings
|
||||||
|
*.rptproj.rsuser
|
||||||
|
*- [Bb]ackup.rdl
|
||||||
|
*- [Bb]ackup ([0-9]).rdl
|
||||||
|
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||||
|
|
||||||
|
# Microsoft Fakes
|
||||||
|
FakesAssemblies/
|
||||||
|
|
||||||
|
# GhostDoc plugin setting file
|
||||||
|
*.GhostDoc.xml
|
||||||
|
|
||||||
|
# Node.js Tools for Visual Studio
|
||||||
|
.ntvs_analysis.dat
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# Visual Studio 6 build log
|
||||||
|
*.plg
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace options file
|
||||||
|
*.opt
|
||||||
|
|
||||||
|
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||||
|
*.vbw
|
||||||
|
|
||||||
|
# Visual Studio LightSwitch build output
|
||||||
|
**/*.HTMLClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/ModelManifest.xml
|
||||||
|
**/*.Server/GeneratedArtifacts
|
||||||
|
**/*.Server/ModelManifest.xml
|
||||||
|
_Pvt_Extensions
|
||||||
|
|
||||||
|
# Paket dependency manager
|
||||||
|
.paket/paket.exe
|
||||||
|
paket-files/
|
||||||
|
|
||||||
|
# FAKE - F# Make
|
||||||
|
.fake/
|
||||||
|
|
||||||
|
# CodeRush personal settings
|
||||||
|
.cr/personal
|
||||||
|
|
||||||
|
# Python Tools for Visual Studio (PTVS)
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
|
||||||
|
# Cake - Uncomment if you are using it
|
||||||
|
# tools/**
|
||||||
|
# !tools/packages.config
|
||||||
|
|
||||||
|
# Tabs Studio
|
||||||
|
*.tss
|
||||||
|
|
||||||
|
# Telerik's JustMock configuration file
|
||||||
|
*.jmconfig
|
||||||
|
|
||||||
|
# BizTalk build output
|
||||||
|
*.btp.cs
|
||||||
|
*.btm.cs
|
||||||
|
*.odx.cs
|
||||||
|
*.xsd.cs
|
||||||
|
|
||||||
|
# OpenCover UI analysis results
|
||||||
|
OpenCover/
|
||||||
|
|
||||||
|
# Azure Stream Analytics local run output
|
||||||
|
ASALocalRun/
|
||||||
|
|
||||||
|
# MSBuild Binary and Structured Log
|
||||||
|
*.binlog
|
||||||
|
|
||||||
|
# NVidia Nsight GPU debugger configuration file
|
||||||
|
*.nvuser
|
||||||
|
|
||||||
|
# MFractors (Xamarin productivity tool) working folder
|
||||||
|
.mfractor/
|
||||||
|
|
||||||
|
# Local History for Visual Studio
|
||||||
|
.localhistory/
|
||||||
|
|
||||||
|
# BeatPulse healthcheck temp database
|
||||||
|
healthchecksdb
|
||||||
|
|
||||||
|
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||||
|
MigrationBackup/
|
29
README.md
Normal file
29
README.md
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
# X10D
|
||||||
|
Extension methods on crack
|
||||||
|
|
||||||
|
## About
|
||||||
|
X10D (pronounced *extend*), is a collection of class libraries that provide various .NET extension methods, including extension methods for Unity, Windows Forms and System.Drawing.
|
||||||
|
|
||||||
|
## Extended Classes
|
||||||
|
Below is a list of the number of extension methods written for a given type. Overloaded methods are not counted.
|
||||||
|
|Type|Library|Method count|
|
||||||
|
|- |- |- |
|
||||||
|
|`byte` / `byte[]`|`X10D`|8|
|
||||||
|
|`char`|`X10D`|1|
|
||||||
|
|`IComparable`|`X10D`|2|
|
||||||
|
|`IConvertible`|`X10D`|4|
|
||||||
|
|`DateTime`|`X10D`|12|
|
||||||
|
|`double`|`X10D`|5|
|
||||||
|
|`enum`|`X10D`|2|
|
||||||
|
|`float`|`X10D`|5|
|
||||||
|
|`short` / `ushort`|`X10D`|15|
|
||||||
|
|`int` / `uint`|`X10D`|15|
|
||||||
|
|`long` / `ulong`|`X10D`|15|
|
||||||
|
|`IList<T>`|`X10D`|1|
|
||||||
|
|`Random`|`X10D`|1|
|
||||||
|
|`SecureString`|`X10D`|1|
|
||||||
|
|`string`|`X10D`|6|
|
||||||
|
|`TimeSpan`|`X10D`|1|
|
||||||
|
|`System.Drawing.Image`|`X10D.Drawing`|2 (+ async)|
|
||||||
|
|`UnityEngine.Material`|`X10D.Unity`|1|
|
||||||
|
|`System.Windows.Forms.Control`|`X10D.WinForms`|1|
|
174
X10D.Drawing/ImageExtensions.cs
Normal file
174
X10D.Drawing/ImageExtensions.cs
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
namespace X10D.Drawing
|
||||||
|
{
|
||||||
|
#region Using Directives
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Drawing.Drawing2D;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Extension methods for <see cref="Image"/>.
|
||||||
|
/// </summary>
|
||||||
|
public static class ImageExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Asynchronously converts the image so that its aspect ratio is 1:1, surrounding any new area with
|
||||||
|
/// transparency.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="image">The image to convert.</param>
|
||||||
|
/// <returns>Returns an <see cref="Image"/>.</returns>
|
||||||
|
public static async Task<Image> ToSquareAsync(this Image image) =>
|
||||||
|
await Task.Run(image.ToSquare);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Asynchronously converts the image so that its aspect ratio is 1:1, surrounding any new area with
|
||||||
|
/// transparency.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="image">The image to convert.</param>
|
||||||
|
/// <param name="size">The new size of the image, i.e. the value of both the width and height.</param>
|
||||||
|
/// <returns>Returns an <see cref="Image"/>.</returns>
|
||||||
|
public static async Task<Image> ToSquareAsync(this Image image, int size) =>
|
||||||
|
await Task.Run(() => image.ToSquare(size));
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Asynchronously converts the image so that its aspect ratio is 1:1, surrounding any new area with a
|
||||||
|
/// specified background color.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="image">The image to convert.</param>
|
||||||
|
/// <param name="size">The new size of the image, i.e. the value of both the width and height.</param>
|
||||||
|
/// <param name="background">The background color to fill.</param>
|
||||||
|
/// <returns>Returns an <see cref="Image"/>.</returns>
|
||||||
|
public static async Task<Image> ToSquareAsync(this Image image, int size, Color background) =>
|
||||||
|
await Task.Run(() => image.ToSquare(size, background));
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Asynchronously converts the image so that its aspect ratio is 1:1, surrounding any new area with a
|
||||||
|
/// specified background color.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="image">The image to convert.</param>
|
||||||
|
/// <param name="background">The background color to fill.</param>
|
||||||
|
/// <returns>Returns an <see cref="Image"/>.</returns>
|
||||||
|
public static async Task<Image> ToSquareAsync(this Image image, Color background) =>
|
||||||
|
await Task.Run(() => image.ToSquare(background));
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the image so that its aspect ratio is 1:1, surrounding any new area with transparency.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="image">The image to convert.</param>
|
||||||
|
/// <returns>Returns an <see cref="Image"/>.</returns>
|
||||||
|
public static Image ToSquare(this Image image) =>
|
||||||
|
image.ToSquare(Color.Transparent);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the image so that its aspect ratio is 1:1, surrounding any new area with transparency.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="image">The image to convert.</param>
|
||||||
|
/// <param name="size">The new size of the image, i.e. the value of both the width and height.</param>
|
||||||
|
/// <returns>Returns an <see cref="Image"/>.</returns>
|
||||||
|
public static Image ToSquare(this Image image, int size) =>
|
||||||
|
image.ToSquare(size, Color.Transparent);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the image so that its aspect ratio is 1:1, surrounding any new area with a specified background
|
||||||
|
/// color.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="image">The image to convert.</param>
|
||||||
|
/// <param name="background">The background color to fill.</param>
|
||||||
|
/// <returns>Returns an <see cref="Image"/>.</returns>
|
||||||
|
public static Image ToSquare(this Image image, Color background)
|
||||||
|
{
|
||||||
|
int resolution = Math.Max(image.Width, image.Height);
|
||||||
|
return image.ToSquare(resolution, background);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the image so that its aspect ratio is 1:1, surrounding any new area with a specified background
|
||||||
|
/// color.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="image">The image to convert.</param>
|
||||||
|
/// <param name="size">The new size of the image, i.e. the value of both the width and height.</param>
|
||||||
|
/// <param name="background">The background color to fill.</param>
|
||||||
|
/// <returns>Returns an <see cref="Image"/>.</returns>
|
||||||
|
public static Image ToSquare(this Image image, int size, Color background)
|
||||||
|
{
|
||||||
|
int resolution = Math.Max(image.Width, image.Height);
|
||||||
|
Bitmap newImage = new Bitmap(resolution, resolution);
|
||||||
|
|
||||||
|
using (Graphics graphics = Graphics.FromImage(newImage))
|
||||||
|
{
|
||||||
|
graphics.FillRectangle(new SolidBrush(background), new Rectangle(0, 0,
|
||||||
|
resolution, resolution));
|
||||||
|
|
||||||
|
graphics.DrawImageUnscaled(image, resolution / 2 - image.Width / 2,
|
||||||
|
resolution / 2 - image.Height / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return newImage.Scale(size, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Asynchronously scales the image.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="image">The image to scale.</param>
|
||||||
|
/// <param name="width">The new width.</param>
|
||||||
|
/// <param name="height">The new height.</param>
|
||||||
|
/// <returns>Returns a new <see cref="Image"/>.</returns>
|
||||||
|
public static async Task<Bitmap> ScaleAsync(this Image image, int width, int height) =>
|
||||||
|
await Task.Run(() => image.Scale(width, height));
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Asynchronously scales the image.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="image">The image to scale.</param>
|
||||||
|
/// <param name="factor">The scale factor.</param>
|
||||||
|
/// <returns>Returns a new <see cref="Image"/>.</returns>
|
||||||
|
public static async Task<Bitmap> ScaleAsync(this Image image, float factor) =>
|
||||||
|
await Task.Run(() => image.Scale(factor));
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Scales the image.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="image">The image to scale.</param>
|
||||||
|
/// <param name="factor">The scale factor.</param>
|
||||||
|
/// <returns>Returns a new <see cref="Image"/>.</returns>
|
||||||
|
public static Bitmap Scale(this Image image, float factor) =>
|
||||||
|
image.Scale((int)(image.Width * factor), (int)(image.Height * factor));
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Scales the image.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="image">The image to scale.</param>
|
||||||
|
/// <param name="width">The new width.</param>
|
||||||
|
/// <param name="height">The new height.</param>
|
||||||
|
/// <returns>Returns a new <see cref="Image"/>.</returns>
|
||||||
|
public static Bitmap Scale(this Image image, int width, int height)
|
||||||
|
{
|
||||||
|
Rectangle destRect = new Rectangle(0, 0, width, height);
|
||||||
|
Bitmap destImage = new Bitmap(width, height);
|
||||||
|
|
||||||
|
destImage.SetResolution(image.HorizontalResolution, image.VerticalResolution);
|
||||||
|
|
||||||
|
using (Graphics graphics = Graphics.FromImage(destImage))
|
||||||
|
{
|
||||||
|
graphics.CompositingMode = CompositingMode.SourceCopy;
|
||||||
|
graphics.CompositingQuality = CompositingQuality.HighQuality;
|
||||||
|
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||||
|
graphics.SmoothingMode = SmoothingMode.HighQuality;
|
||||||
|
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
||||||
|
|
||||||
|
using (ImageAttributes wrapMode = new ImageAttributes())
|
||||||
|
{
|
||||||
|
wrapMode.SetWrapMode(WrapMode.TileFlipXY);
|
||||||
|
graphics.DrawImage(image, destRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel,
|
||||||
|
wrapMode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return destImage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
36
X10D.Drawing/Properties/AssemblyInfo.cs
Normal file
36
X10D.Drawing/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("Extensions.Drawing")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("Extensions.Drawing")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("9e27fb65-4182-443c-8abe-71292f892b59")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
49
X10D.Drawing/X10D.Drawing.csproj
Normal file
49
X10D.Drawing/X10D.Drawing.csproj
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{9E27FB65-4182-443C-8ABE-71292F892B59}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>X10D.Drawing</RootNamespace>
|
||||||
|
<AssemblyName>X10D.Drawing</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<Deterministic>true</Deterministic>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Drawing" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="ImageExtensions.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
82
X10D.Unity/MaterialExtensions.cs
Normal file
82
X10D.Unity/MaterialExtensions.cs
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
namespace X10D.Unity
|
||||||
|
{
|
||||||
|
#region Using Directives
|
||||||
|
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A set of extension methods for <see cref="Material"/>.
|
||||||
|
/// </summary>
|
||||||
|
public static class MaterialExtensions
|
||||||
|
{
|
||||||
|
private static readonly int srcBlend = Shader.PropertyToID("_SrcBlend");
|
||||||
|
private static readonly int dstBlend = Shader.PropertyToID("_DstBlend");
|
||||||
|
private static readonly int zWrite = Shader.PropertyToID("_ZWrite");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// An enumeration of blend modes.
|
||||||
|
/// </summary>
|
||||||
|
public enum BlendMode
|
||||||
|
{
|
||||||
|
Opaque,
|
||||||
|
Cutout,
|
||||||
|
Fade,
|
||||||
|
Transparent
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Changes the material's blend mode.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="material">The material.</param>
|
||||||
|
/// <param name="blendMode">The blend mode.</param>
|
||||||
|
[SuppressMessage("ReSharper", "StringLiteralTypo")]
|
||||||
|
public static void ChangeRenderMode(this Material material, BlendMode blendMode)
|
||||||
|
{
|
||||||
|
switch (blendMode)
|
||||||
|
{
|
||||||
|
case BlendMode.Opaque:
|
||||||
|
material.SetInt(srcBlend, (int)UnityEngine.Rendering.BlendMode.One);
|
||||||
|
material.SetInt(dstBlend, (int)UnityEngine.Rendering.BlendMode.Zero);
|
||||||
|
material.SetInt(zWrite, 1);
|
||||||
|
material.DisableKeyword("_ALPHATEST_ON");
|
||||||
|
material.DisableKeyword("_ALPHABLEND_ON");
|
||||||
|
material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
|
||||||
|
material.renderQueue = -1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BlendMode.Cutout:
|
||||||
|
material.SetInt(srcBlend, (int)UnityEngine.Rendering.BlendMode.One);
|
||||||
|
material.SetInt(dstBlend, (int)UnityEngine.Rendering.BlendMode.Zero);
|
||||||
|
material.SetInt(zWrite, 1);
|
||||||
|
material.EnableKeyword("_ALPHATEST_ON");
|
||||||
|
material.DisableKeyword("_ALPHABLEND_ON");
|
||||||
|
material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
|
||||||
|
material.renderQueue = 2450;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BlendMode.Fade:
|
||||||
|
material.SetInt(srcBlend, (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
|
||||||
|
material.SetInt(dstBlend, (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
|
||||||
|
material.SetInt(zWrite, 0);
|
||||||
|
material.DisableKeyword("_ALPHATEST_ON");
|
||||||
|
material.EnableKeyword("_ALPHABLEND_ON");
|
||||||
|
material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
|
||||||
|
material.renderQueue = 3000;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BlendMode.Transparent:
|
||||||
|
material.SetInt(srcBlend, (int)UnityEngine.Rendering.BlendMode.One);
|
||||||
|
material.SetInt(dstBlend, (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
|
||||||
|
material.SetInt(zWrite, 0);
|
||||||
|
material.DisableKeyword("_ALPHATEST_ON");
|
||||||
|
material.DisableKeyword("_ALPHABLEND_ON");
|
||||||
|
material.EnableKeyword("_ALPHAPREMULTIPLY_ON");
|
||||||
|
material.renderQueue = 3000;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
36
X10D.Unity/Properties/AssemblyInfo.cs
Normal file
36
X10D.Unity/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("Extensions.Unity")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("Extensions.Unity")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2019")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("2657ef66-0334-4a5a-8c24-6c949224a989")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
62
X10D.Unity/Vector3Extensions.cs
Normal file
62
X10D.Unity/Vector3Extensions.cs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
namespace X10D.Unity
|
||||||
|
{
|
||||||
|
#region Using Directives
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A set of extension methods for <see cref="Vector3"/>.
|
||||||
|
/// </summary>
|
||||||
|
public static class Vector3Extensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Converts a vector normal to an Euler rotation.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="v">The vector normal.</param>
|
||||||
|
/// <returns>Returns a <see cref="Vector3"/> representing the Euler rotation.</returns>
|
||||||
|
public static Vector3 NormalToEulerAngles(this Vector3 v)
|
||||||
|
{
|
||||||
|
float x = v.x;
|
||||||
|
v.x = v.z;
|
||||||
|
v.z = x;
|
||||||
|
v.z *= 2.0f * v.y;
|
||||||
|
v.y = 0.0f;
|
||||||
|
return v * 90.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Rounds a vector to the nearest value.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="v">The vector to round.</param>
|
||||||
|
/// <param name="nearest">The nearest value.</param>
|
||||||
|
/// <returns>Returns a <see cref="Vector3"/> containing the rounded values.</returns>
|
||||||
|
public static Vector3 Round(this Vector3 v, int nearest = 1) =>
|
||||||
|
new Vector3(v.x.Round(nearest), v.y.Round(nearest), v.z.Round(nearest));
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Inverts the X component of a vector.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="v">The vector to evaluate.</param>
|
||||||
|
/// <returns>Returns a <see cref="Vector3"/> whose values are (-X, Y, Z).</returns>
|
||||||
|
public static Vector3 InvertX(this Vector3 v) =>
|
||||||
|
new Vector3(-v.x, v.y, v.z);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Inverts the Y component of a vector.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="v">The vector to evaluate.</param>
|
||||||
|
/// <returns>Returns a <see cref="Vector3"/> whose values are (X, -Y, Z).</returns>
|
||||||
|
public static Vector3 InvertY(this Vector3 v) =>
|
||||||
|
new Vector3(v.x, -v.y, v.z);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Inverts the Z component of a vector.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="v">The vector to evaluate.</param>
|
||||||
|
/// <returns>Returns a <see cref="Vector3"/> whose values are (X, Y, -Z).</returns>
|
||||||
|
public static Vector3 InvertZ(this Vector3 v) =>
|
||||||
|
new Vector3(v.x, v.y, -v.z);
|
||||||
|
}
|
||||||
|
}
|
61
X10D.Unity/X10D.Unity.csproj
Normal file
61
X10D.Unity/X10D.Unity.csproj
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{2657EF66-0334-4A5A-8C24-6C949224A989}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>X10D.Unity</RootNamespace>
|
||||||
|
<AssemblyName>X10D.Unity</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<Deterministic>true</Deterministic>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
<Reference Include="UnityEngine">
|
||||||
|
<HintPath>F:\Program Files\Unity\2019.1.0f2\Editor\Data\Managed\UnityEngine\UnityEngine.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.CoreModule">
|
||||||
|
<HintPath>F:\Program Files\Unity\2019.1.0f2\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="MaterialExtensions.cs" />
|
||||||
|
<Compile Include="Vector3Extensions.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\X10D\X10D.csproj">
|
||||||
|
<Project>{de210f83-fc9a-4c23-ac2c-7a060960f716}</Project>
|
||||||
|
<Name>X10D</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
32
X10D.WinForms/ControlExtensions.cs
Normal file
32
X10D.WinForms/ControlExtensions.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
namespace X10D.WinForms
|
||||||
|
{
|
||||||
|
#region Using Directives
|
||||||
|
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Extension methods for <see cref="Control"/>.
|
||||||
|
/// </summary>
|
||||||
|
public static class ControlExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Thread-safe method invocation. Calls <see cref="Control.Invoke(System.Delegate)"/> if
|
||||||
|
/// <see cref="Control.InvokeRequired"/> returns <see langword="true"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="control">The control from which to invoke.</param>
|
||||||
|
/// <param name="action">The action to invoke.</param>
|
||||||
|
public static void InvokeIfRequired(this Control control, MethodInvoker action)
|
||||||
|
{
|
||||||
|
if (control?.InvokeRequired ?? false)
|
||||||
|
{
|
||||||
|
control.Invoke(action);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
action();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
36
X10D.WinForms/Properties/AssemblyInfo.cs
Normal file
36
X10D.WinForms/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("Extensions.WinForms")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("Extensions.WinForms")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("8bc9ef95-dc0f-4866-a01e-f07bbc675829")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
49
X10D.WinForms/X10D.WinForms.csproj
Normal file
49
X10D.WinForms/X10D.WinForms.csproj
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{8BC9EF95-DC0F-4866-A01E-F07BBC675829}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>X10D.WinForms</RootNamespace>
|
||||||
|
<AssemblyName>X10D.WinForms</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<Deterministic>true</Deterministic>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Windows.Forms" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="ControlExtensions.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
43
X10D.sln
Normal file
43
X10D.sln
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 16
|
||||||
|
VisualStudioVersion = 16.0.28902.138
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "X10D", "X10D\X10D.csproj", "{DE210F83-FC9A-4C23-AC2C-7A060960F716}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "X10D.WinForms", "X10D.WinForms\X10D.WinForms.csproj", "{8BC9EF95-DC0F-4866-A01E-F07BBC675829}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "X10D.Drawing", "X10D.Drawing\X10D.Drawing.csproj", "{9E27FB65-4182-443C-8ABE-71292F892B59}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "X10D.Unity", "X10D.Unity\X10D.Unity.csproj", "{2657EF66-0334-4A5A-8C24-6C949224A989}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{DE210F83-FC9A-4C23-AC2C-7A060960F716}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{DE210F83-FC9A-4C23-AC2C-7A060960F716}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{DE210F83-FC9A-4C23-AC2C-7A060960F716}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{DE210F83-FC9A-4C23-AC2C-7A060960F716}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{8BC9EF95-DC0F-4866-A01E-F07BBC675829}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{8BC9EF95-DC0F-4866-A01E-F07BBC675829}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{8BC9EF95-DC0F-4866-A01E-F07BBC675829}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{8BC9EF95-DC0F-4866-A01E-F07BBC675829}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{9E27FB65-4182-443C-8ABE-71292F892B59}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{9E27FB65-4182-443C-8ABE-71292F892B59}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{9E27FB65-4182-443C-8ABE-71292F892B59}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{9E27FB65-4182-443C-8ABE-71292F892B59}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{2657EF66-0334-4A5A-8C24-6C949224A989}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{2657EF66-0334-4A5A-8C24-6C949224A989}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{2657EF66-0334-4A5A-8C24-6C949224A989}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{2657EF66-0334-4A5A-8C24-6C949224A989}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {6F733785-8837-410C-BD91-C4AD1F0A6914}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
94
X10D/ByteExtensions.cs
Normal file
94
X10D/ByteExtensions.cs
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
namespace X10D
|
||||||
|
{
|
||||||
|
#region Using Directives
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Extension methods for <see cref="Byte"/>.
|
||||||
|
/// </summary>
|
||||||
|
public static class ByteExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a <see cref="String"/> literally representing the raw values in the <see cref="Byte"/>[].
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bytes">The bytes to get.</param>
|
||||||
|
/// <returns>Returns a <see cref="String"/>.</returns>
|
||||||
|
public static string AsString(this IEnumerable<byte> bytes) =>
|
||||||
|
BitConverter.ToString(bytes.ToArray());
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the <see cref="Byte"/>[] to an <see cref="Int16"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bytes">The bytes to convert.</param>
|
||||||
|
/// <returns>Returns an <see cref="Int16"/>.</returns>
|
||||||
|
public static short GetInt16(this IEnumerable<byte> bytes) =>
|
||||||
|
BitConverter.ToInt16(bytes.ToArray(), 0);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the <see cref="Byte"/>[] to an <see cref="Int32"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bytes">The bytes to convert.</param>
|
||||||
|
/// <returns>Returns an <see cref="Int32"/>.</returns>
|
||||||
|
public static int GetInt32(this IEnumerable<byte> bytes) =>
|
||||||
|
BitConverter.ToInt32(bytes.ToArray(), 0);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the <see cref="Byte"/>[] to an <see cref="Int64"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bytes">The bytes to convert.</param>
|
||||||
|
/// <returns>Returns an <see cref="Int64"/>.</returns>
|
||||||
|
public static long GetInt64(this IEnumerable<byte> bytes) =>
|
||||||
|
BitConverter.ToInt64(bytes.ToArray(), 0);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the <see cref="Byte"/>[] to a <see cref="UInt16"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bytes">The bytes to convert.</param>
|
||||||
|
/// <returns>Returns an <see cref="UInt16"/>.</returns>
|
||||||
|
public static ushort GetUInt16(this IEnumerable<byte> bytes) =>
|
||||||
|
BitConverter.ToUInt16(bytes.ToArray(), 0);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the <see cref="Byte"/>[] to an <see cref="UInt32"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bytes">The bytes to convert.</param>
|
||||||
|
/// <returns>Returns an <see cref="UInt32"/>.</returns>
|
||||||
|
public static uint GetUInt32(this IEnumerable<byte> bytes) =>
|
||||||
|
BitConverter.ToUInt32(bytes.ToArray(), 0);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the <see cref="Byte"/>[] to an <see cref="UInt64"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bytes">The bytes to convert.</param>
|
||||||
|
/// <returns>Returns an <see cref="UInt64"/>.</returns>
|
||||||
|
public static ulong GetUInt64(this IEnumerable<byte> bytes) =>
|
||||||
|
BitConverter.ToUInt64(bytes.ToArray(), 0);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a <see cref="String"/> representing the value the <see cref="Byte"/>[] with
|
||||||
|
/// <see cref="Encoding.UTF8"/> encoding.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bytes">The bytes to convert.</param>
|
||||||
|
/// <returns>Returns a <see cref="String"/>.</returns>
|
||||||
|
public static string GetString(this IEnumerable<byte> bytes) =>
|
||||||
|
bytes.GetString(Encoding.UTF8);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a <see cref="String"/> representing the value the <see cref="Byte"/>[] with the provided encoding.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bytes">The bytes to convert.</param>
|
||||||
|
/// <param name="encoding">The encoding to use.</param>
|
||||||
|
/// <returns>Returns a <see cref="String"/>.</returns>
|
||||||
|
public static string GetString(this IEnumerable<byte> bytes, Encoding encoding)
|
||||||
|
{
|
||||||
|
IEnumerable<byte> enumerable = bytes as byte[] ?? bytes.ToArray();
|
||||||
|
return encoding.GetString(enumerable.ToArray(), 0, enumerable.Count());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
24
X10D/CharExtensions.cs
Normal file
24
X10D/CharExtensions.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
namespace X10D
|
||||||
|
{
|
||||||
|
#region Using Directives
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Extension methods for <see cref="Char"/>.
|
||||||
|
/// </summary>
|
||||||
|
public static class CharExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Repeats a character a specified number of times.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="c">The character to repeat.</param>
|
||||||
|
/// <param name="count">The repeat count.</param>
|
||||||
|
/// <returns>Returns a <see cref="String"/> whose value is <paramref name="c"/> repeated
|
||||||
|
/// <paramref name="count"/> times.</returns>
|
||||||
|
public static string Repeat(this char c, int count) =>
|
||||||
|
new string(c, count);
|
||||||
|
}
|
||||||
|
}
|
34
X10D/ComparableExtensions.cs
Normal file
34
X10D/ComparableExtensions.cs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
namespace X10D
|
||||||
|
{
|
||||||
|
#region Using Directives
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Extension methods for <see cref="IComparable"/>.
|
||||||
|
/// </summary>
|
||||||
|
public static class ComparableExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Determines if <paramref name="actual"/> is between <paramref name="lower"/> and <paramref name="upper"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The comparable type.</typeparam>
|
||||||
|
/// <param name="actual">The value to compare.</param>
|
||||||
|
/// <param name="lower">The inclusive lower bound.</param>
|
||||||
|
/// <param name="upper">The exclusive upper bound.</param>
|
||||||
|
/// <returns>Returns <see langword="true"/> if the value is between the bounds, <see langword="false"/>
|
||||||
|
/// otherwise.</returns>
|
||||||
|
public static bool Between<T>(this T actual, T lower, T upper) where T : IComparable<T> =>
|
||||||
|
actual.CompareTo(lower) > 0 && actual.CompareTo(upper) < 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the value
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static TimeSpan Days(this IComparable value) =>
|
||||||
|
TimeSpan.FromDays((double)value);
|
||||||
|
}
|
||||||
|
}
|
142
X10D/ConvertibleExtensions.cs
Normal file
142
X10D/ConvertibleExtensions.cs
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
namespace X10D
|
||||||
|
{
|
||||||
|
#region Using Directives
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Extension methods for <see cref="IConvertible"/>.
|
||||||
|
/// </summary>
|
||||||
|
public static class ConvertibleExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the object to another type.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The type to convert to.</typeparam>
|
||||||
|
/// <param name="obj">The object to convert.</param>
|
||||||
|
/// <returns>Returns the value converted to <see cref="T"/>.</returns>
|
||||||
|
public static T To<T>(this IConvertible obj) =>
|
||||||
|
(T) Convert.ChangeType(obj, typeof(T));
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the object to another type, returning the default value on failure.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The type to convert to.</typeparam>
|
||||||
|
/// <param name="obj">The object to convert.</param>
|
||||||
|
/// <returns>Returns the value converted to <see cref="T"/>.</returns>
|
||||||
|
public static T ToOrDefault<T>(this IConvertible obj)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return To<T>(obj);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the object to another type, returning the default value on failure.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The type to convert to.</typeparam>
|
||||||
|
/// <param name="obj">The object to convert.</param>
|
||||||
|
/// <param name="newObj">The parameter where the result should be sent.</param>
|
||||||
|
/// <returns>Returns <see langword="true"/> on success, <see langword="true"/> on failure.</returns>
|
||||||
|
public static bool ToOrDefault<T>(this IConvertible obj, out T newObj)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newObj = To<T>(obj);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
newObj = default;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the object to another type, returning a different value on failure.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The type to convert to.</typeparam>
|
||||||
|
/// <param name="obj">The object to convert.</param>
|
||||||
|
/// <param name="other">The backup value.</param>
|
||||||
|
/// <returns>Returns the value converted to <see cref="T"/>.</returns>
|
||||||
|
public static T ToOrOther<T>(this IConvertible obj, T other)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return To<T>(obj);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return other;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the object to another type, returning a different value on failure.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The type to convert to.</typeparam>
|
||||||
|
/// <param name="obj">The object to convert.</param>
|
||||||
|
/// <param name="newObj">The parameter where the result should be sent.</param>
|
||||||
|
/// <param name="other">The backup value.</param>
|
||||||
|
/// <returns>Returns <see langword="true"/> on success, <see langword="true"/> on failure.</returns>
|
||||||
|
public static bool ToOrOther<T>(this IConvertible obj, out T newObj, T other)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newObj = To<T>(obj);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
newObj = other;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the object to another type, returning <see langword="null"/> on failure.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The type to convert to.</typeparam>
|
||||||
|
/// <param name="obj">The object to convert.</param>
|
||||||
|
/// <returns>Returns a <see cref="T"/> or <see langword="null"/>.</returns>
|
||||||
|
public static T ToOrNull<T>(this IConvertible obj) where T : class
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return To<T>(obj);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the object to another type, returning <see langword="null"/> on failure.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The type to convert to.</typeparam>
|
||||||
|
/// <param name="obj">The object to convert.</param>
|
||||||
|
/// <param name="newObj">The parameter where the result should be sent.</param>
|
||||||
|
/// <returns>Returns a <see cref="T"/> or <see langword="null"/>.</returns>
|
||||||
|
public static bool ToOrNull<T>(this IConvertible obj, out T newObj) where T : class
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newObj = To<T>(obj);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
newObj = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
162
X10D/DateTimeExtensions.cs
Normal file
162
X10D/DateTimeExtensions.cs
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
namespace X10D
|
||||||
|
{
|
||||||
|
#region Using Directives
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Extension methods for <see cref="DateTime"/>.
|
||||||
|
/// </summary>
|
||||||
|
public static class DateTimeExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents the Unix epoch - midnight on January 1, 1970.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Calculates someone's age based on a date of birth.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dateOfBirth">The date of birth.</param>
|
||||||
|
public static int Age(this DateTime dateOfBirth) =>
|
||||||
|
(int) (((DateTime.Today - TimeSpan.FromDays(1) - dateOfBirth.Date).TotalDays + 1) / 365.2425);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a DateTime representing the first specified day in the current month
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="current">The current day</param>
|
||||||
|
/// <param name="dayOfWeek">The current day of week</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static DateTime First(this DateTime current, DayOfWeek dayOfWeek)
|
||||||
|
{
|
||||||
|
DateTime first = current.FirstDayOfMonth();
|
||||||
|
|
||||||
|
if (first.DayOfWeek != dayOfWeek)
|
||||||
|
{
|
||||||
|
first = first.Next(dayOfWeek);
|
||||||
|
}
|
||||||
|
|
||||||
|
return first;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a <see cref="DateTime"/> representing the first day in the current month.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="current">The current date.</param>
|
||||||
|
public static DateTime FirstDayOfMonth(this DateTime current) =>
|
||||||
|
current.AddDays(1 - current.Day);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a <see cref="DateTime"/> representing the last day in the current month.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="current">The current date.</param>
|
||||||
|
public static DateTime LastDayOfMonth(this DateTime current)
|
||||||
|
{
|
||||||
|
int daysInMonth = DateTime.DaysInMonth(current.Year, current.Month);
|
||||||
|
|
||||||
|
DateTime last = current.FirstDayOfMonth().AddDays(daysInMonth - 1);
|
||||||
|
return last;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a <see cref="DateTime"/> representing the last specified day in the current month.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="current">The current date.</param>
|
||||||
|
/// <param name="dayOfWeek">The current day of week.</param>
|
||||||
|
public static DateTime Last(this DateTime current, DayOfWeek dayOfWeek)
|
||||||
|
{
|
||||||
|
DateTime last = current.LastDayOfMonth();
|
||||||
|
|
||||||
|
last = last.AddDays(Math.Abs(dayOfWeek - last.DayOfWeek) * -1);
|
||||||
|
return last;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a <see cref="DateTime"/> representing midnight on the current date.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="current">The current date.</param>
|
||||||
|
public static DateTime Midnight(this DateTime current) =>
|
||||||
|
new DateTime(current.Year, current.Month, current.Day);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a <see cref="DateTime"/> representing the first date following the current date which falls on the
|
||||||
|
/// given day of the week.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="current">The current date.</param>
|
||||||
|
/// <param name="dayOfWeek">The day of week for the next date to get.</param>
|
||||||
|
public static DateTime Next(this DateTime current, DayOfWeek dayOfWeek)
|
||||||
|
{
|
||||||
|
int offsetDays = dayOfWeek - current.DayOfWeek;
|
||||||
|
|
||||||
|
if (offsetDays <= 0)
|
||||||
|
{
|
||||||
|
offsetDays += 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
DateTime result = current.AddDays(offsetDays);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a <see cref="DateTime"/> representing noon on the current date.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="current">The current date.</param>
|
||||||
|
public static DateTime Noon(this DateTime current) =>
|
||||||
|
new DateTime(current.Year, current.Month, current.Day, 12, 0, 0);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the time of the current date with minute precision.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="current">The current date.</param>
|
||||||
|
/// <param name="hour">The hour.</param>
|
||||||
|
/// <param name="minute">The minute.</param>
|
||||||
|
public static DateTime SetTime(this DateTime current, int hour, int minute) =>
|
||||||
|
current.SetTime(hour, minute, 0, 0);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the time of the current date with second precision.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="current">The current date</param>
|
||||||
|
/// <param name="hour">The hour.</param>
|
||||||
|
/// <param name="minute">The minute.</param>
|
||||||
|
/// <param name="second">The second.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static DateTime SetTime(this DateTime current, int hour, int minute, int second) =>
|
||||||
|
current.SetTime(hour, minute, second, 0);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the time of the current date with millisecond precision.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="current">The current date.</param>
|
||||||
|
/// <param name="hour">The hour.</param>
|
||||||
|
/// <param name="minute">The minute.</param>
|
||||||
|
/// <param name="second">The second.</param>
|
||||||
|
/// <param name="millisecond">The millisecond.</param>
|
||||||
|
public static DateTime SetTime(this DateTime current, int hour, int minute, int second, int millisecond) =>
|
||||||
|
new DateTime(current.Year, current.Month, current.Day, hour, minute, second, millisecond);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the <see cref="DateTime"/> to a Unix timestamp.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="time">The <see cref="DateTime"/> instance.</param>
|
||||||
|
/// <param name="useMillis">Optional. Whether or not the return value should be represented as milliseconds.
|
||||||
|
/// Defaults to <see langword="false"/>.</param>
|
||||||
|
/// <returns>Returns a Unix timestamp representing the provided <see cref="DateTime"/>.</returns>
|
||||||
|
public static long ToUnixTimeStamp(this DateTime time, bool useMillis = false)
|
||||||
|
{
|
||||||
|
TimeSpan difference = time - UnixEpoch;
|
||||||
|
return (long) (useMillis ? difference.TotalMilliseconds : difference.TotalSeconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the <see cref="DateTime"/> with the year set to the provided value.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="date">The <see cref="DateTime"/> to copy.</param>
|
||||||
|
/// <param name="year">The year to set.</param>
|
||||||
|
/// <returns>Returns a <see cref="DateTime"/>.</returns>
|
||||||
|
public static DateTime WithYear(this DateTime date, int year) =>
|
||||||
|
new DateTime(year, date.Month, date.Day, date.Hour, date.Minute, date.Second, date.Millisecond);
|
||||||
|
}
|
||||||
|
}
|
60
X10D/DoubleExtensions.cs
Normal file
60
X10D/DoubleExtensions.cs
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
namespace X10D
|
||||||
|
{
|
||||||
|
#region Using Directives
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Extension methods for <see cref="Double"/>.
|
||||||
|
/// </summary>
|
||||||
|
public static class DoubleExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Converts an angle from degrees to radians.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="angle">The angle in degrees.</param>
|
||||||
|
/// <returns>Returns <paramref name="angle"/> in radians.</returns>
|
||||||
|
public static double DegreesToRadians(this double angle) =>
|
||||||
|
Math.PI * angle / 180.0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the <see cref="Double"/> to a <see cref="DateTime"/> treating it as a Unix timestamp.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="timestamp">The timestamp.</param>
|
||||||
|
/// <param name="isMillis">Optional. Whether or not the input value should be treated as milliseconds. Defaults
|
||||||
|
/// to <see langword="false"/>.</param>
|
||||||
|
/// <returns>Returns a <see cref="DateTime"/> representing <paramref name="timestamp"/> seconds since the Unix
|
||||||
|
/// epoch.</returns>
|
||||||
|
public static DateTime FromUnixTimestamp(this double timestamp, bool isMillis = false) =>
|
||||||
|
isMillis
|
||||||
|
? DateTimeExtensions.UnixEpoch.AddMilliseconds(timestamp)
|
||||||
|
: DateTimeExtensions.UnixEpoch.AddSeconds(timestamp);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the <see cref="Double"/> to a <see cref="Byte"/>[].
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="number">The number to convert.</param>
|
||||||
|
/// <returns>Returns a <see cref="Byte"/>[].</returns>
|
||||||
|
public static byte[] GetBytes(this double number) =>
|
||||||
|
BitConverter.GetBytes(number);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts an angle from radians to degrees.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="angle">The angle in radians.</param>
|
||||||
|
/// <returns>Returns <paramref name="angle"/> in degrees.</returns>
|
||||||
|
public static double RadiansToDegrees(this double angle) =>
|
||||||
|
angle * (180.0 / Math.PI);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Rounds to the nearest value.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="v">The value to round.</param>
|
||||||
|
/// <param name="nearest">The nearest value.</param>
|
||||||
|
/// <returns>Returns the rounded value.</returns>
|
||||||
|
public static double Round(this double v, int nearest = 1) =>
|
||||||
|
Math.Round(v / nearest) * nearest;
|
||||||
|
}
|
||||||
|
}
|
92
X10D/Int16Extensions.cs
Normal file
92
X10D/Int16Extensions.cs
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
namespace X10D
|
||||||
|
{
|
||||||
|
#region Using Directives
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Extension methods for <see cref="Int16"/>.
|
||||||
|
/// </summary>
|
||||||
|
public static class Int16Extensions
|
||||||
|
{
|
||||||
|
#region TimeSpan Returns
|
||||||
|
// TODO change
|
||||||
|
|
||||||
|
public static TimeSpan Days(this ushort number) =>
|
||||||
|
TimeSpan.FromDays(number);
|
||||||
|
|
||||||
|
public static TimeSpan Hours(this ushort number) =>
|
||||||
|
TimeSpan.FromHours(number);
|
||||||
|
|
||||||
|
public static TimeSpan Milliseconds(this ushort number) =>
|
||||||
|
TimeSpan.FromSeconds(number);
|
||||||
|
|
||||||
|
public static TimeSpan Minutes(this ushort number) =>
|
||||||
|
TimeSpan.FromMinutes(number);
|
||||||
|
|
||||||
|
public static TimeSpan Seconds(this ushort number) =>
|
||||||
|
TimeSpan.FromSeconds(number);
|
||||||
|
|
||||||
|
public static TimeSpan Ticks(this ushort number) =>
|
||||||
|
TimeSpan.FromTicks(number);
|
||||||
|
|
||||||
|
public static TimeSpan Days(this short number) =>
|
||||||
|
TimeSpan.FromDays(number);
|
||||||
|
|
||||||
|
public static TimeSpan Hours(this short number) =>
|
||||||
|
TimeSpan.FromHours(number);
|
||||||
|
|
||||||
|
public static TimeSpan Milliseconds(this short number) =>
|
||||||
|
TimeSpan.FromSeconds(number);
|
||||||
|
|
||||||
|
public static TimeSpan Minutes(this short number) =>
|
||||||
|
TimeSpan.FromMinutes(number);
|
||||||
|
|
||||||
|
public static TimeSpan Seconds(this short number) =>
|
||||||
|
TimeSpan.FromSeconds(number);
|
||||||
|
|
||||||
|
public static TimeSpan Ticks(this short number) =>
|
||||||
|
TimeSpan.FromTicks(number);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the <see cref="Int16"/> to a <see cref="DateTime"/> treating it as a Unix timestamp.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="timestamp">The timestamp.</param>
|
||||||
|
/// <param name="isMillis">Optional. Whether or not the input value should be treated as milliseconds. Defaults
|
||||||
|
/// to <see langword="false"/>..</param>
|
||||||
|
/// <returns>Returns a <see cref="DateTime"/> representing <paramref name="timestamp"/> seconds since the Unix
|
||||||
|
/// epoch.</returns>
|
||||||
|
public static DateTime FromUnixTimestamp(this short timestamp, bool isMillis = false) =>
|
||||||
|
((long) timestamp).FromUnixTimestamp(isMillis);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the <see cref="UInt16"/> to a <see cref="Byte"/>[].
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="number">The number to convert.</param>
|
||||||
|
/// <returns>Returns a <see cref="Byte"/>[].</returns>
|
||||||
|
public static byte[] GetBytes(this ushort number) =>
|
||||||
|
BitConverter.GetBytes(number);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the <see cref="Int16"/> to a <see cref="Byte"/>[].
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="number">The number to convert.</param>
|
||||||
|
/// <returns>Returns a <see cref="Byte"/>[].</returns>
|
||||||
|
public static byte[] GetBytes(this short number) =>
|
||||||
|
BitConverter.GetBytes(number);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines if the <see cref="Int16"/> is a prime number.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="number">The number.</param>
|
||||||
|
/// <returns>Returns <see langword="true"/> if <paramref name="number"/> is prime, <see langword="false"/>
|
||||||
|
/// otherwise.</returns>
|
||||||
|
public static bool IsPrime(this short number) =>
|
||||||
|
((long) number).IsPrime();
|
||||||
|
}
|
||||||
|
}
|
91
X10D/Int32Extensions.cs
Normal file
91
X10D/Int32Extensions.cs
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
namespace X10D
|
||||||
|
{
|
||||||
|
#region Using Directives
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Extension methods for <see cref="Int32"/>.
|
||||||
|
/// </summary>
|
||||||
|
public static class Int32Extensions
|
||||||
|
{
|
||||||
|
#region TimeSpan Returns
|
||||||
|
// TODO change
|
||||||
|
|
||||||
|
public static TimeSpan Days(this uint number) =>
|
||||||
|
TimeSpan.FromDays(number);
|
||||||
|
|
||||||
|
public static TimeSpan Hours(this uint number) =>
|
||||||
|
TimeSpan.FromHours(number);
|
||||||
|
|
||||||
|
public static TimeSpan Milliseconds(this uint number) =>
|
||||||
|
TimeSpan.FromSeconds(number);
|
||||||
|
|
||||||
|
public static TimeSpan Minutes(this uint number) =>
|
||||||
|
TimeSpan.FromMinutes(number);
|
||||||
|
|
||||||
|
public static TimeSpan Seconds(this uint number) =>
|
||||||
|
TimeSpan.FromSeconds(number);
|
||||||
|
|
||||||
|
public static TimeSpan Ticks(this uint number) =>
|
||||||
|
TimeSpan.FromTicks(number);
|
||||||
|
|
||||||
|
public static TimeSpan Days(this int number) =>
|
||||||
|
TimeSpan.FromDays(number);
|
||||||
|
|
||||||
|
public static TimeSpan Hours(this int number) =>
|
||||||
|
TimeSpan.FromHours(number);
|
||||||
|
|
||||||
|
public static TimeSpan Milliseconds(this int number) =>
|
||||||
|
TimeSpan.FromSeconds(number);
|
||||||
|
|
||||||
|
public static TimeSpan Minutes(this int number) =>
|
||||||
|
TimeSpan.FromMinutes(number);
|
||||||
|
|
||||||
|
public static TimeSpan Seconds(this int number) =>
|
||||||
|
TimeSpan.FromSeconds(number);
|
||||||
|
|
||||||
|
public static TimeSpan Ticks(this int number) =>
|
||||||
|
TimeSpan.FromTicks(number);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the <see cref="Int32"/> to a <see cref="DateTime"/> treating it as a Unix timestamp.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="timestamp">The timestamp.</param>
|
||||||
|
/// <param name="isMillis">Optional. Whether or not the input value should be treated as milliseconds. Defaults
|
||||||
|
/// to <see langword="false"/>..</param>
|
||||||
|
/// <returns>Returns a <see cref="DateTime"/> representing <paramref name="timestamp"/> seconds since the Unix
|
||||||
|
/// epoch.</returns>
|
||||||
|
public static DateTime FromUnixTimestamp(this int timestamp, bool isMillis = false) =>
|
||||||
|
((long)timestamp).FromUnixTimestamp(isMillis);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the <see cref="UInt32"/> to a <see cref="Byte"/>[].
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="number">The number to convert.</param>
|
||||||
|
/// <returns>Returns a <see cref="Byte"/>[].</returns>
|
||||||
|
public static byte[] GetBytes(this uint number) =>
|
||||||
|
BitConverter.GetBytes(number);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the <see cref="Int32"/> to a <see cref="Byte"/>[].
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="number">The number to convert.</param>
|
||||||
|
/// <returns>Returns a <see cref="Byte"/>[].</returns>
|
||||||
|
public static byte[] GetBytes(this int number) =>
|
||||||
|
BitConverter.GetBytes(number);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines if the <see cref="Int32"/> is a prime number.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="number">The number.</param>
|
||||||
|
/// <returns>Returns <see langword="true"/> if <paramref name="number"/> is prime, <see langword="false"/>
|
||||||
|
/// otherwise.</returns>
|
||||||
|
public static bool IsPrime(this int number) =>
|
||||||
|
((long)number).IsPrime();
|
||||||
|
}
|
||||||
|
}
|
114
X10D/Int64Extensions.cs
Normal file
114
X10D/Int64Extensions.cs
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
namespace X10D
|
||||||
|
{
|
||||||
|
#region Using Directives
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Extension methods for <see cref="Int64"/>.
|
||||||
|
/// </summary>
|
||||||
|
public static class Int64Extensions
|
||||||
|
{
|
||||||
|
#region TimeSpan Returns
|
||||||
|
// TODO change
|
||||||
|
|
||||||
|
public static TimeSpan Days(this ulong number) =>
|
||||||
|
TimeSpan.FromDays(number);
|
||||||
|
|
||||||
|
public static TimeSpan Hours(this ulong number) =>
|
||||||
|
TimeSpan.FromHours(number);
|
||||||
|
|
||||||
|
public static TimeSpan Milliseconds(this ulong number) =>
|
||||||
|
TimeSpan.FromSeconds(number);
|
||||||
|
|
||||||
|
public static TimeSpan Minutes(this ulong number) =>
|
||||||
|
TimeSpan.FromMinutes(number);
|
||||||
|
|
||||||
|
public static TimeSpan Seconds(this ulong number) =>
|
||||||
|
TimeSpan.FromSeconds(number);
|
||||||
|
|
||||||
|
public static TimeSpan Days(this long number) =>
|
||||||
|
TimeSpan.FromDays(number);
|
||||||
|
|
||||||
|
public static TimeSpan Hours(this long number) =>
|
||||||
|
TimeSpan.FromHours(number);
|
||||||
|
|
||||||
|
public static TimeSpan Milliseconds(this long number) =>
|
||||||
|
TimeSpan.FromSeconds(number);
|
||||||
|
|
||||||
|
public static TimeSpan Minutes(this long number) =>
|
||||||
|
TimeSpan.FromMinutes(number);
|
||||||
|
|
||||||
|
public static TimeSpan Seconds(this long number) =>
|
||||||
|
TimeSpan.FromSeconds(number);
|
||||||
|
|
||||||
|
public static TimeSpan Ticks(this long number) =>
|
||||||
|
TimeSpan.FromTicks(number);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the <see cref="Int64"/> to a <see cref="DateTime"/> treating it as a Unix timestamp.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="timestamp">The timestamp.</param>
|
||||||
|
/// <param name="isMillis">Optional. Whether or not the input value should be treated as milliseconds. Defaults
|
||||||
|
/// to <see langword="false"/>.</param>
|
||||||
|
/// <returns>Returns a <see cref="DateTime"/> representing <paramref name="timestamp"/> seconds since the Unix
|
||||||
|
/// epoch.</returns>
|
||||||
|
public static DateTime FromUnixTimestamp(this long timestamp, bool isMillis = false) =>
|
||||||
|
((double)timestamp).FromUnixTimestamp(isMillis);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the <see cref="UInt64"/> to a <see cref="Byte"/>[].
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="number">The number to convert.</param>
|
||||||
|
/// <returns>Returns a <see cref="Byte"/>[].</returns>
|
||||||
|
public static byte[] GetBytes(this ulong number) =>
|
||||||
|
BitConverter.GetBytes(number);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the <see cref="Int64"/> to a <see cref="Byte"/>[].
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="number">The number to convert.</param>
|
||||||
|
/// <returns>Returns a <see cref="Byte"/>[].</returns>
|
||||||
|
public static byte[] GetBytes(this long number) =>
|
||||||
|
BitConverter.GetBytes(number);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines if the <see cref="Int64"/> is a prime number.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="number">The number.</param>
|
||||||
|
/// <returns>Returns <see langword="true"/> if <paramref name="number"/> is prime, <see langword="false"/>
|
||||||
|
/// otherwise.</returns>
|
||||||
|
public static bool IsPrime(this long number)
|
||||||
|
{
|
||||||
|
if (number <= 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (number == 2)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (number % 2 == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
long boundary = (long) Math.Floor(Math.Sqrt(number));
|
||||||
|
for (int i = 3; i <= boundary; i += 2)
|
||||||
|
{
|
||||||
|
if (number % i == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
54
X10D/ListExtensions.cs
Normal file
54
X10D/ListExtensions.cs
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
namespace X10D
|
||||||
|
{
|
||||||
|
#region Using Directives
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Extension methods for <see cref="IList{T}"/>.
|
||||||
|
/// </summary>
|
||||||
|
public static class ListExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a random element from <paramref name="source"/> using a new <see cref="Random"/> instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The collection type.</typeparam>
|
||||||
|
/// <param name="source">The collection to draw from.</param>
|
||||||
|
/// <returns>Returns a random element of type <see cref="T"/> from <paramref name="source"/>.</returns>
|
||||||
|
public static T OneOf<T>(this IEnumerable<T> source) =>
|
||||||
|
source.OneOf(new Random());
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a random element from <paramref name="source"/> using the <see cref="Random"/> instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The collection type.</typeparam>
|
||||||
|
/// <param name="source">The collection to draw from.</param>
|
||||||
|
/// <param name="random">The <see cref="Random"/> instance.</param>
|
||||||
|
/// <returns>Returns a random element of type <see cref="T"/> from <paramref name="source"/>.</returns>
|
||||||
|
public static T OneOf<T>(this IEnumerable<T> source, Random random) =>
|
||||||
|
source.ToList().OneOf(random);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a random element from <paramref name="source"/> using a new <see cref="Random"/> instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The collection type.</typeparam>
|
||||||
|
/// <param name="source">The collection to draw from.</param>
|
||||||
|
/// <returns>Returns a random element of type <see cref="T"/> from <paramref name="source"/>.</returns>
|
||||||
|
public static T OneOf<T>(this IList<T> source) =>
|
||||||
|
source.OneOf(new Random());
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a random element from <paramref name="source"/> using the <see cref="Random"/> instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The collection type.</typeparam>
|
||||||
|
/// <param name="source">The collection to draw from.</param>
|
||||||
|
/// <param name="random">The <see cref="Random"/> instance.</param>
|
||||||
|
/// <returns>Returns a random element of type <see cref="T"/> from <paramref name="source"/>.</returns>
|
||||||
|
public static T OneOf<T>(this IList<T> source, Random random) =>
|
||||||
|
random.OneOf(source);
|
||||||
|
}
|
||||||
|
}
|
35
X10D/Properties/AssemblyInfo.cs
Normal file
35
X10D/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("Extensions")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("Extensions")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("de210f83-fc9a-4c23-ac2c-7a060960f716")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
35
X10D/RandomExtensions.cs
Normal file
35
X10D/RandomExtensions.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
namespace X10D
|
||||||
|
{
|
||||||
|
#region Using Directives
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Extension methods for <see cref="Random"/>.
|
||||||
|
/// </summary>
|
||||||
|
public static class RandomExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a random element from <paramref name="source"/> using the <see cref="Random"/> instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The collection type.</typeparam>
|
||||||
|
/// <param name="random">The <see cref="Random"/> instance.</param>
|
||||||
|
/// <param name="source">The collection to draw from.</param>
|
||||||
|
/// <returns>Returns a random element of type <see cref="T"/> from <paramref name="source"/>.</returns>
|
||||||
|
public static T OneOf<T>(this Random random, params T[] source) =>
|
||||||
|
source[random.Next(source.Length)];
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a random element from <paramref name="source"/> using the <see cref="Random"/> instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The collection type.</typeparam>
|
||||||
|
/// <param name="random">The <see cref="Random"/> instance.</param>
|
||||||
|
/// <param name="source">The collection to draw from.</param>
|
||||||
|
/// <returns>Returns a random element of type <see cref="T"/> from <paramref name="source"/>.</returns>
|
||||||
|
public static T OneOf<T>(this Random random, IList<T> source) =>
|
||||||
|
source[random.Next(source.Count)];
|
||||||
|
}
|
||||||
|
}
|
58
X10D/SingleExtensions.cs
Normal file
58
X10D/SingleExtensions.cs
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
namespace X10D
|
||||||
|
{
|
||||||
|
#region Using Directives
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Extension methods for <see cref="Single"/>.
|
||||||
|
/// </summary>
|
||||||
|
public static class SingleExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Converts an angle from degrees to radians.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="angle">The angle in degrees.</param>
|
||||||
|
/// <returns>Returns <paramref name="angle"/> in radians.</returns>
|
||||||
|
public static float DegreesToRadians(this float angle) =>
|
||||||
|
(float)((double)angle).DegreesToRadians();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the <see cref="Single"/> to a <see cref="DateTime"/> treating it as a Unix timestamp.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="timestamp">The timestamp.</param>
|
||||||
|
/// <param name="isMillis">Optional. Whether or not the input value should be treated as milliseconds. Defaults
|
||||||
|
/// to <see langword="false"/>.</param>
|
||||||
|
/// <returns>Returns a <see cref="DateTime"/> representing <paramref name="timestamp"/> seconds since the Unix
|
||||||
|
/// epoch.</returns>
|
||||||
|
public static DateTime FromUnixTimestamp(this float timestamp, bool isMillis = false) =>
|
||||||
|
((double)timestamp).FromUnixTimestamp(isMillis);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the <see cref="Single"/> to a <see cref="Byte"/>[].
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="number">The number to convert.</param>
|
||||||
|
/// <returns>Returns a <see cref="Byte"/>[].</returns>
|
||||||
|
public static byte[] GetBytes(this float number) =>
|
||||||
|
BitConverter.GetBytes(number);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts an angle from radians to degrees.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="angle">The angle in radians.</param>
|
||||||
|
/// <returns>Returns <paramref name="angle"/> in degrees.</returns>
|
||||||
|
public static float RadiansToDegrees(this float angle) =>
|
||||||
|
(float)((double)angle).RadiansToDegrees();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Rounds to the nearest value.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="v">The value to round.</param>
|
||||||
|
/// <param name="nearest">The nearest value.</param>
|
||||||
|
/// <returns>Returns the rounded value.</returns>
|
||||||
|
public static float Round(this float v, int nearest = 1) =>
|
||||||
|
(float)((double)v).Round(nearest);
|
||||||
|
}
|
||||||
|
}
|
141
X10D/StringExtensions.cs
Normal file
141
X10D/StringExtensions.cs
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
namespace X10D
|
||||||
|
{
|
||||||
|
#region Using Directives
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
using System.Security;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Extension methods for <see cref="String"/>.
|
||||||
|
/// </summary>
|
||||||
|
public static class StringExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Decodes a base-64 encoded string.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">The base-64 string to decode.</param>
|
||||||
|
/// <returns>Returns the string in plain text.</returns>
|
||||||
|
public static string Base64Decode(this string data) =>
|
||||||
|
Convert.FromBase64String(data).GetString();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Encodes a base-64 encoded string.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">The plain text string to decode.</param>
|
||||||
|
/// <returns>Returns the string in plain text.</returns>
|
||||||
|
public static string Base64Encode(this string value) =>
|
||||||
|
Convert.ToBase64String(value.GetBytes());
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Parses a <see cref="String"/> into an <see cref="Enum"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The type of the Enum</typeparam>
|
||||||
|
/// <param name="value">String value to parse</param>
|
||||||
|
/// <returns>The Enum corresponding to the stringExtensions</returns>
|
||||||
|
public static T EnumParse<T>(this string value) =>
|
||||||
|
value.EnumParse<T>(false);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Parses a <see cref="String"/> into an <see cref="Enum"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The type of the Enum</typeparam>
|
||||||
|
/// <param name="value">String value to parse</param>
|
||||||
|
/// <param name="ignoreCase">Whether or not to ignore casing.</param>
|
||||||
|
/// <returns>The Enum corresponding to the stringExtensions</returns>
|
||||||
|
public static T EnumParse<T>(this string value, bool ignoreCase)
|
||||||
|
{
|
||||||
|
if (value == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
value = value.Trim();
|
||||||
|
|
||||||
|
if (value.Length == 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Must specify valid information for parsing in the string.",
|
||||||
|
nameof(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
Type t = typeof(T);
|
||||||
|
|
||||||
|
if (!t.IsEnum)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Type provided must be an Enum.", "T");
|
||||||
|
}
|
||||||
|
|
||||||
|
return (T) Enum.Parse(t, value, ignoreCase);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a <see cref="Byte"/>[] representing the value the <see cref="String"/> with
|
||||||
|
/// <see cref="Encoding.UTF8"/> encoding.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="str">The string to convert.</param>
|
||||||
|
/// <returns>Returns a <see cref="Byte"/>[].</returns>
|
||||||
|
public static byte[] GetBytes(this string str) =>
|
||||||
|
str.GetBytes(Encoding.UTF8);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a <see cref="Byte"/>[] representing the value the <see cref="String"/> with the provided encoding.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="str">The string to convert.</param>
|
||||||
|
/// <param name="encoding">The encoding to use.</param>
|
||||||
|
/// <returns>Returns a <see cref="Byte"/>[].</returns>
|
||||||
|
public static byte[] GetBytes(this string str, Encoding encoding) =>
|
||||||
|
encoding.GetBytes(str);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Repeats a string a specified number of times.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="str">The string to repeat.</param>
|
||||||
|
/// <param name="count">The repeat count.</param>
|
||||||
|
/// <returns>Returns a <see cref="String"/> whose value is <paramref name="str"/> repeated
|
||||||
|
/// <paramref name="count"/> times.</returns>
|
||||||
|
public static string Repeat(this string str, int count)
|
||||||
|
{
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
builder.Append(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder.ToString();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Converts a <see cref="String"/> to a <see cref="SecureString"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="str">The string to convert.</param>
|
||||||
|
/// <returns>Returns a <see cref="SecureString"/>.</returns>
|
||||||
|
public static SecureString ToSecureString(this string str)
|
||||||
|
{
|
||||||
|
if (String.IsNullOrWhiteSpace(str))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SecureString result = new SecureString();
|
||||||
|
foreach (char c in str)
|
||||||
|
{
|
||||||
|
result.AppendChar(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts a <see cref="SecureString"/> to a <see cref="String"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="str">The <see cref="SecureString"/> to convert.</param>
|
||||||
|
/// <returns>Returns a <see cref="String"/>.</returns>
|
||||||
|
public static string ToString(this SecureString str) =>
|
||||||
|
new NetworkCredential(String.Empty, str).Password;
|
||||||
|
}
|
||||||
|
}
|
38
X10D/StructExtensions.cs
Normal file
38
X10D/StructExtensions.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
namespace X10D
|
||||||
|
{
|
||||||
|
#region Using Directives
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A set of extension methods for <see langword="struct"/> types.
|
||||||
|
/// </summary>
|
||||||
|
public static class StructExtensions
|
||||||
|
{
|
||||||
|
public static T Next<T>(this T src, bool wrap = true) where T : struct
|
||||||
|
{
|
||||||
|
if (!typeof(T).IsEnum)
|
||||||
|
{
|
||||||
|
throw new ArgumentException($"Argument {typeof(T).FullName} is not an Enum");
|
||||||
|
}
|
||||||
|
|
||||||
|
T[] arr = (T[])Enum.GetValues(src.GetType());
|
||||||
|
int j = Array.IndexOf(arr, src) + 1;
|
||||||
|
return arr.Length == j ? arr[wrap ? 0 : j - 1] : arr[j];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static T Previous<T>(this T src, bool wrap = true) where T : struct
|
||||||
|
{
|
||||||
|
if (!typeof(T).IsEnum)
|
||||||
|
{
|
||||||
|
throw new ArgumentException($"Argument {typeof(T).FullName} is not an Enum");
|
||||||
|
}
|
||||||
|
|
||||||
|
T[] arr = (T[])Enum.GetValues(src.GetType());
|
||||||
|
int j = Array.IndexOf(arr, src) - 1;
|
||||||
|
return j < 0 ? arr[wrap ? arr.Length - 1 : 0] : arr[j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
24
X10D/TimeSpanExtensions.cs
Normal file
24
X10D/TimeSpanExtensions.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
namespace X10D
|
||||||
|
{
|
||||||
|
#region Using Directives
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Extension methods for <see cref="TimeSpan"/>.
|
||||||
|
/// </summary>
|
||||||
|
public static class TimeSpanExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Calculates how long ago a specified <see cref="TimeSpan"/> was.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="span">The <see cref="TimeSpan"/>.</param>
|
||||||
|
/// <param name="utc">Optional. Whether or not to use <see cref="DateTime.UtcNow"/> instead of <see cref="DateTime.Now"/>.
|
||||||
|
/// Defaults to <see langword="false"/>.</param>
|
||||||
|
/// <returns>Returns a <see cref="DateTime"/>.</returns>
|
||||||
|
public static DateTime Ago(this TimeSpan span, bool utc = false) =>
|
||||||
|
(utc ? DateTime.UtcNow : DateTime.Now) - span;
|
||||||
|
}
|
||||||
|
}
|
64
X10D/X10D.csproj
Normal file
64
X10D/X10D.csproj
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{DE210F83-FC9A-4C23-AC2C-7A060960F716}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>X10D</RootNamespace>
|
||||||
|
<AssemblyName>X10D</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<Deterministic>true</Deterministic>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<LangVersion>7.1</LangVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<LangVersion>7.1</LangVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="ByteExtensions.cs" />
|
||||||
|
<Compile Include="CharExtensions.cs" />
|
||||||
|
<Compile Include="ConvertibleExtensions.cs" />
|
||||||
|
<Compile Include="DateTimeExtensions.cs" />
|
||||||
|
<Compile Include="ComparableExtensions.cs" />
|
||||||
|
<Compile Include="SingleExtensions.cs" />
|
||||||
|
<Compile Include="DoubleExtensions.cs" />
|
||||||
|
<Compile Include="Int16Extensions.cs" />
|
||||||
|
<Compile Include="Int32Extensions.cs" />
|
||||||
|
<Compile Include="Int64Extensions.cs" />
|
||||||
|
<Compile Include="ListExtensions.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="RandomExtensions.cs" />
|
||||||
|
<Compile Include="StringExtensions.cs" />
|
||||||
|
<Compile Include="StructExtensions.cs" />
|
||||||
|
<Compile Include="TimeSpanExtensions.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
Loading…
Reference in New Issue
Block a user