Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / ndp / fx / src / DataEntity / System / Data / Metadata / Perspective.cs / 3 / Perspective.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....],[....] //--------------------------------------------------------------------- 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 the type with the given name in the target space /// /// full name of the type /// true for case-insensitive lookup /// TypeUsage for the type you are looking for ///returns true if a match is found, otherwise returns false internal abstract bool TryGetTypeByName(string fullName, bool ignoreCase, out TypeUsage typeUsage); ////// Returns the list of all the function with the given name /// /// name of the function /// namespace of the function /// whether to do a case-insensitive lookup or not ///internal System.Collections.ObjectModel.ReadOnlyCollection GetFunctions( string name, string namespaceName, bool ignoreCase) { EntityUtil.CheckStringArgument(name, "name"); EntityUtil.CheckStringArgument(namespaceName, "namespaceName"); string functionFullName = namespaceName + "." + name; System.Collections.ObjectModel.ReadOnlyCollection functionOverloads; // First lookup canonical functions EdmItemCollection edmItemCollection = (EdmItemCollection)m_metadataWorkspace.GetItemCollection(DataSpace.CSpace); functionOverloads = edmItemCollection.GetFunctions(functionFullName, ignoreCase); if (null == functionOverloads || 0 == functionOverloads.Count) { StoreItemCollection storeItemCollection = (StoreItemCollection)m_metadataWorkspace.GetItemCollection(DataSpace.SSpace); return storeItemCollection.GetCTypeFunctions(functionFullName, ignoreCase); } return functionOverloads; } /// /// 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 [....],[....] //--------------------------------------------------------------------- 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 the type with the given name in the target space /// /// full name of the type /// true for case-insensitive lookup /// TypeUsage for the type you are looking for ///returns true if a match is found, otherwise returns false internal abstract bool TryGetTypeByName(string fullName, bool ignoreCase, out TypeUsage typeUsage); ////// Returns the list of all the function with the given name /// /// name of the function /// namespace of the function /// whether to do a case-insensitive lookup or not ///internal System.Collections.ObjectModel.ReadOnlyCollection GetFunctions( string name, string namespaceName, bool ignoreCase) { EntityUtil.CheckStringArgument(name, "name"); EntityUtil.CheckStringArgument(namespaceName, "namespaceName"); string functionFullName = namespaceName + "." + name; System.Collections.ObjectModel.ReadOnlyCollection functionOverloads; // First lookup canonical functions EdmItemCollection edmItemCollection = (EdmItemCollection)m_metadataWorkspace.GetItemCollection(DataSpace.CSpace); functionOverloads = edmItemCollection.GetFunctions(functionFullName, ignoreCase); if (null == functionOverloads || 0 == functionOverloads.Count) { StoreItemCollection storeItemCollection = (StoreItemCollection)m_metadataWorkspace.GetItemCollection(DataSpace.SSpace); return storeItemCollection.GetCTypeFunctions(functionFullName, ignoreCase); } return functionOverloads; } /// /// 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
- SqlGenerator.cs
- StorageTypeMapping.cs
- GenericTextProperties.cs
- PointLightBase.cs
- CssStyleCollection.cs
- StrokeCollection.cs
- CompositeFontParser.cs
- GridViewPageEventArgs.cs
- DataGridViewCellFormattingEventArgs.cs
- WebBrowserEvent.cs
- DataRowChangeEvent.cs
- base64Transforms.cs
- SpecialTypeDataContract.cs
- EntityDataSourceDataSelection.cs
- Parser.cs
- WMIInterop.cs
- StateRuntime.cs
- EventData.cs
- PlainXmlSerializer.cs
- RightsManagementResourceHelper.cs
- ObjectHandle.cs
- XPathParser.cs
- CustomAttributeBuilder.cs
- TranslateTransform3D.cs
- Scene3D.cs
- HiddenField.cs
- PermissionSetEnumerator.cs
- DragEventArgs.cs
- ToolTipService.cs
- XamlUtilities.cs
- XmlSerializableReader.cs
- DocumentPageHost.cs
- StyleCollection.cs
- CRYPTPROTECT_PROMPTSTRUCT.cs
- ReturnType.cs
- CharUnicodeInfo.cs
- EntityDesignerUtils.cs
- Point3D.cs
- ThreadAttributes.cs
- SoapRpcServiceAttribute.cs
- Context.cs
- ListDictionaryInternal.cs
- CodeTypeConstructor.cs
- AssociationSetEnd.cs
- _ProxyChain.cs
- SetStateEventArgs.cs
- ContextInformation.cs
- FrameworkPropertyMetadata.cs
- ScrollBarRenderer.cs
- Configuration.cs
- TypeUnloadedException.cs
- SqlBulkCopy.cs
- EntityCollection.cs
- altserialization.cs
- ClientConfigurationHost.cs
- Authorization.cs
- StateChangeEvent.cs
- FontCacheUtil.cs
- WebCategoryAttribute.cs
- WindowsFormsHostPropertyMap.cs
- SQLBinaryStorage.cs
- ConsumerConnectionPointCollection.cs
- LongCountAggregationOperator.cs
- rsa.cs
- TemplateManager.cs
- TextStore.cs
- Monitor.cs
- ReadOnlyCollectionBase.cs
- odbcmetadatacolumnnames.cs
- WebPartMinimizeVerb.cs
- TemplateBuilder.cs
- TypeUtil.cs
- ErrorBehavior.cs
- GACMembershipCondition.cs
- InputLanguageEventArgs.cs
- DataGridParentRows.cs
- Page.cs
- FilterQuery.cs
- SocketStream.cs
- MenuTracker.cs
- ScriptingWebServicesSectionGroup.cs
- ComPlusInstanceProvider.cs
- MouseCaptureWithinProperty.cs
- TempEnvironment.cs
- DataGridViewRowHeaderCell.cs
- EntityDataSourceChangedEventArgs.cs
- VisualStyleElement.cs
- LabelLiteral.cs
- basecomparevalidator.cs
- DtrList.cs
- ProgressBar.cs
- CookieHandler.cs
- WebPartDisplayModeCollection.cs
- ScrollChrome.cs
- mediapermission.cs
- ModelPropertyCollectionImpl.cs
- HtmlElement.cs
- ArrayWithOffset.cs
- HttpException.cs
- PopupRoot.cs