Esempio n. 1
0
        protected virtual List <MemberInfo> GetSerializableMembers(Type objectType)
        {
            bool serializableAttribute = this.IgnoreSerializableAttribute;
            MemberSerialization memberSerialization = JsonTypeReflector.GetObjectMemberSerialization(objectType, serializableAttribute);
            List <MemberInfo>   list1 = Enumerable.ToList <MemberInfo>(Enumerable.Where <MemberInfo>((IEnumerable <MemberInfo>)ReflectionUtils.GetFieldsAndProperties(objectType, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), (Func <MemberInfo, bool>)(m => !ReflectionUtils.IsIndexedProperty(m))));
            List <MemberInfo>   list2 = new List <MemberInfo>();

            if (memberSerialization != MemberSerialization.Fields)
            {
                List <MemberInfo> list3 = Enumerable.ToList <MemberInfo>(Enumerable.Where <MemberInfo>((IEnumerable <MemberInfo>)ReflectionUtils.GetFieldsAndProperties(objectType, this.DefaultMembersSearchFlags), (Func <MemberInfo, bool>)(m => !ReflectionUtils.IsIndexedProperty(m))));
                foreach (MemberInfo memberInfo in list1)
                {
                    if (this.SerializeCompilerGeneratedMembers || !memberInfo.IsDefined(typeof(CompilerGeneratedAttribute), true))
                    {
                        if (list3.Contains(memberInfo))
                        {
                            list2.Add(memberInfo);
                        }
                        else if (JsonTypeReflector.GetAttribute <JsonPropertyAttribute>(ReflectionUtils.GetCustomAttributeProvider((object)memberInfo)) != null)
                        {
                            list2.Add(memberInfo);
                        }
                        else if (memberSerialization == MemberSerialization.Fields && TypeExtensions.MemberType(memberInfo) == MemberTypes.Field)
                        {
                            list2.Add(memberInfo);
                        }
                    }
                }
            }
            else
            {
                foreach (MemberInfo memberInfo in list1)
                {
                    if (TypeExtensions.MemberType(memberInfo) == MemberTypes.Field)
                    {
                        list2.Add(memberInfo);
                    }
                }
            }
            return(list2);
        }