Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / ndp / fx / src / DataEntity / System / Data / Metadata / Edm / Provider / ClrProviderManifest.cs / 2 / ClrProviderManifest.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System.Collections.Generic; using System.Data.Common; using System.Diagnostics; using System.Collections.ObjectModel; using System.Threading; using System.Linq; namespace System.Data.Metadata.Edm { internal class ClrProviderManifest : DbProviderManifest { private const int s_PrimitiveTypeCount = 15; private System.Collections.ObjectModel.ReadOnlyCollection_primitiveTypes; private static ClrProviderManifest _instance = new ClrProviderManifest(); /// /// A private constructor to prevent other places from instantiating this class /// private ClrProviderManifest() { } ////// Gets the EDM provider manifest singleton instance /// internal static ClrProviderManifest Instance { get { return _instance; } } ////// Returns the namespace used by this provider manifest /// public override string NamespaceName { get { return EdmConstants.ClrPrimitiveTypeNamespace; } } ////// Returns the primitive type corresponding to the given CLR type /// /// The CLR type for which the PrimitiveType object is retrieved /// The retrieved primitive type ///True if a primitive type is returned internal bool TryGetPrimitiveType(Type clrType, out PrimitiveType primitiveType) { primitiveType = null; InitializePrimitiveTypes(); for (int i = 0 ; i < _primitiveTypes.Count ; i++ ) { if (_primitiveTypes[i].ClrEquivalentType.Equals(clrType)) { primitiveType = _primitiveTypes[i]; return true; } } return false; } ////// Returns all the functions in this provider manifest /// ///A collection of functions public override System.Collections.ObjectModel.ReadOnlyCollectionGetStoreFunctions() { return Helper.EmptyEdmFunctionReadOnlyCollection; } /// /// Returns all the FacetDescriptions for a particular type /// /// the type to return FacetDescriptions for. ///The FacetDescriptions for the type given. public override System.Collections.ObjectModel.ReadOnlyCollectionGetFacetDescriptions(EdmType type) { if (Helper.IsPrimitiveType(type) && ((PrimitiveType)type).DataSpace == DataSpace.OSpace) { // we don't have our own facets, just defer to the edm primitive type facets PrimitiveType basePrimitive = (PrimitiveType)type.BaseType; return basePrimitive.ProviderManifest.GetFacetDescriptions(basePrimitive); } return Helper.EmptyFacetDescriptionEnumerable; } /// /// Initializes all the primitive types /// private void InitializePrimitiveTypes() { if (_primitiveTypes != null) { return; } PrimitiveType[] primitiveTypes = new PrimitiveType[s_PrimitiveTypeCount]; primitiveTypes[(int)PrimitiveTypeKind.Binary] = CreatePrimitiveType(typeof(Byte[]), PrimitiveTypeKind.Binary); primitiveTypes[(int)PrimitiveTypeKind.Boolean] = CreatePrimitiveType(typeof(Boolean), PrimitiveTypeKind.Boolean); primitiveTypes[(int)PrimitiveTypeKind.Byte] = CreatePrimitiveType(typeof(Byte), PrimitiveTypeKind.Byte); primitiveTypes[(int)PrimitiveTypeKind.DateTime] = CreatePrimitiveType(typeof(DateTime), PrimitiveTypeKind.DateTime); primitiveTypes[(int)PrimitiveTypeKind.Time] = CreatePrimitiveType(typeof(TimeSpan), PrimitiveTypeKind.Time); primitiveTypes[(int)PrimitiveTypeKind.DateTimeOffset] = CreatePrimitiveType(typeof(DateTimeOffset), PrimitiveTypeKind.DateTimeOffset); primitiveTypes[(int)PrimitiveTypeKind.Decimal] = CreatePrimitiveType(typeof(Decimal), PrimitiveTypeKind.Decimal); primitiveTypes[(int)PrimitiveTypeKind.Double] = CreatePrimitiveType(typeof(Double), PrimitiveTypeKind.Double); primitiveTypes[(int)PrimitiveTypeKind.Guid] = CreatePrimitiveType(typeof(Guid), PrimitiveTypeKind.Guid); primitiveTypes[(int)PrimitiveTypeKind.Int16] = CreatePrimitiveType(typeof(Int16), PrimitiveTypeKind.Int16); primitiveTypes[(int)PrimitiveTypeKind.Int32] = CreatePrimitiveType(typeof(Int32), PrimitiveTypeKind.Int32); primitiveTypes[(int)PrimitiveTypeKind.Int64] = CreatePrimitiveType(typeof(Int64), PrimitiveTypeKind.Int64); primitiveTypes[(int)PrimitiveTypeKind.SByte] = CreatePrimitiveType(typeof(SByte), PrimitiveTypeKind.SByte); primitiveTypes[(int)PrimitiveTypeKind.Single] = CreatePrimitiveType(typeof(Single), PrimitiveTypeKind.Single); primitiveTypes[(int)PrimitiveTypeKind.String] = CreatePrimitiveType(typeof(String), PrimitiveTypeKind.String); for (int i = 0; i < primitiveTypes.Length; i++) { primitiveTypes[i].SetReadOnly(); } System.Collections.ObjectModel.ReadOnlyCollectionreadOnlyTypes = new System.Collections.ObjectModel.ReadOnlyCollection (primitiveTypes); // Set the result to _primitiveTypes at the end Interlocked.CompareExchange >(ref _primitiveTypes, readOnlyTypes, null); } /// /// Initialize the primitive type with the given /// /// The CLR type of this type /// The primitive type kind of the primitive type private PrimitiveType CreatePrimitiveType(Type clrType, PrimitiveTypeKind primitiveTypeKind) { // Figures out the base type PrimitiveType baseType = MetadataItem.EdmProviderManifest.GetPrimitiveType(primitiveTypeKind); PrimitiveType primitiveType = new PrimitiveType(clrType, baseType, this); return primitiveType; } public override System.Collections.ObjectModel.ReadOnlyCollectionGetStoreTypes() { InitializePrimitiveTypes(); return this._primitiveTypes; } public override TypeUsage GetEdmType(TypeUsage storeType) { throw new NotImplementedException(); } public override TypeUsage GetStoreType(TypeUsage edmType) { throw new NotImplementedException(); } /// /// Providers should override this to return information specific to their provider. /// /// This method should never return null. /// /// The name of the information to be retrieved. ///An XmlReader at the begining of the information requested. protected override System.Xml.XmlReader GetDbInformation(string informationType) { throw new NotImplementedException(); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System.Collections.Generic; using System.Data.Common; using System.Diagnostics; using System.Collections.ObjectModel; using System.Threading; using System.Linq; namespace System.Data.Metadata.Edm { internal class ClrProviderManifest : DbProviderManifest { private const int s_PrimitiveTypeCount = 15; private System.Collections.ObjectModel.ReadOnlyCollection_primitiveTypes; private static ClrProviderManifest _instance = new ClrProviderManifest(); /// /// A private constructor to prevent other places from instantiating this class /// private ClrProviderManifest() { } ////// Gets the EDM provider manifest singleton instance /// internal static ClrProviderManifest Instance { get { return _instance; } } ////// Returns the namespace used by this provider manifest /// public override string NamespaceName { get { return EdmConstants.ClrPrimitiveTypeNamespace; } } ////// Returns the primitive type corresponding to the given CLR type /// /// The CLR type for which the PrimitiveType object is retrieved /// The retrieved primitive type ///True if a primitive type is returned internal bool TryGetPrimitiveType(Type clrType, out PrimitiveType primitiveType) { primitiveType = null; InitializePrimitiveTypes(); for (int i = 0 ; i < _primitiveTypes.Count ; i++ ) { if (_primitiveTypes[i].ClrEquivalentType.Equals(clrType)) { primitiveType = _primitiveTypes[i]; return true; } } return false; } ////// Returns all the functions in this provider manifest /// ///A collection of functions public override System.Collections.ObjectModel.ReadOnlyCollectionGetStoreFunctions() { return Helper.EmptyEdmFunctionReadOnlyCollection; } /// /// Returns all the FacetDescriptions for a particular type /// /// the type to return FacetDescriptions for. ///The FacetDescriptions for the type given. public override System.Collections.ObjectModel.ReadOnlyCollectionGetFacetDescriptions(EdmType type) { if (Helper.IsPrimitiveType(type) && ((PrimitiveType)type).DataSpace == DataSpace.OSpace) { // we don't have our own facets, just defer to the edm primitive type facets PrimitiveType basePrimitive = (PrimitiveType)type.BaseType; return basePrimitive.ProviderManifest.GetFacetDescriptions(basePrimitive); } return Helper.EmptyFacetDescriptionEnumerable; } /// /// Initializes all the primitive types /// private void InitializePrimitiveTypes() { if (_primitiveTypes != null) { return; } PrimitiveType[] primitiveTypes = new PrimitiveType[s_PrimitiveTypeCount]; primitiveTypes[(int)PrimitiveTypeKind.Binary] = CreatePrimitiveType(typeof(Byte[]), PrimitiveTypeKind.Binary); primitiveTypes[(int)PrimitiveTypeKind.Boolean] = CreatePrimitiveType(typeof(Boolean), PrimitiveTypeKind.Boolean); primitiveTypes[(int)PrimitiveTypeKind.Byte] = CreatePrimitiveType(typeof(Byte), PrimitiveTypeKind.Byte); primitiveTypes[(int)PrimitiveTypeKind.DateTime] = CreatePrimitiveType(typeof(DateTime), PrimitiveTypeKind.DateTime); primitiveTypes[(int)PrimitiveTypeKind.Time] = CreatePrimitiveType(typeof(TimeSpan), PrimitiveTypeKind.Time); primitiveTypes[(int)PrimitiveTypeKind.DateTimeOffset] = CreatePrimitiveType(typeof(DateTimeOffset), PrimitiveTypeKind.DateTimeOffset); primitiveTypes[(int)PrimitiveTypeKind.Decimal] = CreatePrimitiveType(typeof(Decimal), PrimitiveTypeKind.Decimal); primitiveTypes[(int)PrimitiveTypeKind.Double] = CreatePrimitiveType(typeof(Double), PrimitiveTypeKind.Double); primitiveTypes[(int)PrimitiveTypeKind.Guid] = CreatePrimitiveType(typeof(Guid), PrimitiveTypeKind.Guid); primitiveTypes[(int)PrimitiveTypeKind.Int16] = CreatePrimitiveType(typeof(Int16), PrimitiveTypeKind.Int16); primitiveTypes[(int)PrimitiveTypeKind.Int32] = CreatePrimitiveType(typeof(Int32), PrimitiveTypeKind.Int32); primitiveTypes[(int)PrimitiveTypeKind.Int64] = CreatePrimitiveType(typeof(Int64), PrimitiveTypeKind.Int64); primitiveTypes[(int)PrimitiveTypeKind.SByte] = CreatePrimitiveType(typeof(SByte), PrimitiveTypeKind.SByte); primitiveTypes[(int)PrimitiveTypeKind.Single] = CreatePrimitiveType(typeof(Single), PrimitiveTypeKind.Single); primitiveTypes[(int)PrimitiveTypeKind.String] = CreatePrimitiveType(typeof(String), PrimitiveTypeKind.String); for (int i = 0; i < primitiveTypes.Length; i++) { primitiveTypes[i].SetReadOnly(); } System.Collections.ObjectModel.ReadOnlyCollectionreadOnlyTypes = new System.Collections.ObjectModel.ReadOnlyCollection (primitiveTypes); // Set the result to _primitiveTypes at the end Interlocked.CompareExchange >(ref _primitiveTypes, readOnlyTypes, null); } /// /// Initialize the primitive type with the given /// /// The CLR type of this type /// The primitive type kind of the primitive type private PrimitiveType CreatePrimitiveType(Type clrType, PrimitiveTypeKind primitiveTypeKind) { // Figures out the base type PrimitiveType baseType = MetadataItem.EdmProviderManifest.GetPrimitiveType(primitiveTypeKind); PrimitiveType primitiveType = new PrimitiveType(clrType, baseType, this); return primitiveType; } public override System.Collections.ObjectModel.ReadOnlyCollectionGetStoreTypes() { InitializePrimitiveTypes(); return this._primitiveTypes; } public override TypeUsage GetEdmType(TypeUsage storeType) { throw new NotImplementedException(); } public override TypeUsage GetStoreType(TypeUsage edmType) { throw new NotImplementedException(); } /// /// Providers should override this to return information specific to their provider. /// /// This method should never return null. /// /// The name of the information to be retrieved. ///An XmlReader at the begining of the information requested. protected override System.Xml.XmlReader GetDbInformation(string informationType) { throw new NotImplementedException(); } } } // 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
- TableRowGroupCollection.cs
- SchemaObjectWriter.cs
- Delegate.cs
- Transactions.cs
- ObjectItemCollectionAssemblyCacheEntry.cs
- SafeSecurityHelper.cs
- SrgsDocumentParser.cs
- __Filters.cs
- Rect3DConverter.cs
- _ConnectionGroup.cs
- ElementHost.cs
- ColorInterpolationModeValidation.cs
- CustomExpression.cs
- ExpressionParser.cs
- CodeDirectoryCompiler.cs
- _Win32.cs
- DoubleIndependentAnimationStorage.cs
- DataServiceConfiguration.cs
- XmlEnumAttribute.cs
- RuntimeResourceSet.cs
- XmlException.cs
- DataDocumentXPathNavigator.cs
- EntityDataSourceWrapperCollection.cs
- XmlAtomicValue.cs
- LookupTables.cs
- ProfileProvider.cs
- NamespaceList.cs
- BamlTreeUpdater.cs
- XmlSchemaCompilationSettings.cs
- DataGridViewCellStyleChangedEventArgs.cs
- WebPartConnectVerb.cs
- TypeUsageBuilder.cs
- RC2CryptoServiceProvider.cs
- ObjectHelper.cs
- Misc.cs
- PatternMatcher.cs
- SmiMetaData.cs
- AnonymousIdentificationSection.cs
- IgnoreFlushAndCloseStream.cs
- XmlSchema.cs
- WebException.cs
- DataGridPagerStyle.cs
- DrawingGroup.cs
- Timer.cs
- DescendantBaseQuery.cs
- WorkflowWebService.cs
- EndpointAddress.cs
- MatrixUtil.cs
- ClockGroup.cs
- InstanceLockedException.cs
- ToolStripSeparatorRenderEventArgs.cs
- DataServiceResponse.cs
- MULTI_QI.cs
- DatatypeImplementation.cs
- StylusPointPropertyId.cs
- _AutoWebProxyScriptEngine.cs
- X509ChainPolicy.cs
- ProfileProvider.cs
- MulticastIPAddressInformationCollection.cs
- SolidColorBrush.cs
- GenericXmlSecurityToken.cs
- SqlDependencyListener.cs
- ObjectRef.cs
- FilteredAttributeCollection.cs
- ObjectItemCollectionAssemblyCacheEntry.cs
- SqlGatherProducedAliases.cs
- MapPathBasedVirtualPathProvider.cs
- InvokeMethodActivity.cs
- MachineKey.cs
- ContentElementAutomationPeer.cs
- EdmComplexPropertyAttribute.cs
- SolidColorBrush.cs
- ParameterToken.cs
- SizeAnimationBase.cs
- StructuredTypeInfo.cs
- NameTable.cs
- ChineseLunisolarCalendar.cs
- BindingExpression.cs
- OrthographicCamera.cs
- OutputCacheProfile.cs
- Help.cs
- Help.cs
- UnmanagedMemoryStream.cs
- VarRemapper.cs
- UIElementParagraph.cs
- TrackingMemoryStream.cs
- TranslateTransform.cs
- SoapSchemaMember.cs
- XmlArrayItemAttribute.cs
- BitmapPalette.cs
- ByteStorage.cs
- UserPreferenceChangingEventArgs.cs
- ServiceElementCollection.cs
- MarkupCompilePass1.cs
- SqlNotificationEventArgs.cs
- RoutedPropertyChangedEventArgs.cs
- MediaCommands.cs
- GridErrorDlg.cs
- RSACryptoServiceProvider.cs
- WsatRegistrationHeader.cs