FastMember.TypeAccessor.GetMembers C# (CSharp) Method

GetMembers() public method

Query the members available for this type
public GetMembers ( ) : MemberSet
return MemberSet
        public virtual MemberSet GetMembers() { throw new NotSupportedException(); }

Usage Example

        public Wrapper(object value)
        {
            _value   = value;
            Accessor = TypeAccessor.Create(value.GetType());

            var atts = value.GetType().GetProperties().SelectMany(p => p.CustomAttributes).SelectMany(g => g.NamedArguments).Where(c => c.MemberName == "Name")
                       .Select(v => v.TypedValue.Value.ToString());

            Map = value.GetType().GetProperties()
                  .Select(x => new
            {
                Name = x.Name, Att = x.CustomAttributes.SelectMany(v => v.NamedArguments).Where(c => c.MemberName == "Name").Select(v => v.TypedValue.Value.ToString()).FirstOrDefault()
            })
                  .ToDictionary(key => key.Name, val => val.Att ?? val.Name);

            if (!Map.ContainsKey("@id"))
            {
                Map.Add("@id", "@id");
            }

            if (!Map.ContainsKey("@context"))
            {
                Map.Add("@context", "@context");
            }

            if (!Map.ContainsKey("@type"))
            {
                Map.Add("@type", "@type");
            }

//            Map = Map.Concat(GetType().GetProperties()
//                .Select(x => new
//                {
//                    Name = x.Name, Att = x.CustomAttributes.SelectMany(v => v.NamedArguments).Where(c => c.MemberName == "Name").Select(v => v.TypedValue.Value.ToString()).FirstOrDefault()
//                })
//                .ToDictionary(key => key.Name, val => val.Att ?? val.Name)).ToDictionary(x => x.Key, x => x.Value);


            var others = value.GetType().GetProperties().Where(x => x.CustomAttributes.All(y => y.AttributeType != typeof(DataMemberAttribute))).Select(c => c.Name);

            var thisatts = GetType().GetProperties().SelectMany(p => p.CustomAttributes).SelectMany(g => g.NamedArguments).Where(c => c.MemberName == "Name")
                           .Select(v => v.TypedValue.Value.ToString());

            MemberNames = atts.Concat(others).Concat(thisatts).ToArray();

            MemberNames = Accessor.GetMembers().Select(a => a.Name).Concat(GetType().GetProperties().Select(p => p.Name)).ToArray();

            MemberNames = Map.Values.Select(x => x).ToArray();
        }