c# Programming Glossary: propname
Get property value from string using reflection in C# http://stackoverflow.com/questions/1196991/get-property-value-from-string-using-reflection-in-c-sharp public static object GetPropValue object src string propName return src.GetType .GetProperty propName .GetValue src null.. object src string propName return src.GetType .GetProperty propName .GetValue src null Of course you will want to add validation..
Get an IDataReader from a typed List http://stackoverflow.com/questions/2258310/get-an-idatareader-from-a-typed-list summary typeparam name T typeparam param name propName param returns returns public static Func T CreateGetPropValue.. returns public static Func T CreateGetPropValue T string propName var param Expression.Parameter typeof object container var.. Expression.Convert param typeof T propName typeof object param return Func T func.Compile share improve..
Extending a solution for simple binding to a 'Text property to multiple Controls to handle binding to any Type? http://stackoverflow.com/questions/2391828/extending-a-solution-for-simple-binding-to-a-text-property-to-multiple-controls a property preferably via TypeDescriptor.GetProperties obj propName giving you an abstraction PropertyDescriptor asking the property..
workarounds for nameof() operator in C#: typesafe databinding http://stackoverflow.com/questions/301809/workarounds-for-nameof-operator-in-c-typesafe-databinding basically does that class Program static void Main var propName Nameof SampleClass .Property e e.Name Console.WriteLine propName.. Nameof SampleClass .Property e e.Name Console.WriteLine propName public class Nameof T public static string Property TProp Expression..
How can I read the properties of a C# class dynamically? http://stackoverflow.com/questions/4629/how-can-i-read-the-properties-of-a-c-sharp-class-dynamically use that object to manipulate a particular object. String propName Text PropertyInfo pi someObject.GetType .GetProperty propName.. Text PropertyInfo pi someObject.GetType .GetProperty propName pi.SetValue someObject New Value new Object 0 Link PropertyInfo.SetValue..
Reflection - get attribute name and value on property http://stackoverflow.com/questions/6637679/reflection-get-attribute-name-and-value-on-property attr as AuthorAttribute if authAttr null string propName prop.Name string auth authAttr.Name _dict.Add propName auth..
Implementing Audit Log / Change History with MVC & Entity Framework http://stackoverflow.com/questions/6867459/implementing-audit-log-change-history-with-mvc-entity-framework entry .CurrentValues foreach var propName in modifiedProps var newValue currentValues propName log.. var propName in modifiedProps var newValue currentValues propName log changes return base.SaveChanges return base.SaveChanges.. entry.EntityKey .CurrentValues foreach var propName in modifiedProps var newValue currentValues propName log..
|