This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Windows.Data; | |
using System.Windows.Controls; | |
using System.Windows; | |
namespace Infrastructure.Extensions | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Type[] GetTypes(this Assembly assembly, bool ignoreReflectionTypeloadException) | |
{ | |
if(ignoreReflectionTypeloadException) | |
{ | |
Type[] types; | |
try | |
{ | |
types = assembly.GetTypes(); | |
} | |
catch (ReflectionTypeLoadException ex) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static readonly Vector ANGLE_BASE_VECTOR = new Vector(1, 0); | |
/// <summary> | |
/// ベクトルの角度をDegreeで返します | |
/// </summary> | |
/// <param name="vector">ベクトル</param> | |
/// <returns>角度(Degree値)</returns> | |
public static double GetAngle(this Vector vector) | |
{ | |
return Vector.AngleBetween(ANGLE_BASE_VECTOR, vector); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IEnumerable<int> BucketSort(IEnumerable<int> input) | |
{ | |
int[] bucket = new int[input.Max() + 1]; | |
foreach(var ele in input) | |
{ | |
bucket[ele]++; | |
} | |
return bucket.SelectMany((i, ele) => Enumerable.Range(0, i).Select(_ => ele)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static IEnumerable<Control> EnumurateAllControl(Control root) | |
{ | |
yield return root; | |
foreach (var ctrl in root.Controls.Cast<Control>().SelectMany(c => EnumurateAllControl(c))) | |
{ | |
yield return ctrl; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static IEnumerable<System.Windows.DependencyObject> EnumurateAllElement(System.Windows.DependencyObject root) | |
{ | |
yield return root; | |
foreach (var element in GetChilren(root).SelectMany(ele => EnumurateAllElement(ele))) | |
{ | |
yield return element; | |
} | |
} | |
static IEnumerable<System.Windows.DependencyObject> GetChilren(System.Windows.DependencyObject root) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Console.Write( | |
string.Concat( | |
Enumerable.Range(1,100).SelectMany(ele => ele.ToString() + System.Environment.NewLine)) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int x = 100; | |
while((x & 255) != 0) | |
{ | |
x += ((x & 255) << 8); | |
x--; | |
} | |
Console.WriteLine(x >> 8); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let rec qSort (x : List<'a>) = | |
if x.Length <= 1 then x | |
else | |
let parted = x.Tail |> List.partition (fun i -> i < x.Head) | |
List.append (fst parted |> qSort) (x.Head::(snd parted |> qSort)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Controlに対してスレッドセーフにActionを実行する | |
/// </summary> | |
/// <param name="control">対象コントロール</param> | |
/// <param name="action">Controlに対してスレッドセーフに実行したいAction</param> | |
public static void InvokeThreadSafely(this Control control, Action action) | |
{ | |
if (control.InvokeRequired) | |
{ | |
var asyncResult = control.BeginInvoke(action); |
OlderNewer