c# Programming Glossary: typeof
What is a good pattern for using a Global Mutex in C#? http://stackoverflow.com/questions/229565/what-is-a-good-pattern-for-using-a-global-mutex-in-c Assembly.GetExecutingAssembly .GetCustomAttributes typeof GuidAttribute false .GetValue 0 .Value.ToString unique id for..
How to use reflection to call generic Method? http://stackoverflow.com/questions/232535/how-to-use-reflection-to-call-generic-method type arguments with MakeGenericMethod MethodInfo method typeof Sample .GetMethod GenericMethod MethodInfo generic method.MakeGenericMethod..
Deserialize JSON into C# dynamic object? http://stackoverflow.com/questions/3142495/deserialize-json-into-c-sharp-dynamic-object throw new ArgumentNullException dictionary return type typeof object new DynamicJsonObject dictionary null public override.. get return new ReadOnlyCollection Type new List Type new typeof object #region Nested type DynamicJsonObject private sealed.. dynamic obj serializer.Deserialize json typeof object So given a JSON string Items Name Apple Price 12.3 Name..
How to Deserialize XML document http://stackoverflow.com/questions/364253/how-to-deserialize-xml-document Namespace IsNullable false public class Cars XmlArrayItem typeof Car public Car Car get set . public class CarSerializer public.. cars.xml XmlSerializer serializer new XmlSerializer typeof Cars StreamReader reader new StreamReader path reader.ReadToEnd.. public class CarCollection XmlArray Cars XmlArrayItem Car typeof Car public Car Car get set The Deserialize function CarCollection..
Dynamic LINQ OrderBy on IEnumerable<T> http://stackoverflow.com/questions/41244/dynamic-linq-orderby-on-ienumerablet methodName string props property.Split '.' Type type typeof T ParameterExpression arg Expression.Parameter type x Expression.. expr pi type pi.PropertyType Type delegateType typeof Func .MakeGenericType typeof T type LambdaExpression lambda.. Type delegateType typeof Func .MakeGenericType typeof T type LambdaExpression lambda Expression.Lambda delegateType..
Retrieving Property name from lambda expression http://stackoverflow.com/questions/671968/retrieving-property-name-from-lambda-expression Expression Func TSource TProperty propertyLambda Type type typeof TSource MemberExpression member propertyLambda.Body as MemberExpression..
Deep cloning objects in C# http://stackoverflow.com/questions/78536/deep-cloning-objects-in-c-sharp object. returns public static T Clone T T source if typeof T .IsSerializable throw new ArgumentException The type must..
Create Generic method constraining T to an Enum http://stackoverflow.com/questions/79126/create-generic-method-constraining-t-to-an-enum value return defaultValue foreach T item in Enum.GetValues typeof T if item.ToString .ToLower .Equals value.Trim .ToLower return.. value T defaultValue where T struct IConvertible if typeof T .IsEnum throw new ArgumentException T must be an enumerated.. value return defaultValue foreach T item in Enum.GetValues typeof T if item.ToString .ToLower .Equals value.Trim .ToLower return..
|