Пример #1
0
        public FieldBuilder CreateField(SchemaBuilder schemaBuilder,
                                        PropertyInfo propertyInfo)
        {
            FieldBuilder fieldBuilder;

            var genericKeyType   = propertyInfo.PropertyType.GetGenericArguments()[0];
            var genericValueType = propertyInfo.PropertyType.GetGenericArguments()[1];

            if (genericValueType.GetInterface("IRevitEntity") != null)
            {
                fieldBuilder =
                    schemaBuilder.AddMapField(propertyInfo.Name,
                                              genericKeyType, typeof(Entity));

                AttributeExtractor <SchemaAttribute> schemaAttributeExtractor =
                    new AttributeExtractor <SchemaAttribute>();
                var subSchemaAttribute =
                    schemaAttributeExtractor
                    .GetAttribute(genericValueType);
                fieldBuilder
                .SetSubSchemaGUID(subSchemaAttribute.GUID);
            }
            else
            {
                fieldBuilder =
                    schemaBuilder.AddMapField(propertyInfo.Name,
                                              genericKeyType, genericValueType);
            }

            var needSubschemaId = fieldBuilder.NeedsSubSchemaGUID();

            return(fieldBuilder);
        }
Пример #2
0
        public FieldBuilder CreateField(SchemaBuilder schemaBuilder, PropertyInfo propertyInfo)
        {
            FieldBuilder fieldBuilder;

            var iRevitEntity = propertyInfo.PropertyType.GetInterface("IRevitEntity");

            if (iRevitEntity != null)
            {
                AttributeExtractor <SchemaAttribute> schemaAttributeExtractor =
                    new AttributeExtractor <SchemaAttribute>();

                fieldBuilder = schemaBuilder
                               .AddSimpleField(propertyInfo.Name, typeof(Entity));
                var subSchemaAttribute =
                    schemaAttributeExtractor
                    .GetAttribute(propertyInfo.PropertyType);
                fieldBuilder
                .SetSubSchemaGUID(subSchemaAttribute.GUID);
            }
            else
            {
                fieldBuilder =
                    schemaBuilder.AddSimpleField(propertyInfo.Name, propertyInfo.PropertyType);
            }

            return(fieldBuilder);
        }
Пример #3
0
        public FieldBuilder CreateField(SchemaBuilder schemaBuilder,
                                        PropertyInfo propertyInfo)
        {
            FieldBuilder fieldBuilder;

            // Check whether generic type is subentity or not
            var genericType = propertyInfo.PropertyType.GetGenericArguments()[0];

            var iRevitEntity = genericType.GetInterface("IRevitEntity");

            if (iRevitEntity != null)
            {
                fieldBuilder =
                    schemaBuilder.AddArrayField(propertyInfo.Name, typeof(Entity));

                AttributeExtractor <SchemaAttribute> schemaAttributeExtractor =
                    new AttributeExtractor <SchemaAttribute>();
                var subSchemaAttribute =
                    schemaAttributeExtractor
                    .GetAttribute(genericType);
                fieldBuilder
                .SetSubSchemaGUID(subSchemaAttribute.GUID);
            }
            else
            {
                fieldBuilder =
                    schemaBuilder.AddArrayField(propertyInfo.Name, genericType);
            }
            return(fieldBuilder);
        }