Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- dataprotectionpermission.cs
- SplitterPanel.cs
- DataGridItemAutomationPeer.cs
- UIElementIsland.cs
- XPathNodeHelper.cs
- StoryFragments.cs
- NoClickablePointException.cs
- LoginView.cs
- RectAnimation.cs
- TdsParserStateObject.cs
- BehaviorEditorPart.cs
- XmlWrappingReader.cs
- HijriCalendar.cs
- ListViewCommandEventArgs.cs
- ItemChangedEventArgs.cs
- DesignerOptionService.cs
- NetPipeSectionData.cs
- _ScatterGatherBuffers.cs
- FontStyle.cs
- GPPOINTF.cs
- AssemblyResourceLoader.cs
- AbstractSvcMapFileLoader.cs
- RayMeshGeometry3DHitTestResult.cs
- FrameworkElement.cs
- RecognizerInfo.cs
- InfiniteTimeSpanConverter.cs
- ProfileSettingsCollection.cs
- RotateTransform.cs
- OutOfProcStateClientManager.cs
- XamlRtfConverter.cs
- WebPartConnectionsCancelVerb.cs
- DateTimeConstantAttribute.cs
- LookupNode.cs
- HttpTransportElement.cs
- DocumentViewerConstants.cs
- SystemIcmpV4Statistics.cs
- TileBrush.cs
- TraceUtils.cs
- TraceProvider.cs
- IdentityReference.cs
- ApplicationException.cs
- SafeWaitHandle.cs
- TextServicesCompartmentContext.cs
- Literal.cs
- ImageInfo.cs
- PropertyChangedEventArgs.cs
- PeerCustomResolverSettings.cs
- CodeGroup.cs
- HandlerFactoryCache.cs
- WeakHashtable.cs
- DbExpressionRules.cs
- TextPenaltyModule.cs
- SqlRewriteScalarSubqueries.cs
- AssociatedControlConverter.cs
- CheckBoxFlatAdapter.cs
- ISessionStateStore.cs
- InheritanceAttribute.cs
- HtmlInputFile.cs
- InfoCardRSAPKCS1SignatureFormatter.cs
- FullTextLine.cs
- CollectionViewGroupRoot.cs
- ScrollPattern.cs
- FacetDescription.cs
- WebPartMenu.cs
- WebBrowserNavigatedEventHandler.cs
- Membership.cs
- HScrollBar.cs
- ListMarkerSourceInfo.cs
- BigInt.cs
- PolicyUnit.cs
- DataSourceGroupCollection.cs
- DataColumn.cs
- XPSSignatureDefinition.cs
- SmuggledIUnknown.cs
- Int32Rect.cs
- UnsafeNativeMethods.cs
- Base64Decoder.cs
- ChildrenQuery.cs
- DataGridViewCell.cs
- EventData.cs
- XomlDesignerLoader.cs
- PeerEndPoint.cs
- RootBrowserWindow.cs
- X509KeyIdentifierClauseType.cs
- TextSchema.cs
- SystemDropShadowChrome.cs
- HttpGetServerProtocol.cs
- Bitmap.cs
- CompilerLocalReference.cs
- Splitter.cs
- ConfigurationException.cs
- TextBlockAutomationPeer.cs
- FlowchartDesigner.Helpers.cs
- MetadataArtifactLoaderResource.cs
- SignatureDescription.cs
- Interlocked.cs
- cookieexception.cs
- XpsColorContext.cs
- GrammarBuilderDictation.cs
- DataRowView.cs