internal virtual AttributeDefinition CreateDowncastAttributeDefinition(AssetType downcastAssetType) { throw new NotSupportedException($"Cannot downcast {Token} to {downcastAssetType.Token}"); }
public AttributeDefinitionVisitor(AssetType rootAssetType, MetaModel metaModel) { _rootAssetType = rootAssetType; _metaModel = metaModel; }
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; }
public FilterVisitor(AssetType rootAssetType, MetaModel metaModel) { _rootAssetType = rootAssetType; _metaModel = metaModel; }
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; }
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}"); }
internal bool TryGetAttributeDefinition(AssetType assetType, string attributeNameToken, out AttributeDefinition attributeDefinition) { string key = $"{assetType.Token}.{attributeNameToken}"; return(TryGetAttributeDefinition(key, out attributeDefinition)); }
internal bool TryGetAssetType(string assetTypeToken, out AssetType assetType) { return(_assetTypes.TryGetValue(assetTypeToken, out assetType)); }
public SingleRelationAttributeDefinition(Type ownedType, PropertyInfo property, AssetType assetType, bool nullable, AssetType relatedAssetType) : base(assetType, property.Name, nullable, relatedAssetType, false) { _ownedType = ownedType; _property = property; }