Ejemplo n.º 1
0
 private static void Validate(EpmSourcePathSegment pathSegment, ResourceType resourceType, Dictionary <ResourceType, IEnumerable <ResourceProperty> > declaredPropertiesLookup)
 {
     foreach (EpmSourcePathSegment segment in pathSegment.SubProperties)
     {
         ResourceType type = GetPropertyType(resourceType, segment.PropertyName, declaredPropertiesLookup);
         Validate(segment, type, declaredPropertiesLookup);
     }
 }
Ejemplo n.º 2
0
        internal void Add(EntityPropertyMappingInfo epmInfo, IEnumerable <ResourceProperty> declaredProperties)
        {
            Dictionary <ResourceType, IEnumerable <ResourceProperty> > declaredPropertiesLookup = new Dictionary <ResourceType, IEnumerable <ResourceProperty> >(EqualityComparer <ResourceType> .Default);

            declaredPropertiesLookup.Add(epmInfo.ActualPropertyType, declaredProperties);
            EpmSourcePathSegment root               = this.Root;
            EpmSourcePathSegment segment2           = null;
            ResourceType         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.Strings.EpmSourceTree_InvalidSourcePath(epmInfo.DefiningType.Name, epmInfo.Attribute.SourcePath));
                }
                actualPropertyType = GetPropertyType(actualPropertyType, propertyName, declaredPropertiesLookup);
                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) && (actualPropertyType.ResourceTypeKind != ResourceTypeKind.Primitive))
            {
                throw new InvalidOperationException(System.Data.Services.Strings.EpmSourceTree_EndsWithNonPrimitiveType(root.PropertyName));
            }
            if (segment2 != null)
            {
                if (segment2.EpmInfo.DefiningTypesAreEqual(epmInfo))
                {
                    throw new InvalidOperationException(System.Data.Services.Strings.EpmSourceTree_DuplicateEpmAttrsWithSameSourceName(epmInfo.Attribute.SourcePath, epmInfo.DefiningType.Name));
                }
                this.epmTargetTree.Remove(segment2.EpmInfo);
            }
            root.EpmInfo = epmInfo;
            this.epmTargetTree.Add(epmInfo);
        }
Ejemplo n.º 3
0
 internal void Add(EntityPropertyMappingInfo epmInfo, IEnumerable<ResourceProperty> declaredProperties)
 {
     Dictionary<ResourceType, IEnumerable<ResourceProperty>> declaredPropertiesLookup = new Dictionary<ResourceType, IEnumerable<ResourceProperty>>(EqualityComparer<ResourceType>.Default);
     declaredPropertiesLookup.Add(epmInfo.ActualPropertyType, declaredProperties);
     EpmSourcePathSegment root = this.Root;
     EpmSourcePathSegment segment2 = null;
     ResourceType 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.Strings.EpmSourceTree_InvalidSourcePath(epmInfo.DefiningType.Name, epmInfo.Attribute.SourcePath));
         }
         actualPropertyType = GetPropertyType(actualPropertyType, propertyName, declaredPropertiesLookup);
         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) && (actualPropertyType.ResourceTypeKind != ResourceTypeKind.Primitive))
     {
         throw new InvalidOperationException(System.Data.Services.Strings.EpmSourceTree_EndsWithNonPrimitiveType(root.PropertyName));
     }
     if (segment2 != null)
     {
         if (segment2.EpmInfo.DefiningTypesAreEqual(epmInfo))
         {
             throw new InvalidOperationException(System.Data.Services.Strings.EpmSourceTree_DuplicateEpmAttrsWithSameSourceName(epmInfo.Attribute.SourcePath, epmInfo.DefiningType.Name));
         }
         this.epmTargetTree.Remove(segment2.EpmInfo);
     }
     root.EpmInfo = epmInfo;
     this.epmTargetTree.Add(epmInfo);
 }
Ejemplo n.º 4
0
 private static void Validate(EpmSourcePathSegment pathSegment, ResourceType resourceType, Dictionary<ResourceType, IEnumerable<ResourceProperty>> declaredPropertiesLookup)
 {
     foreach (EpmSourcePathSegment segment in pathSegment.SubProperties)
     {
         ResourceType type = GetPropertyType(resourceType, segment.PropertyName, declaredPropertiesLookup);
         Validate(segment, type, declaredPropertiesLookup);
     }
 }