Ejemplo n.º 1
0
 private static ReadOnlyCollection<MemberInfo> JsonSlotsForThisVeryT(this Type t, JsonSlots options)
 {
     if (options == Annotations.JsonSlots.None)
     {
         return Seq.Empty<MemberInfo>().ToReadOnly();
     }
     else if (options == Annotations.JsonSlots.OptOutPublic)
     {
         return t.GetProperties(BF.PublicInstance | BF.DeclOnly).Where(pi => !pi.HasAttr<JsonExcludeAttribute>() && pi.GetIndexParameters().IsEmpty()).Cast<MemberInfo>().ToReadOnly();
     }
     else if (options == Annotations.JsonSlots.OptOutNonPublic)
     {
         return t.GetProperties(BF.AllInstance | BF.DeclOnly).Where(pi => !pi.HasAttr<JsonExcludeAttribute>() && pi.GetIndexParameters().IsEmpty()).Cast<MemberInfo>().ToReadOnly();
     }
     else if (options == Annotations.JsonSlots.OptInPublic)
     {
         return t.GetProperties(BF.PublicInstance | BF.DeclOnly).Where(pi => pi.HasAttr<JsonIncludeAttribute>() && pi.GetIndexParameters().IsEmpty()).Cast<MemberInfo>().ToReadOnly();
     }
     else if (options == Annotations.JsonSlots.OptInNonPublic)
     {
         return t.GetProperties(BF.AllInstance | BF.DeclOnly).Where(pi => pi.HasAttr<JsonIncludeAttribute>() && pi.GetIndexParameters().IsEmpty()).Cast<MemberInfo>().ToReadOnly();
     }
     else
     {
         throw AssertionHelper.Fail();
     }
 }
Ejemplo n.º 2
0
        public static ReadOnlyCollection<MemberInfo> JsonSlots(this Type root, JsonSlots options)
        {
            if (root == null) return null;

            var slots = new List<MemberInfo>();
            root.Hierarchy().ForEach(t =>
            {
                var t_slots = t.JsonSlotsForThisVeryT(options);
                t_slots = t_slots.Where(s_t => slots.None(s => s.Overrides(s_t))).ToReadOnly();
                slots.AddElements(t_slots);
            });

            return slots.Distinct().ToReadOnly();
        }
Ejemplo n.º 3
0
        public static ReadOnlyCollection <MemberInfo> JsonSlots(this Type root, JsonSlots options)
        {
            if (root == null)
            {
                return(null);
            }

            var slots = new List <MemberInfo>();

            root.Hierarchy().ForEach(t =>
            {
                var t_slots = t.JsonSlotsForThisVeryT(options);
                t_slots     = t_slots.Where(s_t => slots.None(s => s.Overrides(s_t))).ToReadOnly();
                slots.AddElements(t_slots);
            });

            return(slots.Distinct().ToReadOnly());
        }
Ejemplo n.º 4
0
 public JsonAttribute(JsonSlots slots, JsonShape shape)
     : this()
 {
     Shape = shape;
     Slots = slots;
 }
Ejemplo n.º 5
0
 public JsonAttribute(JsonSlots slots)
     : this()
 {
     Slots = slots;
 }
Ejemplo n.º 6
0
 public JsonAttribute(JsonSlots slots, JsonShape shape)
     : this()
 {
     Shape = shape;
     Slots = slots;
 }
Ejemplo n.º 7
0
 public JsonAttribute(JsonSlots slots)
     : this()
 {
     Slots = slots;
 }
Ejemplo n.º 8
0
 private static ReadOnlyCollection <MemberInfo> JsonSlotsForThisVeryT(this Type t, JsonSlots options)
 {
     if (options == Annotations.JsonSlots.None)
     {
         return(Seq.Empty <MemberInfo>().ToReadOnly());
     }
     else if (options == Annotations.JsonSlots.OptOutPublic)
     {
         return(t.GetProperties(BF.PublicInstance | BF.DeclOnly).Where(pi => !pi.HasAttr <JsonExcludeAttribute>() && pi.GetIndexParameters().IsEmpty()).Cast <MemberInfo>().ToReadOnly());
     }
     else if (options == Annotations.JsonSlots.OptOutNonPublic)
     {
         return(t.GetProperties(BF.AllInstance | BF.DeclOnly).Where(pi => !pi.HasAttr <JsonExcludeAttribute>() && pi.GetIndexParameters().IsEmpty()).Cast <MemberInfo>().ToReadOnly());
     }
     else if (options == Annotations.JsonSlots.OptInPublic)
     {
         return(t.GetProperties(BF.PublicInstance | BF.DeclOnly).Where(pi => pi.HasAttr <JsonIncludeAttribute>() && pi.GetIndexParameters().IsEmpty()).Cast <MemberInfo>().ToReadOnly());
     }
     else if (options == Annotations.JsonSlots.OptInNonPublic)
     {
         return(t.GetProperties(BF.AllInstance | BF.DeclOnly).Where(pi => pi.HasAttr <JsonIncludeAttribute>() && pi.GetIndexParameters().IsEmpty()).Cast <MemberInfo>().ToReadOnly());
     }
     else
     {
         throw AssertionHelper.Fail();
     }
 }