Ejemplo n.º 1
0
 internal virtual AttributeDefinition CreateDowncastAttributeDefinition(AssetType downcastAssetType)
 {
     throw new NotSupportedException($"Cannot downcast {Token} to {downcastAssetType.Token}");
 }
Ejemplo n.º 2
0
 public AttributeDefinitionVisitor(AssetType rootAssetType, MetaModel metaModel)
 {
     _rootAssetType = rootAssetType;
     _metaModel     = metaModel;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 4
0
 public FilterVisitor(AssetType rootAssetType, MetaModel metaModel)
 {
     _rootAssetType = rootAssetType;
     _metaModel     = metaModel;
 }
Ejemplo n.º 5
0
 public OrderVisitor(AssetType assetType, MetaModel metaModel)
 {
     _assetType = assetType;
     _metaModel = metaModel;
 }
 public PrimitveAttributeDefinition(Type ownedType, PropertyInfo property, AssetType assetType, bool nullable)
     : base(assetType, property.Name, nullable, null, false)
 {
     _ownedType = ownedType;
     _property  = property;
 }
Ejemplo n.º 7
0
        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}");
        }
Ejemplo n.º 8
0
        internal bool TryGetAttributeDefinition(AssetType assetType, string attributeNameToken, out AttributeDefinition attributeDefinition)
        {
            string key = $"{assetType.Token}.{attributeNameToken}";

            return(TryGetAttributeDefinition(key, out attributeDefinition));
        }
Ejemplo n.º 9
0
 internal bool TryGetAssetType(string assetTypeToken, out AssetType assetType)
 {
     return(_assetTypes.TryGetValue(assetTypeToken, out assetType));
 }
Ejemplo n.º 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;
 }