Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / Metadata / Edm / Provider / ClrProviderManifest.cs / 1305376 / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- FixedDocumentSequencePaginator.cs
- XmlAutoDetectWriter.cs
- DiscriminatorMap.cs
- XamlFilter.cs
- NavigationProperty.cs
- EntityDataSourceWrapper.cs
- Composition.cs
- ConcurrentBag.cs
- ZoomPercentageConverter.cs
- DesignerFrame.cs
- OrderedDictionary.cs
- AvTraceFormat.cs
- GridViewItemAutomationPeer.cs
- DbProviderFactory.cs
- SoapObjectReader.cs
- _SSPIWrapper.cs
- DrawingCollection.cs
- GridToolTip.cs
- RecipientInfo.cs
- BindingCompleteEventArgs.cs
- NetTcpSecurityElement.cs
- BrowserCapabilitiesFactory.cs
- DetailsViewDeletedEventArgs.cs
- XPathExpr.cs
- RelatedCurrencyManager.cs
- ArraySortHelper.cs
- TrustSection.cs
- XmlSortKey.cs
- TreeViewHitTestInfo.cs
- Canvas.cs
- XmlSerializationGeneratedCode.cs
- GlobalAllocSafeHandle.cs
- ConnectionStringsExpressionEditor.cs
- ListView.cs
- PropertyKey.cs
- MenuItemCollection.cs
- SqlCacheDependency.cs
- InvokeGenerator.cs
- CalloutQueueItem.cs
- TreeNodeStyleCollection.cs
- Mutex.cs
- ResourceContainerWrapper.cs
- QuotedPrintableStream.cs
- FastEncoder.cs
- TdsEnums.cs
- QueryAccessibilityHelpEvent.cs
- SQLInt16Storage.cs
- MatrixCamera.cs
- SequentialWorkflowRootDesigner.cs
- FontDialog.cs
- CodeRegionDirective.cs
- SqlServer2KCompatibilityAnnotation.cs
- FontUnitConverter.cs
- TextTreeFixupNode.cs
- StrokeNode.cs
- CommandHelper.cs
- ControlValuePropertyAttribute.cs
- TextAnchor.cs
- TextReader.cs
- DropDownList.cs
- TextShapeableCharacters.cs
- System.Data.OracleClient_BID.cs
- ToolboxComponentsCreatingEventArgs.cs
- RemoteCryptoTokenProvider.cs
- SchemaImporterExtensionElementCollection.cs
- Int32Collection.cs
- IntSecurity.cs
- DataColumnPropertyDescriptor.cs
- DatatypeImplementation.cs
- HelpKeywordAttribute.cs
- DescendantOverDescendantQuery.cs
- Binding.cs
- Encoder.cs
- SerializationException.cs
- ContextMenu.cs
- PtsPage.cs
- DES.cs
- DataServiceRequestOfT.cs
- SQLInt16Storage.cs
- Table.cs
- FontStyleConverter.cs
- HtmlInputImage.cs
- DbParameterHelper.cs
- XmlCharacterData.cs
- SpecialFolderEnumConverter.cs
- ListCollectionView.cs
- _AutoWebProxyScriptEngine.cs
- FileReader.cs
- TextContainer.cs
- Odbc32.cs
- diagnosticsswitches.cs
- CustomErrorCollection.cs
- XmlSerializableWriter.cs
- UnconditionalPolicy.cs
- CopyOnWriteList.cs
- DoubleCollection.cs
- Win32MouseDevice.cs
- SqlRemoveConstantOrderBy.cs
- HttpCookie.cs
- WorkflowTimerService.cs