Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / ndp / fx / src / DataEntity / System / Data / Common / internal / materialization / util.cs / 1 / util.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- using System.Data.Metadata.Edm; using System.Data.Mapping; namespace System.Data.Common.Internal.Materialization { static class Util { ////// Retrieves a mapping to CLR type for the given EDM type. Assumes the MetadataWorkspace has no /// internal static ObjectTypeMapping GetObjectMapping(EdmType type, MetadataWorkspace workspace) { // Check if the workspace has cspace item collection registered with it. If not, then its a case // of public materializer trying to create objects from PODR or EntityDataReader with no context. ItemCollection collection; if (workspace.TryGetItemCollection(DataSpace.CSpace, out collection)) { return (ObjectTypeMapping)workspace.GetMap(type, DataSpace.OCSpace); } else { EdmType ospaceType; EdmType cspaceType; // If its a case of EntityDataReader with no context, the typeUsage which is passed in must contain // a cspace type. We need to look up an OSpace type in the ospace item collection and then create // ocMapping if (type.DataSpace == DataSpace.CSpace) { // if its a primitive type, then the names will be different for CSpace type and OSpace type if (Helper.IsPrimitiveType(type)) { ospaceType = workspace.GetMappedPrimitiveType(((PrimitiveType)type).PrimitiveTypeKind, DataSpace.OSpace); } else { // Metadata will throw if there is no item with this identity present. // Is this exception fine or does object materializer code wants to wrap and throw a new exception ospaceType = workspace.GetItem(type.FullName, DataSpace.OSpace); } cspaceType = type; } else { // In case of PODR, there is no cspace at all. We must create a fake ocmapping, with ospace types // on both the ends ospaceType = type; cspaceType = type; } // This condition must be hit only when someone is trying to materialize a legacy data reader and we // don't have the CSpace metadata. if (!Helper.IsPrimitiveType(ospaceType) && !Helper.IsEntityType(ospaceType) && !Helper.IsComplexType(ospaceType)) { throw EntityUtil.MaterializerUnsupportedType(); } ObjectTypeMapping typeMapping; if (Helper.IsPrimitiveType(ospaceType)) { typeMapping = new ObjectTypeMapping(ospaceType, cspaceType); } else { typeMapping = DefaultObjectMappingItemCollection.LoadObjectMapping(cspaceType, ospaceType, null); } return typeMapping; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- using System.Data.Metadata.Edm; using System.Data.Mapping; namespace System.Data.Common.Internal.Materialization { static class Util { ////// Retrieves a mapping to CLR type for the given EDM type. Assumes the MetadataWorkspace has no /// internal static ObjectTypeMapping GetObjectMapping(EdmType type, MetadataWorkspace workspace) { // Check if the workspace has cspace item collection registered with it. If not, then its a case // of public materializer trying to create objects from PODR or EntityDataReader with no context. ItemCollection collection; if (workspace.TryGetItemCollection(DataSpace.CSpace, out collection)) { return (ObjectTypeMapping)workspace.GetMap(type, DataSpace.OCSpace); } else { EdmType ospaceType; EdmType cspaceType; // If its a case of EntityDataReader with no context, the typeUsage which is passed in must contain // a cspace type. We need to look up an OSpace type in the ospace item collection and then create // ocMapping if (type.DataSpace == DataSpace.CSpace) { // if its a primitive type, then the names will be different for CSpace type and OSpace type if (Helper.IsPrimitiveType(type)) { ospaceType = workspace.GetMappedPrimitiveType(((PrimitiveType)type).PrimitiveTypeKind, DataSpace.OSpace); } else { // Metadata will throw if there is no item with this identity present. // Is this exception fine or does object materializer code wants to wrap and throw a new exception ospaceType = workspace.GetItem(type.FullName, DataSpace.OSpace); } cspaceType = type; } else { // In case of PODR, there is no cspace at all. We must create a fake ocmapping, with ospace types // on both the ends ospaceType = type; cspaceType = type; } // This condition must be hit only when someone is trying to materialize a legacy data reader and we // don't have the CSpace metadata. if (!Helper.IsPrimitiveType(ospaceType) && !Helper.IsEntityType(ospaceType) && !Helper.IsComplexType(ospaceType)) { throw EntityUtil.MaterializerUnsupportedType(); } ObjectTypeMapping typeMapping; if (Helper.IsPrimitiveType(ospaceType)) { typeMapping = new ObjectTypeMapping(ospaceType, cspaceType); } else { typeMapping = DefaultObjectMappingItemCollection.LoadObjectMapping(cspaceType, ospaceType, null); } return typeMapping; } } } } // 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
- FullTextState.cs
- WindowsTitleBar.cs
- IDataContractSurrogate.cs
- DeviceContext2.cs
- DataRecordInternal.cs
- StandardMenuStripVerb.cs
- Maps.cs
- regiisutil.cs
- HttpModuleCollection.cs
- SqlParameter.cs
- DocumentCollection.cs
- FreezableCollection.cs
- DataGridViewComboBoxEditingControl.cs
- HttpDigestClientElement.cs
- ParameterDataSourceExpression.cs
- AssemblyInfo.cs
- GlobalizationSection.cs
- InternalCache.cs
- EntityDataSourceDesignerHelper.cs
- ExceptionHandlerDesigner.cs
- OleDbTransaction.cs
- ConnectorEditor.cs
- ExpressionReplacer.cs
- HelpOperationInvoker.cs
- StreamWriter.cs
- XmlSerializerNamespaces.cs
- CollectionBuilder.cs
- LogExtentCollection.cs
- CodeNamespaceImport.cs
- ExpandableObjectConverter.cs
- HTMLTextWriter.cs
- ISFClipboardData.cs
- InvokeMethod.cs
- CuspData.cs
- FontInfo.cs
- HwndStylusInputProvider.cs
- XmlWriterSettings.cs
- ViewSimplifier.cs
- DatatypeImplementation.cs
- SQLByte.cs
- CachedFontFace.cs
- SignatureHelper.cs
- SchemaLookupTable.cs
- XmlSignatureProperties.cs
- SequenceRange.cs
- UpdateTracker.cs
- SignedXml.cs
- NotifyParentPropertyAttribute.cs
- DataTableTypeConverter.cs
- EventToken.cs
- TextTreeText.cs
- PageAsyncTaskManager.cs
- Parameter.cs
- ListItemCollection.cs
- OpenTypeMethods.cs
- ConfigurationFileMap.cs
- RelationshipType.cs
- OperationContractGenerationContext.cs
- MessageSecurityVersion.cs
- ObjectViewFactory.cs
- ListBindingConverter.cs
- EntityDataSourceUtil.cs
- TemplateEditingFrame.cs
- PropertyChangedEventManager.cs
- ClientSettingsStore.cs
- CompilationPass2Task.cs
- SchemaMerger.cs
- FocusChangedEventArgs.cs
- UnhandledExceptionEventArgs.cs
- KeyEvent.cs
- _ListenerResponseStream.cs
- Composition.cs
- FunctionNode.cs
- PreviewPrintController.cs
- ImageFormat.cs
- PlacementWorkspace.cs
- PolicyManager.cs
- SourceCollection.cs
- ContentPresenter.cs
- PropertyGrid.cs
- XPathQilFactory.cs
- TextTreeRootTextBlock.cs
- EntityObject.cs
- TriggerAction.cs
- HMACRIPEMD160.cs
- Crc32Helper.cs
- Label.cs
- ConnectionsZone.cs
- DataGridColumnHeaderItemAutomationPeer.cs
- fixedPageContentExtractor.cs
- PathSegmentCollection.cs
- RequestCache.cs
- DecoderReplacementFallback.cs
- ObjectSet.cs
- WebContext.cs
- XmlUTF8TextWriter.cs
- HttpResponseInternalWrapper.cs
- TemplateKey.cs
- AuthStoreRoleProvider.cs
- SettingsAttributes.cs