1 //--------------------------------------------------------------------- 2 // <copyright file="StorageTypeMapping.cs" company="Microsoft"> 3 // Copyright (c) Microsoft Corporation. All rights reserved. 4 // </copyright> 5 // 6 // @owner Microsoft 7 // @backupOwner Microsoft 8 //--------------------------------------------------------------------- 9 10 using System; 11 using System.Collections.Generic; 12 using System.Collections.ObjectModel; 13 using System.Text; 14 using System.Data.Metadata.Edm; 15 16 namespace System.Data.Mapping { 17 /// <summary> 18 /// Represents the Mapping metadata for a type map in CS space. 19 /// </summary> 20 /// <example> 21 /// For Example if conceptually you could represent the CS MSL file as following 22 /// --Mapping 23 /// --EntityContainerMapping ( CNorthwind-->SNorthwind ) 24 /// --EntitySetMapping 25 /// --EntityTypeMapping 26 /// --MappingFragment 27 /// --EntityKey 28 /// --ScalarPropertyMap 29 /// --ScalarPropertyMap 30 /// --EntityTypeMapping 31 /// --MappingFragment 32 /// --EntityKey 33 /// --ScalarPropertyMap 34 /// --ComplexPropertyMap 35 /// --ScalarPropertyMap 36 /// --ScalarProperyMap 37 /// --ScalarPropertyMap 38 /// --AssociationSetMapping 39 /// --AssociationTypeMapping 40 /// --MappingFragment 41 /// --EndPropertyMap 42 /// --ScalarPropertyMap 43 /// --ScalarProperyMap 44 /// --EndPropertyMap 45 /// --ScalarPropertyMap 46 /// This class represents the metadata for all the Type map elements in the 47 /// above example namely EntityTypeMapping, AssociationTypeMapping and CompositionTypeMapping. 48 /// The TypeMapping elements contain TableMappingFragments which in turn contain the property maps. 49 /// </example> 50 internal abstract class StorageTypeMapping { 51 #region Constructors 52 /// <summary> 53 /// Construct the new StorageTypeMapping object. 54 /// </summary> 55 /// <param name="setMapping">SetMapping that contains this type mapping </param> StorageTypeMapping(StorageSetMapping setMapping)56 internal StorageTypeMapping(StorageSetMapping setMapping) { 57 this.m_fragments = new List<StorageMappingFragment>(); 58 this.m_setMapping = setMapping; 59 } 60 #endregion 61 62 #region Fields 63 /// <summary> 64 /// ExtentMap that contains this type mapping. 65 /// </summary> 66 StorageSetMapping m_setMapping; 67 /// <summary> 68 /// Set of fragments that make up the type Mapping. 69 /// </summary> 70 List<StorageMappingFragment> m_fragments; 71 #endregion 72 73 #region Properties 74 /// <summary> 75 /// Mapping fragments that make up this set type 76 /// </summary> 77 internal ReadOnlyCollection<StorageMappingFragment> MappingFragments 78 { 79 get 80 { 81 return this.m_fragments.AsReadOnly(); 82 } 83 } 84 85 internal StorageSetMapping SetMapping 86 { 87 get 88 { 89 return m_setMapping; 90 } 91 } 92 93 94 /// <summary> 95 /// a list of TypeMetadata that this mapping holds true for. 96 /// </summary> 97 internal abstract ReadOnlyCollection<EdmType> Types { get;} 98 99 /// <summary> 100 /// a list of TypeMetadatas for which the mapping holds true for 101 /// not only the type specified but the sub-types of that type as well. 102 /// </summary> 103 internal abstract ReadOnlyCollection<EdmType> IsOfTypes { get;} 104 #endregion 105 106 #region Methods 107 /// <summary> 108 /// Add a fragment mapping as child of this type mapping 109 /// </summary> 110 /// <param name="fragment"></param> AddFragment(StorageMappingFragment fragment)111 internal void AddFragment(StorageMappingFragment fragment) 112 { 113 this.m_fragments.Add(fragment); 114 } 115 116 /// <summary> 117 /// This method is primarily for debugging purposes. 118 /// Will be removed shortly. 119 /// </summary> 120 /// <param name="index"></param> Print(int index)121 internal abstract void Print(int index); 122 #endregion 123 } 124 } 125