コード例 #1
0
        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);
        }
コード例 #2
0
        internal virtual IDictionary <string, ReflectionsUtils.GetDelegate> GetterValueFactory(Type type)
        {
            IDictionary <string, ReflectionsUtils.GetDelegate> dictionary = new Dictionary <string, ReflectionsUtils.GetDelegate>();

            foreach (PropertyInfo current in ReflectionsUtils.GetProperties(type))
            {
                if (current.CanRead && current.CanWrite)
                {
                    MethodInfo getterMethodInfo = ReflectionsUtils.GetGetterMethodInfo(current);
                    if (!getterMethodInfo.IsStatic && getterMethodInfo.IsPublic)
                    {
                        dictionary[this.MapClrMemberNameToJsonFieldName(current.Name)] = ReflectionsUtils.GetGetMethod(current);
                    }
                }
            }
            foreach (FieldInfo current2 in ReflectionsUtils.GetFields(type))
            {
                if (!current2.IsStatic && current2.IsPublic)
                {
                    dictionary[this.MapClrMemberNameToJsonFieldName(current2.Name)] = ReflectionsUtils.GetGetMethod(current2);
                }
            }
            return(dictionary);
        }