4b768e481715cff0cb9b6c13585a0a60aa4e51fd
[mono.git] / mcs / class / referencesource / System.Data.Entity / System / Data / Metadata / Edm / GlobalItem.cs
1 //---------------------------------------------------------------------
2 // <copyright file="GlobalItem.cs" company="Microsoft">
3 //      Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>
5 //
6 // @owner       Microsoft
7 // @backupOwner Microsoft
8 //---------------------------------------------------------------------
9 using System;
10 using System.Collections.Generic;
11 using System.Collections.ObjectModel;
12 using System.Data.Common;
13 using System.Diagnostics;
14 using System.Text;
15 using System.Xml.Serialization;
16 using System.Xml.Schema;
17 using System.Xml;
18
19 namespace System.Data.Metadata.Edm
20 {
21     /// <summary>
22     /// Represents the base item class for all the metadata
23     /// </summary>
24     public abstract class GlobalItem : MetadataItem
25     {
26         #region Constructors
27         /// <summary>
28         /// Implementing this internal constructor so that this class can't be derived
29         /// outside this assembly
30         /// </summary>
31         internal GlobalItem()
32         {
33         }
34
35         internal GlobalItem(MetadataFlags flags) 
36             : base(flags) 
37         { 
38         }
39         #endregion
40
41         #region Properties
42
43         /// <summary>
44         /// Returns the DataSpace in which this type belongs to
45         /// </summary>
46         [MetadataProperty(typeof(DataSpace), false)]
47         internal DataSpace DataSpace
48         {
49             get
50             {
51                 // Since there can be row types that span across spaces and we can have collections to such row types, we need to exclude RowType and collection type in this assert check
52                 Debug.Assert(GetDataSpace() != (DataSpace)(-1) || this.BuiltInTypeKind == BuiltInTypeKind.RowType || this.BuiltInTypeKind == BuiltInTypeKind.CollectionType, "DataSpace must have some valid value");
53                 return GetDataSpace();
54             }
55             set
56             {
57                 // Whenever you assign the data space value, it must be unassigned or re-assigned to the same value.
58                 // The only exception being we sometimes need to create row types that contains types from various spaces
59                 Debug.Assert(GetDataSpace() == (DataSpace)(-1) || GetDataSpace() == value || this.BuiltInTypeKind == BuiltInTypeKind.RowType || this.BuiltInTypeKind == BuiltInTypeKind.CollectionType, "Invalid Value being set for DataSpace");
60                 SetDataSpace(value);
61             }
62         }
63         #endregion  
64     }
65 }