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(); } }
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(); }
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()); }
public JsonAttribute(JsonSlots slots, JsonShape shape) : this() { Shape = shape; Slots = slots; }
public JsonAttribute(JsonSlots slots) : this() { Slots = slots; }
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(); } }