Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataWeb / Server / System / Data / Services / Epm / EpmSourceTree.cs / 1305376 / EpmSourceTree.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // //// Tree for managing SourceNames on EntityPropertyMappingAttributes // for a ResourceType. // // // @owner [....] //--------------------------------------------------------------------- namespace System.Data.Services.Common { using System.Collections.Generic; using System.Diagnostics; using System.Linq; #if ASTORIA_CLIENT using System.Data.Services.Client; #else using System.Data.Services; #endif ////// Tree representing the sourceName properties in all the EntityPropertyMappingAttributes for a resource type /// internal sealed class EpmSourceTree { #region Fields ///Root of the tree private readonly EpmSourcePathSegment root; ///private readonly EpmTargetTree epmTargetTree; #endregion /// corresponding to this tree Default constructor creates a null root /// Target xml tree internal EpmSourceTree(EpmTargetTree epmTargetTree) { this.root = new EpmSourcePathSegment(""); this.epmTargetTree = epmTargetTree; } #region Properties ////// Root of the tree /// internal EpmSourcePathSegment Root { get { return this.root; } } #endregion ////// Adds a path to the source and target tree which is obtained by looking at the EntityPropertyMappingAttribute in the /// EnitityPropertyMappingInfo holding the source path internal void Add(EntityPropertyMappingInfo epmInfo) { String sourceName = epmInfo.Attribute.SourcePath; EpmSourcePathSegment currentProperty = this.Root; IList/// activeSubProperties = currentProperty.SubProperties; EpmSourcePathSegment foundProperty = null; Debug.Assert(!String.IsNullOrEmpty(sourceName), "Must have been validated during EntityPropertyMappingAttribute construction"); foreach (String propertyName in sourceName.Split('/')) { if (propertyName.Length == 0) { throw new InvalidOperationException(Strings.EpmSourceTree_InvalidSourcePath(epmInfo.DefiningType.Name, sourceName)); } foundProperty = activeSubProperties.SingleOrDefault(e => e.PropertyName == propertyName); if (foundProperty != null) { currentProperty = foundProperty; } else { currentProperty = new EpmSourcePathSegment(propertyName); activeSubProperties.Add(currentProperty); } activeSubProperties = currentProperty.SubProperties; } // Two EpmAttributes with same PropertyName in the same ResourceType, this could be a result of inheritance if (foundProperty != null) { Debug.Assert(Object.ReferenceEquals(foundProperty, currentProperty), "currentProperty variable should have been updated already to foundProperty"); // Check for duplicates on the same entity type #if !ASTORIA_CLIENT Debug.Assert(foundProperty.SubProperties.Count == 0, "If non-leaf, it means we allowed complex type to be a leaf node"); if (foundProperty.EpmInfo.DefiningType == epmInfo.DefiningType) { throw new InvalidOperationException(Strings.EpmSourceTree_DuplicateEpmAttrsWithSameSourceName(epmInfo.Attribute.SourcePath, epmInfo.DefiningType.Name)); } #else if (foundProperty.EpmInfo.DefiningType.Name == epmInfo.DefiningType.Name) { throw new InvalidOperationException(Strings.EpmSourceTree_DuplicateEpmAttrsWithSameSourceName(epmInfo.Attribute.SourcePath, epmInfo.DefiningType.Name)); } #endif // In case of inheritance, we need to remove the node from target tree which was mapped to base type property this.epmTargetTree.Remove(foundProperty.EpmInfo); } currentProperty.EpmInfo = epmInfo; this.epmTargetTree.Add(epmInfo); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // //// Tree for managing SourceNames on EntityPropertyMappingAttributes // for a ResourceType. // // // @owner [....] //--------------------------------------------------------------------- namespace System.Data.Services.Common { using System.Collections.Generic; using System.Diagnostics; using System.Linq; #if ASTORIA_CLIENT using System.Data.Services.Client; #else using System.Data.Services; #endif ////// Tree representing the sourceName properties in all the EntityPropertyMappingAttributes for a resource type /// internal sealed class EpmSourceTree { #region Fields ///Root of the tree private readonly EpmSourcePathSegment root; ///private readonly EpmTargetTree epmTargetTree; #endregion /// corresponding to this tree Default constructor creates a null root /// Target xml tree internal EpmSourceTree(EpmTargetTree epmTargetTree) { this.root = new EpmSourcePathSegment(""); this.epmTargetTree = epmTargetTree; } #region Properties ////// Root of the tree /// internal EpmSourcePathSegment Root { get { return this.root; } } #endregion ////// Adds a path to the source and target tree which is obtained by looking at the EntityPropertyMappingAttribute in the /// EnitityPropertyMappingInfo holding the source path internal void Add(EntityPropertyMappingInfo epmInfo) { String sourceName = epmInfo.Attribute.SourcePath; EpmSourcePathSegment currentProperty = this.Root; IList/// activeSubProperties = currentProperty.SubProperties; EpmSourcePathSegment foundProperty = null; Debug.Assert(!String.IsNullOrEmpty(sourceName), "Must have been validated during EntityPropertyMappingAttribute construction"); foreach (String propertyName in sourceName.Split('/')) { if (propertyName.Length == 0) { throw new InvalidOperationException(Strings.EpmSourceTree_InvalidSourcePath(epmInfo.DefiningType.Name, sourceName)); } foundProperty = activeSubProperties.SingleOrDefault(e => e.PropertyName == propertyName); if (foundProperty != null) { currentProperty = foundProperty; } else { currentProperty = new EpmSourcePathSegment(propertyName); activeSubProperties.Add(currentProperty); } activeSubProperties = currentProperty.SubProperties; } // Two EpmAttributes with same PropertyName in the same ResourceType, this could be a result of inheritance if (foundProperty != null) { Debug.Assert(Object.ReferenceEquals(foundProperty, currentProperty), "currentProperty variable should have been updated already to foundProperty"); // Check for duplicates on the same entity type #if !ASTORIA_CLIENT Debug.Assert(foundProperty.SubProperties.Count == 0, "If non-leaf, it means we allowed complex type to be a leaf node"); if (foundProperty.EpmInfo.DefiningType == epmInfo.DefiningType) { throw new InvalidOperationException(Strings.EpmSourceTree_DuplicateEpmAttrsWithSameSourceName(epmInfo.Attribute.SourcePath, epmInfo.DefiningType.Name)); } #else if (foundProperty.EpmInfo.DefiningType.Name == epmInfo.DefiningType.Name) { throw new InvalidOperationException(Strings.EpmSourceTree_DuplicateEpmAttrsWithSameSourceName(epmInfo.Attribute.SourcePath, epmInfo.DefiningType.Name)); } #endif // In case of inheritance, we need to remove the node from target tree which was mapped to base type property this.epmTargetTree.Remove(foundProperty.EpmInfo); } currentProperty.EpmInfo = epmInfo; this.epmTargetTree.Add(epmInfo); } } } // 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
- ParseChildrenAsPropertiesAttribute.cs
- figurelengthconverter.cs
- PreviewPageInfo.cs
- ImageMap.cs
- ScriptResourceDefinition.cs
- UpdatePanelControlTrigger.cs
- CacheDependency.cs
- ParallelEnumerableWrapper.cs
- TcpTransportSecurityElement.cs
- wgx_render.cs
- ComponentCommands.cs
- DbProviderSpecificTypePropertyAttribute.cs
- AuthenticationConfig.cs
- DataGridRow.cs
- VectorCollection.cs
- QueryOpcode.cs
- Metafile.cs
- ToolStripTextBox.cs
- CompilationRelaxations.cs
- DrawingServices.cs
- Geometry.cs
- X509Certificate2Collection.cs
- CodeAccessSecurityEngine.cs
- StringAnimationBase.cs
- ConstructorArgumentAttribute.cs
- ValueType.cs
- ProcessStartInfo.cs
- Camera.cs
- InfoCardConstants.cs
- EditorZone.cs
- ScriptReferenceEventArgs.cs
- SingleObjectCollection.cs
- PageParser.cs
- ArrayWithOffset.cs
- XPathParser.cs
- HScrollBar.cs
- Literal.cs
- XmlHierarchyData.cs
- FontDriver.cs
- AssemblyCache.cs
- TabletDevice.cs
- URIFormatException.cs
- SelectionPattern.cs
- MachineKeyConverter.cs
- HttpRequestCacheValidator.cs
- InvokeMethodActivity.cs
- TypeInitializationException.cs
- Logging.cs
- BaseConfigurationRecord.cs
- QueryGeneratorBase.cs
- PointAnimationBase.cs
- WindowsStatusBar.cs
- OleDbInfoMessageEvent.cs
- MethodExpr.cs
- TemplatePropertyEntry.cs
- Constant.cs
- TreeNode.cs
- ExpressionEditorSheet.cs
- URL.cs
- Int32RectConverter.cs
- HttpFormatExtensions.cs
- HuffModule.cs
- ReflectEventDescriptor.cs
- RegionIterator.cs
- EndOfStreamException.cs
- VideoDrawing.cs
- EnvironmentPermission.cs
- StyleBamlTreeBuilder.cs
- HtmlMeta.cs
- SqlDataReaderSmi.cs
- ListViewInsertedEventArgs.cs
- BooleanFunctions.cs
- PostBackOptions.cs
- DragEvent.cs
- PtsCache.cs
- OverflowException.cs
- AccessedThroughPropertyAttribute.cs
- ClosableStream.cs
- ErrorWrapper.cs
- __TransparentProxy.cs
- AnnotationAdorner.cs
- RawStylusInputCustomData.cs
- TypedDatasetGenerator.cs
- XmlJsonReader.cs
- EntitySqlQueryState.cs
- __FastResourceComparer.cs
- NumberFunctions.cs
- IndentedWriter.cs
- XmlReflectionImporter.cs
- MembershipSection.cs
- DefaultMemberAttribute.cs
- EntityUtil.cs
- EventWaitHandle.cs
- KeyToListMap.cs
- X509Chain.cs
- TraceSwitch.cs
- SspiWrapper.cs
- TableItemPatternIdentifiers.cs
- ToolboxItemFilterAttribute.cs
- webeventbuffer.cs