public ReadOnlyCollection <IPropertyBase> GetAllProperties(bool includeInheritance) { if (!includeInheritance) { return(base.GetAllProperties(false)); } var inheritanceTree = InheritanceTreeCache.Get(this); var distinctByName = new IdentityProjectionEqualityComparer <IPropertyBase, string>(property => property.Name); var inheritanceList = inheritanceTree.GetFlatList(InheritanceListMode.WholeTree).Select(node => node.Interface); var result = (from item in inheritanceList select item.AllProperties).SelectMany(list => list).Distinct(distinctByName); return(new ReadOnlyCollection <IPropertyBase>(result.ToList())); }
public override ReadOnlyCollection <IPropertyBase> GetAllProperties(bool includeInheritance) { if (!includeInheritance) { return(base.GetAllProperties(false)); } var inheritanceTree = InheritanceTreeCache.Get(this); var distinctByName = new IdentityProjectionEqualityComparer <IPropertyBase, string>(property => property.Name); var flatList = inheritanceTree.GetFlatList(InheritanceListMode.WholeTree); var inheritanceList = flatList.Reverse().Select((node, i) => new { pos = i, @interface = node.Interface }); var allProps = (from item in inheritanceList orderby item.pos select [email protected]).SelectMany(list => list).Concat(this.AllProperties); var result = allProps.Distinct(distinctByName).ToList(); return(new ReadOnlyCollection <IPropertyBase>(result)); }