コード例 #1
0
 internal virtual AttributeDefinition CreateDowncastAttributeDefinition(AssetType downcastAssetType)
 {
     throw new NotSupportedException($"Cannot downcast {Token} to {downcastAssetType.Token}");
 }
コード例 #2
0
 public AttributeDefinitionVisitor(AssetType rootAssetType, MetaModel metaModel)
 {
     _rootAssetType = rootAssetType;
     _metaModel     = metaModel;
 }
コード例 #3
0
 protected AttributeDefinition(AssetType assetType, string name, bool nullable, AssetType relatedAssetType, bool isMultiValue)
 {
     AssetType        = assetType;
     Token            = $"{assetType.Token}.{name}";
     Name             = name;
     IsNullable       = nullable;
     RelatedAssetType = relatedAssetType;
     IsMultiValue     = isMultiValue;
 }
コード例 #4
0
 public FilterVisitor(AssetType rootAssetType, MetaModel metaModel)
 {
     _rootAssetType = rootAssetType;
     _metaModel     = metaModel;
 }
コード例 #5
0
 public OrderVisitor(AssetType assetType, MetaModel metaModel)
 {
     _assetType = assetType;
     _metaModel = metaModel;
 }
コード例 #6
0
 public PrimitveAttributeDefinition(Type ownedType, PropertyInfo property, AssetType assetType, bool nullable)
     : base(assetType, property.Name, nullable, null, false)
 {
     _ownedType = ownedType;
     _property  = property;
 }
コード例 #7
0
ファイル: MetaModel.cs プロジェクト: donald-hanson/V1Antlr
        private AttributeDefinition CreateAttributeDefinition(Type type, PropertyInfo property, AssetType assetType)
        {
            var propertyType = property.PropertyType;

            string propertyDebugName = string.Format("{0} {1}.{2}", propertyType.ToShortTypeName(), type.ToShortTypeName(), property.Name);

            if (propertyType == typeof(string))
            {
                return(new PrimitveAttributeDefinition(type, property, assetType, true));
            }

            if (propertyType.IsSupportedPrimitiveType())
            {
                return(new PrimitveAttributeDefinition(type, property, assetType, false));
            }

            if (propertyType.Implements(typeof(ICollection <>)))
            {
                var innerType = propertyType.GetGenericArguments()[0];
                if (innerType.IsClass && innerType != typeof(string))
                {
                    AssetType relatedAssetType;
                    if (!_assetTypes.TryGetValue(innerType.Name, out relatedAssetType))
                    {
                        throw new NotImplementedException($"Could not reslve related asset type: {propertyDebugName}");
                    }
                    return(new MultiRelationAttributeDefinition(type, property, innerType, assetType, relatedAssetType));
                }

                throw new NotImplementedException($"Unsupported collection type: {propertyDebugName}");
            }

            if (propertyType.Implements(typeof(Nullable <>)))
            {
                var innerType = propertyType.GetGenericArguments()[0];
                if (innerType.IsSupportedPrimitiveType())
                {
                    return(new PrimitveAttributeDefinition(type, property, assetType, true));
                }

                throw new NotImplementedException($"Unsupported nullable type: {propertyDebugName}");
            }

            if (propertyType.IsClass)
            {
                AssetType relatedAssetType;
                if (!_assetTypes.TryGetValue(propertyType.Name, out relatedAssetType))
                {
                    throw new NotImplementedException($"Could not resolve related asset type: {propertyDebugName}");
                }
                return(new SingleRelationAttributeDefinition(type, property, assetType, true, relatedAssetType));
            }

            throw new NotImplementedException($"Unsupported property type: {propertyDebugName}");
        }
コード例 #8
0
ファイル: MetaModel.cs プロジェクト: donald-hanson/V1Antlr
        internal bool TryGetAttributeDefinition(AssetType assetType, string attributeNameToken, out AttributeDefinition attributeDefinition)
        {
            string key = $"{assetType.Token}.{attributeNameToken}";

            return(TryGetAttributeDefinition(key, out attributeDefinition));
        }
コード例 #9
0
ファイル: MetaModel.cs プロジェクト: donald-hanson/V1Antlr
 internal bool TryGetAssetType(string assetTypeToken, out AssetType assetType)
 {
     return(_assetTypes.TryGetValue(assetTypeToken, out assetType));
 }
コード例 #10
0
 public SingleRelationAttributeDefinition(Type ownedType, PropertyInfo property, AssetType assetType, bool nullable, AssetType relatedAssetType)
     : base(assetType, property.Name, nullable, relatedAssetType, false)
 {
     _ownedType = ownedType;
     _property  = property;
 }