private static string GetPropertyNameFromEpmInfo(EntityPropertyMappingInfo epmInfo) { if (epmInfo.Attribute.TargetSyndicationItem == SyndicationItemProperty.CustomProperty) { return(epmInfo.Attribute.TargetPath); } return(epmInfo.Attribute.TargetSyndicationItem.ToString()); }
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)); } }
internal void Add(EntityPropertyMappingInfo epmInfo) { EpmSourcePathSegment root = this.Root; EpmSourcePathSegment segment2 = null; ClientTypeAnnotation actualPropertyType = epmInfo.ActualPropertyType; for (int i = 0; i < epmInfo.PropertyValuePath.Length; i++) { string propertyName = epmInfo.PropertyValuePath[i]; if (propertyName.Length == 0) { throw new InvalidOperationException(System.Data.Services.Client.Strings.EpmSourceTree_InvalidSourcePath(epmInfo.DefiningType.Name, epmInfo.Attribute.SourcePath)); } actualPropertyType = GetPropertyType(actualPropertyType, propertyName); segment2 = root.SubProperties.SingleOrDefault <EpmSourcePathSegment>(e => e.PropertyName == propertyName); if (segment2 != null) { root = segment2; } else { EpmSourcePathSegment item = new EpmSourcePathSegment(propertyName); root.SubProperties.Add(item); root = item; } } if ((actualPropertyType != null) && !PrimitiveType.IsKnownNullableType(actualPropertyType.ElementType)) { throw new InvalidOperationException(System.Data.Services.Client.Strings.EpmSourceTree_EndsWithNonPrimitiveType(root.PropertyName)); } if (segment2 != null) { if (segment2.EpmInfo.DefiningTypesAreEqual(epmInfo)) { throw new InvalidOperationException(System.Data.Services.Client.Strings.EpmSourceTree_DuplicateEpmAttrsWithSameSourceName(epmInfo.Attribute.SourcePath, epmInfo.DefiningType.Name)); } this.epmTargetTree.Remove(segment2.EpmInfo); } root.EpmInfo = epmInfo; this.epmTargetTree.Add(epmInfo); }
internal void Add(EntityPropertyMappingInfo epmInfo) { EpmSourcePathSegment root = this.Root; EpmSourcePathSegment segment2 = null; ClientTypeAnnotation actualPropertyType = epmInfo.ActualPropertyType; for (int i = 0; i < epmInfo.PropertyValuePath.Length; i++) { string propertyName = epmInfo.PropertyValuePath[i]; if (propertyName.Length == 0) { throw new InvalidOperationException(System.Data.Services.Client.Strings.EpmSourceTree_InvalidSourcePath(epmInfo.DefiningType.Name, epmInfo.Attribute.SourcePath)); } actualPropertyType = GetPropertyType(actualPropertyType, propertyName); segment2 = root.SubProperties.SingleOrDefault<EpmSourcePathSegment>(e => e.PropertyName == propertyName); if (segment2 != null) { root = segment2; } else { EpmSourcePathSegment item = new EpmSourcePathSegment(propertyName); root.SubProperties.Add(item); root = item; } } if ((actualPropertyType != null) && !PrimitiveType.IsKnownNullableType(actualPropertyType.ElementType)) { throw new InvalidOperationException(System.Data.Services.Client.Strings.EpmSourceTree_EndsWithNonPrimitiveType(root.PropertyName)); } if (segment2 != null) { if (segment2.EpmInfo.DefiningTypesAreEqual(epmInfo)) { throw new InvalidOperationException(System.Data.Services.Client.Strings.EpmSourceTree_DuplicateEpmAttrsWithSameSourceName(epmInfo.Attribute.SourcePath, epmInfo.DefiningType.Name)); } this.epmTargetTree.Remove(segment2.EpmInfo); } root.EpmInfo = epmInfo; this.epmTargetTree.Add(epmInfo); }
internal bool DefiningTypesAreEqual(EntityPropertyMappingInfo other) { return(this.DefiningType == other.DefiningType); }
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)); } }