public static ReflectionsUtils.SetDelegate GetSetMethodByReflection(PropertyInfo propertyInfo) { MethodInfo methodInfo = ReflectionsUtils.GetSetterMethodInfo(propertyInfo); return(delegate(object source, object value) { methodInfo.Invoke(source, new object[] { value }); }); }
internal virtual IDictionary <string, KeyValuePair <Type, ReflectionsUtils.SetDelegate> > SetterValueFactory(Type type) { IDictionary <string, KeyValuePair <Type, ReflectionsUtils.SetDelegate> > dictionary = new Dictionary <string, KeyValuePair <Type, ReflectionsUtils.SetDelegate> >(); foreach (PropertyInfo current in ReflectionsUtils.GetProperties(type)) { if (current.CanWrite) { MethodInfo setterMethodInfo = ReflectionsUtils.GetSetterMethodInfo(current); if (!setterMethodInfo.IsStatic && setterMethodInfo.IsPublic) { dictionary[this.MapClrMemberNameToJsonFieldName(current.Name)] = new KeyValuePair <Type, ReflectionsUtils.SetDelegate>(current.PropertyType, ReflectionsUtils.GetSetMethod(current)); } } } foreach (FieldInfo current2 in ReflectionsUtils.GetFields(type)) { if (!current2.IsInitOnly && !current2.IsStatic && current2.IsPublic) { dictionary[this.MapClrMemberNameToJsonFieldName(current2.Name)] = new KeyValuePair <Type, ReflectionsUtils.SetDelegate>(current2.FieldType, ReflectionsUtils.GetSetMethod(current2)); } } return(dictionary); }