internal ProjectionStructureType(Type type, ProjectionFactory factory) : base(type, TypeKind.Structure, factory) { // Ensure base types exist before self // - Safe because no type can have itself as a base (i.e. no cycles) // - Causes inits to be called in order from more-base to more-derived int basePropertyCount; baseTypes = CollectBaseTypes(type, out basePropertyCount); // Register self // - Required before creating metaobjects that can refer back to this type factory.RegisterProjectionType(this); // Create members after registration // - Members can be of any type and thus can form cycles properties = CollectProperties(type, basePropertyCount); }
private static void CollectInheritedProperties(ProjectionTypeCollection baseTypes, ProjectionPropertyCollection collection) { foreach (var baseType in baseTypes) foreach (var property in baseType.Properties) collection.Add(property, false); }
private static ProjectionTypeCollection CollectBaseTypesCore( HashSet<ProjectionType> baseTypes, out int propertyCount) { var collection = new ProjectionTypeCollection(baseTypes.Count); var count = 0; foreach (var baseType in baseTypes) { count += baseType.Properties.Count; collection.Add(baseType); } propertyCount = count; return collection; }