Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / ndp / fx / src / DataEntity / System / Data / Mapping / ObjectTypeMapping.cs / 2 / ObjectTypeMapping.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....], [....] //--------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Text; using System.Diagnostics; using System.Data.Metadata.Edm; using System.Data.Common.Utils; namespace System.Data.Mapping { ////// Represents the metadata for OCObjectMapping. /// internal class ObjectTypeMapping : Map { #region Constructors ////// Construct a new ObjectTypeMapping object /// /// /// internal ObjectTypeMapping(EdmType clrType, EdmType cdmType) { Debug.Assert(clrType.BuiltInTypeKind == cdmType.BuiltInTypeKind, "BuiltInTypeKind must be the same for both types"); this.m_clrType = clrType; this.m_cdmType = cdmType; identity = clrType.Identity + ObjectMslConstructs.IdentitySeperator + cdmType.Identity; if (Helper.IsStructuralType(cdmType)) { m_memberMapping = new Dictionary(((StructuralType)cdmType).Members.Count); } else { m_memberMapping = EmptyMemberMapping; } } #endregion #region Fields #region Internal private readonly EdmType m_clrType; //type on the Clr side that is being mapped private readonly EdmType m_cdmType; //type on the Cdm side that is being mapped private readonly string identity; private readonly Dictionary m_memberMapping; //Indexes into the member mappings collection based on clr member name private static readonly Dictionary EmptyMemberMapping = new Dictionary (0); #endregion #endregion #region Properties /// /// Gets the type kind for this item /// public override BuiltInTypeKind BuiltInTypeKind { get { return BuiltInTypeKind.MetadataItem; } } ////// The reference to the Clr type in Metadata /// that participates in this mapping instance /// internal EdmType ClrType { get { return this.m_clrType; } } ////// The reference to the Cdm type in Metadata /// that participates in this mapping instance /// internal override MetadataItem EdmItem { get { return this.EdmType; } } ////// The reference to the Cdm type in Metadata /// that participates in this mapping instance /// internal EdmType EdmType { get { return this.m_cdmType; } } ////// Returns the Identity of ObjectTypeMapping. /// The identity for an Object Type Map is the concatenation of /// CLR Type Idntity + ':' + CDM Type Identity /// internal override string Identity { get { return identity; } } #endregion #region Methods ////// get a MemberMap for the member name specified /// /// the name of the CDM member for which map needs to be retrieved internal ObjectPropertyMapping GetPropertyMap(String propertyName) { ObjectMemberMapping memberMapping = GetMemberMap(propertyName, false /*ignoreCase*/); if (memberMapping != null && memberMapping.MemberMappingKind == MemberMappingKind.ScalarPropertyMapping || memberMapping.MemberMappingKind == MemberMappingKind.ComplexPropertyMapping) { return (ObjectPropertyMapping)memberMapping; } return null; } ////// Add a member mapping as a child of this object mapping /// /// child property mapping to be added internal void AddMemberMap(ObjectMemberMapping memberMapping) { Debug.Assert(memberMapping.ClrMember.Name == memberMapping.EdmMember.Name, "Both clrmember and edmMember name must be the same"); //Check to see if either the Clr member or the Cdm member specified in this //type has already been mapped. Debug.Assert(!m_memberMapping.ContainsKey(memberMapping.EdmMember.Name)); Debug.Assert(!Type.ReferenceEquals(m_memberMapping, EmptyMemberMapping), "Make sure you don't add anything to the static emtpy member mapping"); m_memberMapping.Add(memberMapping.EdmMember.Name, memberMapping); } ////// Returns the member map for the given clr member /// /// /// ///internal ObjectMemberMapping GetMemberMapForClrMember(string clrMemberName, bool ignoreCase) { return GetMemberMap(clrMemberName, ignoreCase); } /// /// returns the member mapping for the given member /// /// /// ///private ObjectMemberMapping GetMemberMap(string propertyName, bool ignoreCase) { EntityUtil.CheckStringArgument(propertyName, "propertyName"); ObjectMemberMapping memberMapping = null; if (!ignoreCase) { //First get the index of the member map from the clr indexs m_memberMapping.TryGetValue(propertyName, out memberMapping); } else { foreach (KeyValuePair keyValuePair in m_memberMapping) { if (keyValuePair.Key.Equals(propertyName, StringComparison.OrdinalIgnoreCase)) { if (memberMapping != null) { throw new MappingException(System.Data.Entity.Strings.Mapping_Duplicate_PropertyMap_CaseInsensitive( propertyName)); } memberMapping = keyValuePair.Value; } } } return memberMapping; } /// /// Overriding System.Object.ToString to provide better String representation /// for this type. /// public override string ToString() { return this.Identity; } #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....], [....] //--------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Text; using System.Diagnostics; using System.Data.Metadata.Edm; using System.Data.Common.Utils; namespace System.Data.Mapping { ////// Represents the metadata for OCObjectMapping. /// internal class ObjectTypeMapping : Map { #region Constructors ////// Construct a new ObjectTypeMapping object /// /// /// internal ObjectTypeMapping(EdmType clrType, EdmType cdmType) { Debug.Assert(clrType.BuiltInTypeKind == cdmType.BuiltInTypeKind, "BuiltInTypeKind must be the same for both types"); this.m_clrType = clrType; this.m_cdmType = cdmType; identity = clrType.Identity + ObjectMslConstructs.IdentitySeperator + cdmType.Identity; if (Helper.IsStructuralType(cdmType)) { m_memberMapping = new Dictionary(((StructuralType)cdmType).Members.Count); } else { m_memberMapping = EmptyMemberMapping; } } #endregion #region Fields #region Internal private readonly EdmType m_clrType; //type on the Clr side that is being mapped private readonly EdmType m_cdmType; //type on the Cdm side that is being mapped private readonly string identity; private readonly Dictionary m_memberMapping; //Indexes into the member mappings collection based on clr member name private static readonly Dictionary EmptyMemberMapping = new Dictionary (0); #endregion #endregion #region Properties /// /// Gets the type kind for this item /// public override BuiltInTypeKind BuiltInTypeKind { get { return BuiltInTypeKind.MetadataItem; } } ////// The reference to the Clr type in Metadata /// that participates in this mapping instance /// internal EdmType ClrType { get { return this.m_clrType; } } ////// The reference to the Cdm type in Metadata /// that participates in this mapping instance /// internal override MetadataItem EdmItem { get { return this.EdmType; } } ////// The reference to the Cdm type in Metadata /// that participates in this mapping instance /// internal EdmType EdmType { get { return this.m_cdmType; } } ////// Returns the Identity of ObjectTypeMapping. /// The identity for an Object Type Map is the concatenation of /// CLR Type Idntity + ':' + CDM Type Identity /// internal override string Identity { get { return identity; } } #endregion #region Methods ////// get a MemberMap for the member name specified /// /// the name of the CDM member for which map needs to be retrieved internal ObjectPropertyMapping GetPropertyMap(String propertyName) { ObjectMemberMapping memberMapping = GetMemberMap(propertyName, false /*ignoreCase*/); if (memberMapping != null && memberMapping.MemberMappingKind == MemberMappingKind.ScalarPropertyMapping || memberMapping.MemberMappingKind == MemberMappingKind.ComplexPropertyMapping) { return (ObjectPropertyMapping)memberMapping; } return null; } ////// Add a member mapping as a child of this object mapping /// /// child property mapping to be added internal void AddMemberMap(ObjectMemberMapping memberMapping) { Debug.Assert(memberMapping.ClrMember.Name == memberMapping.EdmMember.Name, "Both clrmember and edmMember name must be the same"); //Check to see if either the Clr member or the Cdm member specified in this //type has already been mapped. Debug.Assert(!m_memberMapping.ContainsKey(memberMapping.EdmMember.Name)); Debug.Assert(!Type.ReferenceEquals(m_memberMapping, EmptyMemberMapping), "Make sure you don't add anything to the static emtpy member mapping"); m_memberMapping.Add(memberMapping.EdmMember.Name, memberMapping); } ////// Returns the member map for the given clr member /// /// /// ///internal ObjectMemberMapping GetMemberMapForClrMember(string clrMemberName, bool ignoreCase) { return GetMemberMap(clrMemberName, ignoreCase); } /// /// returns the member mapping for the given member /// /// /// ///private ObjectMemberMapping GetMemberMap(string propertyName, bool ignoreCase) { EntityUtil.CheckStringArgument(propertyName, "propertyName"); ObjectMemberMapping memberMapping = null; if (!ignoreCase) { //First get the index of the member map from the clr indexs m_memberMapping.TryGetValue(propertyName, out memberMapping); } else { foreach (KeyValuePair keyValuePair in m_memberMapping) { if (keyValuePair.Key.Equals(propertyName, StringComparison.OrdinalIgnoreCase)) { if (memberMapping != null) { throw new MappingException(System.Data.Entity.Strings.Mapping_Duplicate_PropertyMap_CaseInsensitive( propertyName)); } memberMapping = keyValuePair.Value; } } } return memberMapping; } /// /// Overriding System.Object.ToString to provide better String representation /// for this type. /// public override string ToString() { return this.Identity; } #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
- OrderedEnumerableRowCollection.cs
- VisualProxy.cs
- ContactManager.cs
- EncodingDataItem.cs
- OdbcConnectionString.cs
- XmlUnspecifiedAttribute.cs
- FormsAuthenticationModule.cs
- FrameworkName.cs
- ClientSideQueueItem.cs
- TypefaceCollection.cs
- BaseComponentEditor.cs
- wgx_sdk_version.cs
- TargetConverter.cs
- DoWorkEventArgs.cs
- ValidationErrorCollection.cs
- ScrollBarRenderer.cs
- AuthorizationPolicyTypeElement.cs
- WmlImageAdapter.cs
- IndividualDeviceConfig.cs
- EntityParameter.cs
- DataColumnPropertyDescriptor.cs
- RangeContentEnumerator.cs
- ConfigXmlAttribute.cs
- Stackframe.cs
- JpegBitmapDecoder.cs
- Win32NamedPipes.cs
- ProtocolsConfiguration.cs
- ListSortDescriptionCollection.cs
- MachineKey.cs
- SecurityTokenTypes.cs
- Merger.cs
- SpellCheck.cs
- TextDecoration.cs
- HttpCacheVary.cs
- AlignmentYValidation.cs
- ContextInformation.cs
- QilLoop.cs
- Rect3DConverter.cs
- WebConfigurationHost.cs
- DiscoveryClientReferences.cs
- RemoveStoryboard.cs
- MatrixAnimationBase.cs
- TextBoxBase.cs
- DataGridTextBoxColumn.cs
- Model3D.cs
- RemotingConfiguration.cs
- SerialPort.cs
- MultiDataTrigger.cs
- x509utils.cs
- ServiceErrorHandler.cs
- InputLanguageManager.cs
- NativeMethods.cs
- QuaternionValueSerializer.cs
- GridViewColumnHeaderAutomationPeer.cs
- StoreAnnotationsMap.cs
- LowerCaseStringConverter.cs
- CornerRadius.cs
- DataGridViewButtonColumn.cs
- PeerNode.cs
- RestClientProxyHandler.cs
- brushes.cs
- DetailsView.cs
- DataGridViewComboBoxColumn.cs
- DependencyObjectPropertyDescriptor.cs
- RangeEnumerable.cs
- AssemblyFilter.cs
- EventListener.cs
- CompensationExtension.cs
- AstNode.cs
- FtpWebResponse.cs
- SizeAnimationUsingKeyFrames.cs
- VisualTreeHelper.cs
- SqlErrorCollection.cs
- FilterableAttribute.cs
- EditorAttribute.cs
- DiscoveryDocumentSerializer.cs
- ProfilePropertyMetadata.cs
- DatagridviewDisplayedBandsData.cs
- EnumUnknown.cs
- _MultipleConnectAsync.cs
- BatchStream.cs
- PageRequestManager.cs
- XamlPathDataSerializer.cs
- SizeConverter.cs
- Rfc2898DeriveBytes.cs
- NotifyInputEventArgs.cs
- XmlBinaryWriterSession.cs
- MissingMemberException.cs
- CodeBinaryOperatorExpression.cs
- DbResourceAllocator.cs
- FieldAccessException.cs
- RepeaterCommandEventArgs.cs
- UniqueIdentifierService.cs
- IntegerValidatorAttribute.cs
- MetafileHeaderWmf.cs
- Vector3D.cs
- ConditionalAttribute.cs
- MimeTypeAttribute.cs
- QueryConverter.cs
- FileSecurity.cs