Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / ndp / fx / src / DataEntity / System / Data / Metadata / Edm / CollectionType.cs / 3 / CollectionType.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....], [....]
//---------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Text;
namespace System.Data.Metadata.Edm
{
///
/// Represents the Edm Collection Type
///
public sealed class CollectionType : EdmType
{
#region Constructors
///
/// The constructor for constructing a CollectionType object with the element type it contains
///
/// The element type that this collection type contains
/// Thrown if the argument elementType is null
internal CollectionType(EdmType elementType)
: this(TypeUsage.Create(elementType))
{
this.DataSpace = elementType.DataSpace;
}
///
/// The constructor for constructing a CollectionType object with the element type (as a TypeUsage) it contains
///
/// The element type that this collection type contains
/// Thrown if the argument elementType is null
internal CollectionType(TypeUsage elementType)
: base(GetIdentity(EntityUtil.GenericCheckArgumentNull(elementType, "elementType")),
EdmConstants.TransientNamespace, elementType.EdmType.DataSpace)
{
_typeUsage = elementType;
SetReadOnly();
}
#endregion
#region Fields
private readonly TypeUsage _typeUsage;
#endregion
#region Properties
///
/// Returns the kind of the type
///
public override BuiltInTypeKind BuiltInTypeKind { get { return BuiltInTypeKind.CollectionType; } }
///
/// The type of the element that this collection type contains
///
[MetadataProperty(BuiltInTypeKind.TypeUsage, false)]
public TypeUsage TypeUsage
{
get
{
return _typeUsage;
}
}
#endregion
#region Methods
///
/// Constructs the name of the collection type
///
/// The typeusage for the element type that this collection type refers to
/// The identity of the resulting collection type
private static string GetIdentity(TypeUsage typeUsage)
{
StringBuilder builder = new StringBuilder(50);
builder.Append("collection[");
typeUsage.BuildIdentity(builder);
builder.Append("]");
return builder.ToString();
}
///
/// Override EdmEquals to support value comparison of TypeUsage property
///
///
///
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.CollectionType != item.BuiltInTypeKind) { return false; }
CollectionType other = (CollectionType)item;
// compare type usage
return this.TypeUsage.EdmEquals(other.TypeUsage);
}
#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.Data.Common;
using System.Text;
namespace System.Data.Metadata.Edm
{
///
/// Represents the Edm Collection Type
///
public sealed class CollectionType : EdmType
{
#region Constructors
///
/// The constructor for constructing a CollectionType object with the element type it contains
///
/// The element type that this collection type contains
/// Thrown if the argument elementType is null
internal CollectionType(EdmType elementType)
: this(TypeUsage.Create(elementType))
{
this.DataSpace = elementType.DataSpace;
}
///
/// The constructor for constructing a CollectionType object with the element type (as a TypeUsage) it contains
///
/// The element type that this collection type contains
/// Thrown if the argument elementType is null
internal CollectionType(TypeUsage elementType)
: base(GetIdentity(EntityUtil.GenericCheckArgumentNull(elementType, "elementType")),
EdmConstants.TransientNamespace, elementType.EdmType.DataSpace)
{
_typeUsage = elementType;
SetReadOnly();
}
#endregion
#region Fields
private readonly TypeUsage _typeUsage;
#endregion
#region Properties
///
/// Returns the kind of the type
///
public override BuiltInTypeKind BuiltInTypeKind { get { return BuiltInTypeKind.CollectionType; } }
///
/// The type of the element that this collection type contains
///
[MetadataProperty(BuiltInTypeKind.TypeUsage, false)]
public TypeUsage TypeUsage
{
get
{
return _typeUsage;
}
}
#endregion
#region Methods
///
/// Constructs the name of the collection type
///
/// The typeusage for the element type that this collection type refers to
/// The identity of the resulting collection type
private static string GetIdentity(TypeUsage typeUsage)
{
StringBuilder builder = new StringBuilder(50);
builder.Append("collection[");
typeUsage.BuildIdentity(builder);
builder.Append("]");
return builder.ToString();
}
///
/// Override EdmEquals to support value comparison of TypeUsage property
///
///
///
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.CollectionType != item.BuiltInTypeKind) { return false; }
CollectionType other = (CollectionType)item;
// compare type usage
return this.TypeUsage.EdmEquals(other.TypeUsage);
}
#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
- LayoutUtils.cs
- ResourceReferenceKeyNotFoundException.cs
- StringStorage.cs
- AutomationPropertyInfo.cs
- DynamicQueryableWrapper.cs
- DescendentsWalker.cs
- SafeRegistryHandle.cs
- ExpressionBindings.cs
- ContractSearchPattern.cs
- XsdDateTime.cs
- TargetException.cs
- ValuePatternIdentifiers.cs
- AppDomainShutdownMonitor.cs
- EmptyArray.cs
- XmlCountingReader.cs
- TextTreePropertyUndoUnit.cs
- TextEndOfLine.cs
- DataObjectPastingEventArgs.cs
- SqlFactory.cs
- SR.cs
- PocoPropertyAccessorStrategy.cs
- DataBinding.cs
- ConfigurationSectionCollection.cs
- TextBounds.cs
- SoapCommonClasses.cs
- TypeInfo.cs
- MouseWheelEventArgs.cs
- BitmapInitialize.cs
- FileUpload.cs
- TextBoxAutoCompleteSourceConverter.cs
- DocumentViewerConstants.cs
- ListMarkerSourceInfo.cs
- ToolStripOverflow.cs
- ByteViewer.cs
- SpecialTypeDataContract.cs
- OdbcStatementHandle.cs
- SelectionItemPattern.cs
- ChannelSinkStacks.cs
- DoubleKeyFrameCollection.cs
- ThreadAbortException.cs
- DataRowComparer.cs
- RSAPKCS1SignatureFormatter.cs
- DesignTimeResourceProviderFactoryAttribute.cs
- WrapPanel.cs
- indexingfiltermarshaler.cs
- ProtocolViolationException.cs
- TypeLoadException.cs
- SystemIcmpV4Statistics.cs
- Compiler.cs
- SqlConnectionHelper.cs
- PreviewPrintController.cs
- CodeTypeMember.cs
- dataSvcMapFileLoader.cs
- SystemFonts.cs
- AutoGeneratedField.cs
- DescendantQuery.cs
- PropertyEmitter.cs
- ContentElement.cs
- IResourceProvider.cs
- XmlUrlResolver.cs
- WsdlImporter.cs
- HandledEventArgs.cs
- CodeTypeReferenceExpression.cs
- PerfCounters.cs
- EventSource.cs
- AutoResetEvent.cs
- AlignmentYValidation.cs
- HttpRawResponse.cs
- ValueQuery.cs
- XMLSchema.cs
- FactoryMaker.cs
- _IPv4Address.cs
- SqlDataSourceStatusEventArgs.cs
- ImageAttributes.cs
- Int32Storage.cs
- InitializationEventAttribute.cs
- Size3D.cs
- CharacterMetrics.cs
- BaseTemplateParser.cs
- Relationship.cs
- SynchronizedReadOnlyCollection.cs
- AuthenticateEventArgs.cs
- BrowserCapabilitiesFactory.cs
- IdentityValidationException.cs
- InkCanvasInnerCanvas.cs
- SingleTagSectionHandler.cs
- RoutedCommand.cs
- NonClientArea.cs
- DBSqlParserColumn.cs
- TiffBitmapDecoder.cs
- MultiByteCodec.cs
- GB18030Encoding.cs
- ProviderException.cs
- CqlParserHelpers.cs
- PriorityBindingExpression.cs
- UInt64Converter.cs
- XmlNullResolver.cs
- FormViewPagerRow.cs
- AssemblyFilter.cs
- DecoratedNameAttribute.cs