Example #1
0
        internal MemberSet(Type type)
        {
            const BindingFlags PublicInstance = BindingFlags.Public | BindingFlags.Instance;

#if NET20
            RefList <MemberInfo> properties = new RefList <MemberInfo>(type.GetProperties(PublicInstance));
            properties.AddRange(new RefList <MemberInfo>(type.GetFields(PublicInstance)));
            properties.Sort((p1, p2) => p1.Name.CompareTo(p2.Name));
            members = properties.ConvertAll <Member>(mi => new Member(mi)).ToArray();
#else
            members = type.GetProperties(PublicInstance).Cast <MemberInfo>()
                      .Concat(type.GetFields(PublicInstance).Cast <MemberInfo>())
                      .OrderBy(x => Marshal.OffsetOf(type, x.Name).ToInt32())
                      .Select(member => new Member(member)).ToArray();
#endif
        }