Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / Metadata / Perspective.cs / 1305376 / Perspective.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System.Diagnostics; namespace System.Data.Metadata.Edm { using System.Collections.Generic; ////// Internal helper class for query /// internal abstract class Perspective { #region Constructors ////// Creates a new instance of perspective class so that query can work /// ignorant of all spaces /// /// runtime metadata container /// target dataspace for the perspective internal Perspective(MetadataWorkspace metadataWorkspace, DataSpace targetDataspace) { EntityUtil.CheckArgumentNull(metadataWorkspace, "metadataWorkspace"); m_metadataWorkspace = metadataWorkspace; m_targetDataspace = targetDataspace; } #endregion #region Fields private MetadataWorkspace m_metadataWorkspace; private DataSpace m_targetDataspace; #endregion #region Methods ////// Given the type in the target space and the member name in the source space, /// get the corresponding member in the target space /// For e.g. consider a Conceptual Type 'Foo' with a member 'Bar' and a CLR type /// 'XFoo' with a member 'YBar'. If one has a reference to Foo one can /// invoke GetMember(Foo,"YBar") to retrieve the member metadata for bar /// /// The type in the target perspective /// the name of the member in the source perspective /// Whether to do case-sensitive member look up or not /// returns the member in target space, if a match is found ///internal virtual bool TryGetMember(StructuralType type, String memberName, bool ignoreCase, out EdmMember outMember) { EntityUtil.CheckArgumentNull(type, "type"); EntityUtil.CheckStringArgument(memberName, "memberName"); outMember = null; // If a normal member is not present, check for navigation property with that name return type.Members.TryGetValue(memberName, ignoreCase, out outMember); } /// /// Returns the extent in the target space, for the given entity container /// /// name of the entity container in target space /// name of the extent /// Whether to do case-sensitive member look up or not /// extent in target space, if a match is found ///returns true, if a match is found otherwise returns false internal bool TryGetExtent(EntityContainer entityContainer, String extentName, bool ignoreCase, out EntitySetBase outSet) { // There are no entity container and extents in the OSpace. So there is no mapping // involved. Hence the name should be a valid name in the CSpace. return entityContainer.BaseEntitySets.TryGetValue(extentName, ignoreCase, out outSet); } ////// Get the default entity container /// returns null for any perspective other /// than the CLR perspective /// ///The default container internal virtual EntityContainer GetDefaultContainer() { return null; } ////// Get an entity container based upon the strong name of the container /// If no entity container is found, returns null, else returns the first one/// /// name of the entity container /// true for case-insensitive lookup /// returns the entity container if a match is found ///returns true if a match is found, otherwise false internal virtual bool TryGetEntityContainer(string name, bool ignoreCase, out EntityContainer entityContainer) { return MetadataWorkspace.TryGetEntityContainer(name, ignoreCase, TargetDataspace, out entityContainer); } ////// Gets a type with the given name in the target space. /// /// full name of the type /// true for case-insensitive lookup /// TypeUsage for the type ///returns true if a match was found, otherwise false internal abstract bool TryGetTypeByName(string fullName, bool ignoreCase, out TypeUsage typeUsage); ////// Returns overloads of a function with the given name in the target space. /// /// full name of the function /// true for case-insensitive lookup /// function overloads ///returns true if a match was found, otherwise false internal bool TryGetFunctionByName(string fullName, bool ignoreCase, out IListfunctionOverloads) { EntityUtil.CheckStringArgument(fullName, "fullName"); // First look in CSpace EdmItemCollection edmItemCollection = (EdmItemCollection)m_metadataWorkspace.GetItemCollection(DataSpace.CSpace); var overloads = edmItemCollection.GetFunctions(fullName, ignoreCase); // If CSpace lookup failed, look in SSpace if (overloads == null || overloads.Count == 0) { ItemCollection storeItemCollection; if (m_metadataWorkspace.TryGetItemCollection(DataSpace.SSpace, out storeItemCollection)) { overloads = ((StoreItemCollection)storeItemCollection).GetCTypeFunctions(fullName, ignoreCase); } } functionOverloads = (overloads != null && overloads.Count > 0) ? overloads : null; return functionOverloads != null; } /// /// Return the metadata workspace /// internal MetadataWorkspace MetadataWorkspace { get { return m_metadataWorkspace; } } ////// returns the primitive type for a given primitive type kind. /// /// /// ///internal virtual bool TryGetMappedPrimitiveType(PrimitiveTypeKind primitiveTypeKind, out PrimitiveType primitiveType) { primitiveType = m_metadataWorkspace.GetMappedPrimitiveType(primitiveTypeKind, DataSpace.CSpace); return (null != primitiveType); } // // This property will be needed to construct keys for transient types // /// /// Returns the target dataspace for this perspective /// internal DataSpace TargetDataspace { get { return m_targetDataspace; } } #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System.Diagnostics; namespace System.Data.Metadata.Edm { using System.Collections.Generic; ////// Internal helper class for query /// internal abstract class Perspective { #region Constructors ////// Creates a new instance of perspective class so that query can work /// ignorant of all spaces /// /// runtime metadata container /// target dataspace for the perspective internal Perspective(MetadataWorkspace metadataWorkspace, DataSpace targetDataspace) { EntityUtil.CheckArgumentNull(metadataWorkspace, "metadataWorkspace"); m_metadataWorkspace = metadataWorkspace; m_targetDataspace = targetDataspace; } #endregion #region Fields private MetadataWorkspace m_metadataWorkspace; private DataSpace m_targetDataspace; #endregion #region Methods ////// Given the type in the target space and the member name in the source space, /// get the corresponding member in the target space /// For e.g. consider a Conceptual Type 'Foo' with a member 'Bar' and a CLR type /// 'XFoo' with a member 'YBar'. If one has a reference to Foo one can /// invoke GetMember(Foo,"YBar") to retrieve the member metadata for bar /// /// The type in the target perspective /// the name of the member in the source perspective /// Whether to do case-sensitive member look up or not /// returns the member in target space, if a match is found ///internal virtual bool TryGetMember(StructuralType type, String memberName, bool ignoreCase, out EdmMember outMember) { EntityUtil.CheckArgumentNull(type, "type"); EntityUtil.CheckStringArgument(memberName, "memberName"); outMember = null; // If a normal member is not present, check for navigation property with that name return type.Members.TryGetValue(memberName, ignoreCase, out outMember); } /// /// Returns the extent in the target space, for the given entity container /// /// name of the entity container in target space /// name of the extent /// Whether to do case-sensitive member look up or not /// extent in target space, if a match is found ///returns true, if a match is found otherwise returns false internal bool TryGetExtent(EntityContainer entityContainer, String extentName, bool ignoreCase, out EntitySetBase outSet) { // There are no entity container and extents in the OSpace. So there is no mapping // involved. Hence the name should be a valid name in the CSpace. return entityContainer.BaseEntitySets.TryGetValue(extentName, ignoreCase, out outSet); } ////// Get the default entity container /// returns null for any perspective other /// than the CLR perspective /// ///The default container internal virtual EntityContainer GetDefaultContainer() { return null; } ////// Get an entity container based upon the strong name of the container /// If no entity container is found, returns null, else returns the first one/// /// name of the entity container /// true for case-insensitive lookup /// returns the entity container if a match is found ///returns true if a match is found, otherwise false internal virtual bool TryGetEntityContainer(string name, bool ignoreCase, out EntityContainer entityContainer) { return MetadataWorkspace.TryGetEntityContainer(name, ignoreCase, TargetDataspace, out entityContainer); } ////// Gets a type with the given name in the target space. /// /// full name of the type /// true for case-insensitive lookup /// TypeUsage for the type ///returns true if a match was found, otherwise false internal abstract bool TryGetTypeByName(string fullName, bool ignoreCase, out TypeUsage typeUsage); ////// Returns overloads of a function with the given name in the target space. /// /// full name of the function /// true for case-insensitive lookup /// function overloads ///returns true if a match was found, otherwise false internal bool TryGetFunctionByName(string fullName, bool ignoreCase, out IListfunctionOverloads) { EntityUtil.CheckStringArgument(fullName, "fullName"); // First look in CSpace EdmItemCollection edmItemCollection = (EdmItemCollection)m_metadataWorkspace.GetItemCollection(DataSpace.CSpace); var overloads = edmItemCollection.GetFunctions(fullName, ignoreCase); // If CSpace lookup failed, look in SSpace if (overloads == null || overloads.Count == 0) { ItemCollection storeItemCollection; if (m_metadataWorkspace.TryGetItemCollection(DataSpace.SSpace, out storeItemCollection)) { overloads = ((StoreItemCollection)storeItemCollection).GetCTypeFunctions(fullName, ignoreCase); } } functionOverloads = (overloads != null && overloads.Count > 0) ? overloads : null; return functionOverloads != null; } /// /// Return the metadata workspace /// internal MetadataWorkspace MetadataWorkspace { get { return m_metadataWorkspace; } } ////// returns the primitive type for a given primitive type kind. /// /// /// ///internal virtual bool TryGetMappedPrimitiveType(PrimitiveTypeKind primitiveTypeKind, out PrimitiveType primitiveType) { primitiveType = m_metadataWorkspace.GetMappedPrimitiveType(primitiveTypeKind, DataSpace.CSpace); return (null != primitiveType); } // // This property will be needed to construct keys for transient types // /// /// Returns the target dataspace for this perspective /// internal DataSpace TargetDataspace { get { return m_targetDataspace; } } #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
- ScopeElementCollection.cs
- ResourceIDHelper.cs
- Transactions.cs
- TranslateTransform3D.cs
- RuntimeCompatibilityAttribute.cs
- XpsThumbnail.cs
- LinkLabel.cs
- PointAnimationClockResource.cs
- FormParameter.cs
- recordstatescratchpad.cs
- TreeView.cs
- Enum.cs
- Point3D.cs
- Math.cs
- PresentationAppDomainManager.cs
- SqlServer2KCompatibilityCheck.cs
- CfgParser.cs
- FileNotFoundException.cs
- VirtualizingPanel.cs
- BlobPersonalizationState.cs
- RegisteredArrayDeclaration.cs
- WriteTimeStream.cs
- UnsafeMethods.cs
- CompoundFileIOPermission.cs
- Geometry3D.cs
- SudsParser.cs
- ScrollChrome.cs
- ConnectionsZoneDesigner.cs
- GridLength.cs
- VarRefManager.cs
- MissingFieldException.cs
- ExpressionCopier.cs
- CryptoStream.cs
- serverconfig.cs
- ReflectionUtil.cs
- VersionedStreamOwner.cs
- PrePrepareMethodAttribute.cs
- DoubleAnimationClockResource.cs
- PreviewPrintController.cs
- TextDecoration.cs
- DataGridViewCellStyleConverter.cs
- HttpHeaderCollection.cs
- CustomBindingElementCollection.cs
- VisualStateChangedEventArgs.cs
- EqualityComparer.cs
- TPLETWProvider.cs
- FixUpCollection.cs
- BitmapCodecInfoInternal.cs
- ObjectAssociationEndMapping.cs
- ClientSettingsStore.cs
- ZoneIdentityPermission.cs
- httpstaticobjectscollection.cs
- MimeTypeAttribute.cs
- StringFunctions.cs
- FileDialog_Vista_Interop.cs
- BinaryObjectWriter.cs
- DelegateHelpers.cs
- Int32AnimationBase.cs
- LabelEditEvent.cs
- CompositionTarget.cs
- Restrictions.cs
- ExpressionBuilderCollection.cs
- DataViewSettingCollection.cs
- UriSectionData.cs
- DataTablePropertyDescriptor.cs
- EncoderParameter.cs
- MimeTypeAttribute.cs
- FreeFormDragDropManager.cs
- Message.cs
- EventLogPropertySelector.cs
- ZipIOExtraFieldPaddingElement.cs
- BaseConfigurationRecord.cs
- DataView.cs
- NullableConverter.cs
- basemetadatamappingvisitor.cs
- System.Data_BID.cs
- DbCommandTree.cs
- EntityDesignerDataSourceView.cs
- DataBoundControlAdapter.cs
- DrawingContextWalker.cs
- SettingsAttributeDictionary.cs
- GenericTypeParameterBuilder.cs
- NestPullup.cs
- ConfigXmlComment.cs
- CrossContextChannel.cs
- ControlParser.cs
- ProfileSettings.cs
- LayoutEvent.cs
- OutputScopeManager.cs
- DataGridPageChangedEventArgs.cs
- QueueProcessor.cs
- ExtendedTransformFactory.cs
- DoubleAnimationBase.cs
- Matrix.cs
- PageContent.cs
- TextEndOfParagraph.cs
- BitmapEffectGroup.cs
- TransformConverter.cs
- MultiBinding.cs
- PageTheme.cs