Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / Metadata / Edm / StructuralType.cs / 1305376 / StructuralType.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Diagnostics; using System.Data.Common; using System.Text; namespace System.Data.Metadata.Edm { ////// Represents the Structural Type /// public abstract class StructuralType : EdmType { #region Constructors ////// Internal parameterless constructor for bootstrapping edmtypes /// internal StructuralType() { _members = new MemberCollection(this); _readOnlyMembers = _members.AsReadOnlyMetadataCollection(); } ////// Initializes a new instance of Structural Type with the given members /// /// name of the structural type /// namespace of the structural type /// version of the structural type /// dataSpace in which this edmtype belongs to ///Thrown if either name, namespace or version arguments are null internal StructuralType(string name, string namespaceName, DataSpace dataSpace) : base(name, namespaceName, dataSpace) { _members = new MemberCollection(this); _readOnlyMembers = _members.AsReadOnlyMetadataCollection(); } #endregion #region Fields private readonly MemberCollection _members; private readonly ReadOnlyMetadataCollection_readOnlyMembers; #endregion #region Properties /// /// Returns the collection of members. /// [MetadataProperty(BuiltInTypeKind.EdmMember, true)] public ReadOnlyMetadataCollectionMembers { get { return _readOnlyMembers; } } #endregion #region Methods /// /// Get the declared only members of a particular type /// internal ReadOnlyMetadataCollectionGetDeclaredOnlyMembers () where T : EdmMember { return _members.GetDeclaredOnlyMembers (); } /// /// Validates the types and sets the readOnly property to true. Once the type is set to readOnly, /// it can never be changed. /// internal override void SetReadOnly() { if (!IsReadOnly) { base.SetReadOnly(); this.Members.Source.SetReadOnly(); } } ////// Validates a EdmMember object to determine if it can be added to this type's /// Members collection. If this method returns without throwing, it is assumed /// the member is valid. /// /// The member to validate internal abstract void ValidateMemberForAdd(EdmMember member); ////// Adds a member to this type /// /// The member to add internal void AddMember(EdmMember member) { EntityUtil.GenericCheckArgumentNull(member, "member"); Util.ThrowIfReadOnly(this); Debug.Assert(this.DataSpace == member.TypeUsage.EdmType.DataSpace || this.BuiltInTypeKind == BuiltInTypeKind.RowType, "Wrong member type getting added in structural type"); //Since we set the DataSpace of the RowType to be -1 in the constructor, we need to initialize it //as and when we add members to it if (BuiltInTypeKind.RowType == this.BuiltInTypeKind) { // Do this only when you are adding the first member if (_members.Count == 0) { this.DataSpace = member.TypeUsage.EdmType.DataSpace; } // We need to build types that span across more than one space. For such row types, we set the // DataSpace to -1 else if (this.DataSpace != (DataSpace)(-1) && member.TypeUsage.EdmType.DataSpace != this.DataSpace) { this.DataSpace = (DataSpace)(-1); } } this._members.Add(member); } #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Diagnostics; using System.Data.Common; using System.Text; namespace System.Data.Metadata.Edm { ////// Represents the Structural Type /// public abstract class StructuralType : EdmType { #region Constructors ////// Internal parameterless constructor for bootstrapping edmtypes /// internal StructuralType() { _members = new MemberCollection(this); _readOnlyMembers = _members.AsReadOnlyMetadataCollection(); } ////// Initializes a new instance of Structural Type with the given members /// /// name of the structural type /// namespace of the structural type /// version of the structural type /// dataSpace in which this edmtype belongs to ///Thrown if either name, namespace or version arguments are null internal StructuralType(string name, string namespaceName, DataSpace dataSpace) : base(name, namespaceName, dataSpace) { _members = new MemberCollection(this); _readOnlyMembers = _members.AsReadOnlyMetadataCollection(); } #endregion #region Fields private readonly MemberCollection _members; private readonly ReadOnlyMetadataCollection_readOnlyMembers; #endregion #region Properties /// /// Returns the collection of members. /// [MetadataProperty(BuiltInTypeKind.EdmMember, true)] public ReadOnlyMetadataCollectionMembers { get { return _readOnlyMembers; } } #endregion #region Methods /// /// Get the declared only members of a particular type /// internal ReadOnlyMetadataCollectionGetDeclaredOnlyMembers () where T : EdmMember { return _members.GetDeclaredOnlyMembers (); } /// /// Validates the types and sets the readOnly property to true. Once the type is set to readOnly, /// it can never be changed. /// internal override void SetReadOnly() { if (!IsReadOnly) { base.SetReadOnly(); this.Members.Source.SetReadOnly(); } } ////// Validates a EdmMember object to determine if it can be added to this type's /// Members collection. If this method returns without throwing, it is assumed /// the member is valid. /// /// The member to validate internal abstract void ValidateMemberForAdd(EdmMember member); ////// Adds a member to this type /// /// The member to add internal void AddMember(EdmMember member) { EntityUtil.GenericCheckArgumentNull(member, "member"); Util.ThrowIfReadOnly(this); Debug.Assert(this.DataSpace == member.TypeUsage.EdmType.DataSpace || this.BuiltInTypeKind == BuiltInTypeKind.RowType, "Wrong member type getting added in structural type"); //Since we set the DataSpace of the RowType to be -1 in the constructor, we need to initialize it //as and when we add members to it if (BuiltInTypeKind.RowType == this.BuiltInTypeKind) { // Do this only when you are adding the first member if (_members.Count == 0) { this.DataSpace = member.TypeUsage.EdmType.DataSpace; } // We need to build types that span across more than one space. For such row types, we set the // DataSpace to -1 else if (this.DataSpace != (DataSpace)(-1) && member.TypeUsage.EdmType.DataSpace != this.DataSpace) { this.DataSpace = (DataSpace)(-1); } } this._members.Add(member); } #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- Encoding.cs
- XmlSchemaExternal.cs
- ColumnPropertiesGroup.cs
- PaperSource.cs
- _UncName.cs
- StyleXamlTreeBuilder.cs
- GPRECT.cs
- DocumentApplicationJournalEntry.cs
- Token.cs
- _NegotiateClient.cs
- XmlTextEncoder.cs
- SafePEFileHandle.cs
- Ops.cs
- PathStreamGeometryContext.cs
- ConsumerConnectionPointCollection.cs
- RIPEMD160.cs
- TdsParser.cs
- ValueTypeFixupInfo.cs
- ExplicitDiscriminatorMap.cs
- ExtensionFile.cs
- XamlSerializerUtil.cs
- MetadataCollection.cs
- HashHelpers.cs
- GridView.cs
- ParameterRetriever.cs
- HttpModulesSection.cs
- MD5.cs
- IsolatedStoragePermission.cs
- CleanUpVirtualizedItemEventArgs.cs
- JumpList.cs
- HtmlLink.cs
- InternalDuplexChannelListener.cs
- RotateTransform.cs
- TypeReference.cs
- ResourceProviderFactory.cs
- SqlConnectionManager.cs
- SharedPersonalizationStateInfo.cs
- MissingMethodException.cs
- BulletedListEventArgs.cs
- SiteMapDataSourceView.cs
- SecureEnvironment.cs
- ListBoxItem.cs
- Membership.cs
- DotAtomReader.cs
- EncryptedData.cs
- FixedSOMLineCollection.cs
- EditingScopeUndoUnit.cs
- DataFieldConverter.cs
- XPathParser.cs
- MetadataUtil.cs
- RootBrowserWindowProxy.cs
- ErrorWrapper.cs
- BufferedGraphics.cs
- SchemaTableColumn.cs
- XMLSyntaxException.cs
- ScrollableControl.cs
- ArraySegment.cs
- CriticalHandle.cs
- FixedSOMLineCollection.cs
- GroupBox.cs
- ALinqExpressionVisitor.cs
- WarningException.cs
- BaseResourcesBuildProvider.cs
- XPathAxisIterator.cs
- Propagator.ExtentPlaceholderCreator.cs
- SmtpDigestAuthenticationModule.cs
- Encoder.cs
- WebControl.cs
- Enlistment.cs
- loginstatus.cs
- DataBoundControlParameterTarget.cs
- FontCacheLogic.cs
- ConditionalWeakTable.cs
- FixUp.cs
- Psha1DerivedKeyGenerator.cs
- TypeViewSchema.cs
- EmptyStringExpandableObjectConverter.cs
- CheckBoxStandardAdapter.cs
- SBCSCodePageEncoding.cs
- CachedFontFace.cs
- ClientTargetSection.cs
- ExpressionBuilder.cs
- IndexedWhereQueryOperator.cs
- BookmarkUndoUnit.cs
- PropertyEntry.cs
- StrongNamePublicKeyBlob.cs
- C14NUtil.cs
- Int32Storage.cs
- TextChange.cs
- DataReaderContainer.cs
- ValidationHelpers.cs
- ExceptionNotification.cs
- Msmq3PoisonHandler.cs
- Trace.cs
- TableProviderWrapper.cs
- StructureChangedEventArgs.cs
- TextSchema.cs
- SettingsSection.cs
- SafeHandles.cs
- PointHitTestResult.cs