1 //---------------------------------------------------------------------
2 // <copyright file="MetadataPropertyAttribute.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
7 // @backupOwner Microsoft
8 //---------------------------------------------------------------------
11 using System.Collections.Generic;
12 using System.Data.Common;
13 using System.Diagnostics;
15 namespace System.Data.Metadata.Edm
18 /// Attribute used to mark up properties that should appear in the MetadataItem.MetadataProperties collection
20 [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
21 internal sealed class MetadataPropertyAttribute : Attribute
24 /// Initializes a new attribute with built in type kind
26 /// <param name="builtInTypeKind">Built in type setting Type property</param>
27 /// <param name="isCollectionType">Sets IsCollectionType property</param>
28 internal MetadataPropertyAttribute(BuiltInTypeKind builtInTypeKind, bool isCollectionType)
29 : this(MetadataItem.GetBuiltInType(builtInTypeKind), isCollectionType)
34 /// Initializes a new attribute with primitive type kind
36 /// <param name="primitiveTypeKind">Primitive type setting Type property</param>
37 /// <param name="isCollectionType">Sets IsCollectionType property</param>
38 internal MetadataPropertyAttribute(PrimitiveTypeKind primitiveTypeKind, bool isCollectionType)
39 : this(MetadataItem.EdmProviderManifest.GetPrimitiveType(primitiveTypeKind), isCollectionType)
44 /// Initialize a new attribute with complex type kind (corresponding the the CLR type)
46 /// <param name="type">CLR type setting Type property</param>
47 /// <param name="isCollection">Sets IsCollectionType property</param>
48 internal MetadataPropertyAttribute(Type type, bool isCollection)
49 : this(ClrComplexType.CreateReadonlyClrComplexType(type, type.Namespace ?? string.Empty, type.Name), isCollection)
54 /// Initialize a new attribute
56 /// <param name="type">Sets Type property</param>
57 /// <param name="isCollectionType">Sets IsCollectionType property</param>
58 private MetadataPropertyAttribute(EdmType type, bool isCollectionType)
60 Debug.Assert(null != type);
62 _isCollectionType = isCollectionType;
65 private readonly EdmType _type;
66 private readonly bool _isCollectionType;
69 /// Gets EDM type for values stored in property.
71 internal EdmType Type { get { return _type; } }
74 /// Gets bool indicating whether this is a collection type.
76 internal bool IsCollectionType { get { return _isCollectionType; } }