Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / ndp / fx / src / DataEntity / System / Data / Metadata / Edm / RowType.cs / 3 / RowType.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....], [....] //--------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Globalization; using System.Data.Common; using System.Text; using System.Data.Objects.ELinq; using System.Threading; using System.Diagnostics; namespace System.Data.Metadata.Edm { ////// Represents the Edm Row Type /// public sealed class RowType : StructuralType { private ReadOnlyMetadataCollection_properties; private readonly InitializerMetadata _initializerMetadata; #region Constructors /// /// Initializes a new instance of RowType class with the given list of members /// /// properties for this row type ///Thrown if any individual property in the passed in properties argument is null internal RowType(IEnumerableproperties) : this(properties, null) { } /// /// Initializes a RowType with the given members and initializer metadata /// internal RowType(IEnumerableproperties, InitializerMetadata initializerMetadata) : base(GetRowTypeIdentityFromProperties(CheckProperties(properties), initializerMetadata), EdmConstants.TransientNamespace, (DataSpace)(-1)) { // Initialize the properties. if (null != properties) { foreach (EdmProperty property in properties) { this.AddProperty(property); } } _initializerMetadata = initializerMetadata; // Row types are immutable, so now that we're done initializing, set it // to be read-only. SetReadOnly(); } #endregion #region Properties /// /// Gets or sets LINQ initializer Metadata for this row type. If there is no associated /// initializer type, value is null. /// internal InitializerMetadata InitializerMetadata { get { return _initializerMetadata; } } ////// Returns the kind of the type /// public override BuiltInTypeKind BuiltInTypeKind { get { return BuiltInTypeKind.RowType; } } ////// Returns the list of properties for this row type /// ////// Returns just the properties from the collection /// of members on this type /// public ReadOnlyMetadataCollectionProperties { get { Debug.Assert(IsReadOnly, "this is a wrapper around this.Members, don't call it during metadata loading, only call it after the metadata is set to readonly"); if (null == _properties) { Interlocked.CompareExchange(ref _properties, new FilteredReadOnlyMetadataCollection ( this.Members, Helper.IsEdmProperty), null); } return _properties; } } /// /// Adds a property /// /// The property to add private void AddProperty(EdmProperty property) { EntityUtil.GenericCheckArgumentNull(property, "property"); AddMember(property); } ////// 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 ///Thrown if the member is not a EdmProperty internal override void ValidateMemberForAdd(EdmMember member) { if (!Helper.IsEdmProperty(member)) { throw EntityUtil.RowTypeInvalidMembers(); } } ////// Calculates the row type identity that would result from /// a given set of properties. /// /// The properties that determine the row type's structure /// Metadata describing materialization of this row type ///A string that identifies the row type private static string GetRowTypeIdentityFromProperties(IEnumerableproperties, InitializerMetadata initializerMetadata) { // The row type identity is formed as follows: // "rowtype[" + a comma-separated list of property identities + "]" StringBuilder identity = new StringBuilder("rowtype["); if (null != properties) { int i = 0; // For each property, append the type name and facets. foreach (EdmProperty property in properties) { if (i > 0) { identity.Append(","); } identity.Append("("); identity.Append(property.Name); identity.Append(","); property.TypeUsage.BuildIdentity(identity); identity.Append(")"); i++; } } identity.Append("]"); if (null != initializerMetadata) { identity.Append(",").Append(initializerMetadata.Identity); } return identity.ToString(); } private static IEnumerable CheckProperties(IEnumerable properties) { if (null != properties) { int i = 0; foreach (EdmProperty prop in properties) { if (prop == null) { throw EntityUtil.CollectionParameterElementIsNull("properties"); } i++; } /* if (i < 1) { throw EntityUtil.ArgumentOutOfRange("properties"); } */ } return properties; } #endregion #region Methods /// /// EdmEquals override verifying the equivalence of all members and their type usages. /// /// ///internal override bool EdmEquals(MetadataItem item) { // short-circuit if this and other are reference equivalent if (Object.ReferenceEquals(this, item)) { return true; } // check type of item if (null == item || BuiltInTypeKind.RowType != item.BuiltInTypeKind) { return false; } RowType other = (RowType)item; // check each row type has the same number of members if (this.Members.Count != other.Members.Count) { return false; } // verify all members are equivalent for (int ordinal = 0; ordinal < this.Members.Count; ordinal++) { EdmMember thisMember = this.Members[ordinal]; EdmMember otherMember = other.Members[ordinal]; // if members are different, return false if (!thisMember.EdmEquals(otherMember) || !thisMember.TypeUsage.EdmEquals(otherMember.TypeUsage)) { return false; } } return true; } #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....], [....] //--------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Globalization; using System.Data.Common; using System.Text; using System.Data.Objects.ELinq; using System.Threading; using System.Diagnostics; namespace System.Data.Metadata.Edm { ////// Represents the Edm Row Type /// public sealed class RowType : StructuralType { private ReadOnlyMetadataCollection_properties; private readonly InitializerMetadata _initializerMetadata; #region Constructors /// /// Initializes a new instance of RowType class with the given list of members /// /// properties for this row type ///Thrown if any individual property in the passed in properties argument is null internal RowType(IEnumerableproperties) : this(properties, null) { } /// /// Initializes a RowType with the given members and initializer metadata /// internal RowType(IEnumerableproperties, InitializerMetadata initializerMetadata) : base(GetRowTypeIdentityFromProperties(CheckProperties(properties), initializerMetadata), EdmConstants.TransientNamespace, (DataSpace)(-1)) { // Initialize the properties. if (null != properties) { foreach (EdmProperty property in properties) { this.AddProperty(property); } } _initializerMetadata = initializerMetadata; // Row types are immutable, so now that we're done initializing, set it // to be read-only. SetReadOnly(); } #endregion #region Properties /// /// Gets or sets LINQ initializer Metadata for this row type. If there is no associated /// initializer type, value is null. /// internal InitializerMetadata InitializerMetadata { get { return _initializerMetadata; } } ////// Returns the kind of the type /// public override BuiltInTypeKind BuiltInTypeKind { get { return BuiltInTypeKind.RowType; } } ////// Returns the list of properties for this row type /// ////// Returns just the properties from the collection /// of members on this type /// public ReadOnlyMetadataCollectionProperties { get { Debug.Assert(IsReadOnly, "this is a wrapper around this.Members, don't call it during metadata loading, only call it after the metadata is set to readonly"); if (null == _properties) { Interlocked.CompareExchange(ref _properties, new FilteredReadOnlyMetadataCollection ( this.Members, Helper.IsEdmProperty), null); } return _properties; } } /// /// Adds a property /// /// The property to add private void AddProperty(EdmProperty property) { EntityUtil.GenericCheckArgumentNull(property, "property"); AddMember(property); } ////// 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 ///Thrown if the member is not a EdmProperty internal override void ValidateMemberForAdd(EdmMember member) { if (!Helper.IsEdmProperty(member)) { throw EntityUtil.RowTypeInvalidMembers(); } } ////// Calculates the row type identity that would result from /// a given set of properties. /// /// The properties that determine the row type's structure /// Metadata describing materialization of this row type ///A string that identifies the row type private static string GetRowTypeIdentityFromProperties(IEnumerableproperties, InitializerMetadata initializerMetadata) { // The row type identity is formed as follows: // "rowtype[" + a comma-separated list of property identities + "]" StringBuilder identity = new StringBuilder("rowtype["); if (null != properties) { int i = 0; // For each property, append the type name and facets. foreach (EdmProperty property in properties) { if (i > 0) { identity.Append(","); } identity.Append("("); identity.Append(property.Name); identity.Append(","); property.TypeUsage.BuildIdentity(identity); identity.Append(")"); i++; } } identity.Append("]"); if (null != initializerMetadata) { identity.Append(",").Append(initializerMetadata.Identity); } return identity.ToString(); } private static IEnumerable CheckProperties(IEnumerable properties) { if (null != properties) { int i = 0; foreach (EdmProperty prop in properties) { if (prop == null) { throw EntityUtil.CollectionParameterElementIsNull("properties"); } i++; } /* if (i < 1) { throw EntityUtil.ArgumentOutOfRange("properties"); } */ } return properties; } #endregion #region Methods /// /// EdmEquals override verifying the equivalence of all members and their type usages. /// /// ///internal override bool EdmEquals(MetadataItem item) { // short-circuit if this and other are reference equivalent if (Object.ReferenceEquals(this, item)) { return true; } // check type of item if (null == item || BuiltInTypeKind.RowType != item.BuiltInTypeKind) { return false; } RowType other = (RowType)item; // check each row type has the same number of members if (this.Members.Count != other.Members.Count) { return false; } // verify all members are equivalent for (int ordinal = 0; ordinal < this.Members.Count; ordinal++) { EdmMember thisMember = this.Members[ordinal]; EdmMember otherMember = other.Members[ordinal]; // if members are different, return false if (!thisMember.EdmEquals(otherMember) || !thisMember.TypeUsage.EdmEquals(otherMember.TypeUsage)) { return false; } } return true; } #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
- _Connection.cs
- PrintController.cs
- BitmapSource.cs
- AsyncCodeActivityContext.cs
- ScriptingJsonSerializationSection.cs
- LogManagementAsyncResult.cs
- LinqDataSourceUpdateEventArgs.cs
- DataReceivedEventArgs.cs
- WorkflowServiceBehavior.cs
- StateWorkerRequest.cs
- Material.cs
- XPathAncestorQuery.cs
- ApplyImportsAction.cs
- DataColumnChangeEvent.cs
- CaseInsensitiveComparer.cs
- AbstractExpressions.cs
- EditableRegion.cs
- DataSourceControlBuilder.cs
- DrawingContextWalker.cs
- FixedFindEngine.cs
- IListConverters.cs
- KeyboardInputProviderAcquireFocusEventArgs.cs
- XmlBindingWorker.cs
- LocationReference.cs
- BuiltInExpr.cs
- SystemIcmpV6Statistics.cs
- ReceiveParametersContent.cs
- XmlSchemaImporter.cs
- BooleanSwitch.cs
- SqlDataSourceFilteringEventArgs.cs
- MetadataHelper.cs
- GenericUriParser.cs
- RegisteredScript.cs
- ToolStripKeyboardHandlingService.cs
- HttpServerVarsCollection.cs
- TextCompositionManager.cs
- SQLSingle.cs
- X509Extension.cs
- XmlnsCache.cs
- SqlCacheDependencySection.cs
- SessionConnectionReader.cs
- RegexInterpreter.cs
- GeneralTransform3D.cs
- SqlClientWrapperSmiStreamChars.cs
- ProbeMatchesCD1.cs
- RepeaterDesigner.cs
- KeyedByTypeCollection.cs
- Camera.cs
- EdmConstants.cs
- ChannelTerminatedException.cs
- CodePropertyReferenceExpression.cs
- DynamicDataRoute.cs
- ColorMap.cs
- OpacityConverter.cs
- NullRuntimeConfig.cs
- EncryptedType.cs
- AspNetRouteServiceHttpHandler.cs
- CodeTypeParameterCollection.cs
- TaiwanLunisolarCalendar.cs
- ColumnMap.cs
- HttpAsyncResult.cs
- BufferedGraphicsContext.cs
- WebServiceParameterData.cs
- CorrelationTokenInvalidatedHandler.cs
- GroupItemAutomationPeer.cs
- ObjectDisposedException.cs
- AlphaSortedEnumConverter.cs
- TriState.cs
- InternalConfigSettingsFactory.cs
- DbDataRecord.cs
- SplayTreeNode.cs
- ObjectDataSourceSelectingEventArgs.cs
- DbProviderSpecificTypePropertyAttribute.cs
- SecuritySessionSecurityTokenAuthenticator.cs
- LineSegment.cs
- SingleResultAttribute.cs
- SchemaImporterExtensionsSection.cs
- SiteMapNodeItemEventArgs.cs
- AutoGeneratedFieldProperties.cs
- DocumentSchemaValidator.cs
- PrinterResolution.cs
- IRCollection.cs
- DateTimeOffset.cs
- __Filters.cs
- CurrentTimeZone.cs
- Paragraph.cs
- RootBrowserWindow.cs
- DefaultValueTypeConverter.cs
- WindowsGraphics2.cs
- LogicalChannelCollection.cs
- URL.cs
- Expression.cs
- VectorAnimation.cs
- MetadataItemEmitter.cs
- XPathSelectionIterator.cs
- SolidBrush.cs
- RelationshipType.cs
- ProcessInfo.cs
- RoutedUICommand.cs
- WebDisplayNameAttribute.cs