internal void Remove(EntityPropertyMappingInfo epmInfo) { string targetPath = epmInfo.Attribute.TargetPath; string namespaceUri = epmInfo.Attribute.TargetNamespaceUri; EpmTargetPathSegment item = epmInfo.IsSyndicationMapping ? this.SyndicationRoot : this.NonSyndicationRoot; List <EpmTargetPathSegment> subSegments = item.SubSegments; string[] strArray = targetPath.Split(new char[] { '/' }); for (int i = 0; i < strArray.Length; i++) { string targetSegment = strArray[i]; EpmTargetPathSegment segment2 = subSegments.FirstOrDefault <EpmTargetPathSegment>(delegate(EpmTargetPathSegment segment) { if (!(segment.SegmentName == targetSegment)) { return(false); } if (!epmInfo.IsSyndicationMapping) { return(segment.SegmentNamespaceUri == namespaceUri); } return(true); }); if (segment2 != null) { item = segment2; } else { return; } subSegments = item.SubSegments; } if (item.EpmInfo != null) { if (!item.EpmInfo.Attribute.KeepInContent) { this.countOfNonContentV2mappings--; } EpmTargetPathSegment parentSegment = null; do { parentSegment = item.ParentSegment; parentSegment.SubSegments.Remove(item); item = parentSegment; }while (((item.ParentSegment != null) && !item.HasContent) && (item.SubSegments.Count == 0)); } }
private static bool HasMixedContent(EpmTargetPathSegment currentSegment, bool ancestorHasContent) { foreach (EpmTargetPathSegment segment in from s in currentSegment.SubSegments where !s.IsAttribute select s) { if (segment.HasContent && ancestorHasContent) { return(true); } if (HasMixedContent(segment, segment.HasContent || ancestorHasContent)) { return(true); } } return(false); }
internal EpmTargetPathSegment(string segmentName, string segmentNamespaceUri, EpmTargetPathSegment parentSegment) : this() { this.segmentName = segmentName; this.segmentNamespaceUri = segmentNamespaceUri; this.parentSegment = parentSegment; }
internal void Add(EntityPropertyMappingInfo epmInfo) { string targetPath = epmInfo.Attribute.TargetPath; string namespaceUri = epmInfo.Attribute.TargetNamespaceUri; EpmTargetPathSegment parentSegment = epmInfo.IsSyndicationMapping ? this.SyndicationRoot : this.NonSyndicationRoot; IList <EpmTargetPathSegment> subSegments = parentSegment.SubSegments; string[] strArray = targetPath.Split(new char[] { '/' }); EpmTargetPathSegment segment2 = null; for (int i = 0; i < strArray.Length; i++) { string targetSegment = strArray[i]; if (targetSegment.Length == 0) { throw new InvalidOperationException(System.Data.Services.Client.Strings.EpmTargetTree_InvalidTargetPath(targetPath)); } if ((targetSegment[0] == '@') && (i != (strArray.Length - 1))) { throw new InvalidOperationException(System.Data.Services.Client.Strings.EpmTargetTree_AttributeInMiddle(targetSegment)); } segment2 = subSegments.SingleOrDefault <EpmTargetPathSegment>(delegate(EpmTargetPathSegment segment) { if (!(segment.SegmentName == targetSegment)) { return(false); } if (!epmInfo.IsSyndicationMapping) { return(segment.SegmentNamespaceUri == namespaceUri); } return(true); }); if (segment2 != null) { parentSegment = segment2; } else { parentSegment = new EpmTargetPathSegment(targetSegment, namespaceUri, parentSegment); if (targetSegment[0] == '@') { subSegments.Insert(0, parentSegment); } else { subSegments.Add(parentSegment); } } subSegments = parentSegment.SubSegments; } if (parentSegment.EpmInfo != null) { throw new ArgumentException(System.Data.Services.Client.Strings.EpmTargetTree_DuplicateEpmAttrsWithSameTargetName(GetPropertyNameFromEpmInfo(parentSegment.EpmInfo), parentSegment.EpmInfo.DefiningType.Name, parentSegment.EpmInfo.Attribute.SourcePath, epmInfo.Attribute.SourcePath)); } if (!epmInfo.Attribute.KeepInContent) { this.countOfNonContentV2mappings++; } parentSegment.EpmInfo = epmInfo; if (HasMixedContent(this.NonSyndicationRoot, false)) { throw new InvalidOperationException(System.Data.Services.Client.Strings.EpmTargetTree_InvalidTargetPath(targetPath)); } }