private static Dictionary <Type, Dictionary <ExpressMetaProperty, ProcessingType> > GetProcessingInstructions(ExpressMetaData metaData, bool includeGeometry, bool includeSiteGeometry) { var productType = GetImplementation <IIfcProduct>(metaData); var types = metaData.Types() .Where(t => !t.Type.IsAbstract && !ignoreNamespaces.Any(ns => t.Type.Namespace.EndsWith(ns))) .ToList(); var result = new Dictionary <Type, Dictionary <ExpressMetaProperty, ProcessingType> >(); foreach (var type in types) { var instructions = new Dictionary <ExpressMetaProperty, ProcessingType>(type.Properties.Count); foreach (var propertyKvp in type.Properties) { var propIdx = propertyKvp.Key - 1; var property = propertyKvp.Value; // single instance if (property.EnumerableType == null) { var propType = property.PropertyInfo.PropertyType; if (propType.IsValueType || propType == typeof(string)) { instructions.Add(property, ProcessingType.Pass); continue; } if (propType.IsAssignableFrom(productType) || productType.IsAssignableFrom(propType)) { instructions.Add(property, ProcessingType.Entity); continue; } //if geometry is to be included don't filter anything else out if (includeGeometry && (!(typeof(IIfcSite).IsAssignableFrom(type.Type)) || includeSiteGeometry)) { instructions.Add(property, ProcessingType.Pass); continue; } //leave out geometry and placement of products if (typeof(IIfcProduct).IsAssignableFrom(type.Type) && (property.PropertyInfo.Name == "Representation" || property.PropertyInfo.Name == "ObjectPlacement") ) { instructions.Add(property, ProcessingType.Remove); continue; } //leave out representation maps if (typeof(IIfcTypeProduct).IsAssignableFrom(type.Type) && property.PropertyInfo.Name == "RepresentationMaps") { instructions.Add(property, ProcessingType.Remove); continue; } //leave out eventual connection geometry if (typeof(IIfcRelSpaceBoundary).IsAssignableFrom(type.Type) && property.PropertyInfo.Name == "ConnectionGeometry") { instructions.Add(property, ProcessingType.Remove); continue; } instructions.Add(property, ProcessingType.Pass); continue; } // item set var genType = property.EnumerableType; if (genType.IsValueType || genType == typeof(string)) { instructions.Add(property, ProcessingType.Pass); continue; } if (genType.IsAssignableFrom(productType) || productType.IsAssignableFrom(genType)) { instructions.Add(property, ProcessingType.List); continue; } instructions.Add(property, ProcessingType.Pass); continue; } result.Add(type.Type, instructions); } return(result); }
private static HashSet <Type> GetIgnoredTypes(ExpressMetaData metaData) { var types = metaData.Types().Where(t => !t.Type.IsAbstract && ignoreNamespaces.Any(ns => t.Type.Namespace.EndsWith(ns))).Select(t => t.Type); return(new HashSet <Type>(types)); }