Esempio n. 1
0
 private void InitializeAndBuildTree()
 {
     lock (this.epmDataLock)
     {
         if (this.EpmNeedsInitializing)
         {
             System.Data.Services.Client.Serializers.EpmTargetTree epmTargetTree = new System.Data.Services.Client.Serializers.EpmTargetTree();
             System.Data.Services.Client.Serializers.EpmSourceTree sourceTree    = new System.Data.Services.Client.Serializers.EpmSourceTree(epmTargetTree);
             BuildEpmInfo(this.clientTypeAnnotation, sourceTree);
             sourceTree.Validate(this.clientTypeAnnotation);
             this.epmTargetTree = epmTargetTree;
             this.epmSourceTree = sourceTree;
         }
     }
 }
Esempio n. 2
0
 private void InitializeAndBuildTree()
 {
     lock (this.epmDataLock)
     {
         if (this.EpmNeedsInitializing)
         {
             System.Data.Services.Client.Serializers.EpmTargetTree epmTargetTree = new System.Data.Services.Client.Serializers.EpmTargetTree();
             System.Data.Services.Client.Serializers.EpmSourceTree sourceTree = new System.Data.Services.Client.Serializers.EpmSourceTree(epmTargetTree);
             BuildEpmInfo(this.clientTypeAnnotation, sourceTree);
             sourceTree.Validate(this.clientTypeAnnotation);
             this.epmTargetTree = epmTargetTree;
             this.epmSourceTree = sourceTree;
         }
     }
 }
Esempio n. 3
0
 private static void BuildEpmInfo(Type type, ClientTypeAnnotation clientTypeAnnotation, System.Data.Services.Client.Serializers.EpmSourceTree sourceTree)
 {
     if (clientTypeAnnotation.IsEntityType)
     {
         Func <EntityPropertyMappingAttribute, bool> predicate = null;
         Type baseType = type.BaseType;
         ClientTypeAnnotation annotation = null;
         ClientEdmModel       model      = ClientEdmModel.GetModel(clientTypeAnnotation.MaxProtocolVersion);
         ODataEntityPropertyMappingCollection mappings = null;
         if ((baseType != null) && (baseType != typeof(object)))
         {
             if (((EdmStructuredType)clientTypeAnnotation.EdmType).BaseType == null)
             {
                 BuildEpmInfo(baseType, clientTypeAnnotation, sourceTree);
                 mappings = model.GetAnnotationValue <ODataEntityPropertyMappingCollection>(clientTypeAnnotation.EdmType);
             }
             else
             {
                 annotation = model.GetClientTypeAnnotation(baseType);
                 BuildEpmInfo(baseType, annotation, sourceTree);
             }
         }
         foreach (EntityPropertyMappingAttribute attribute in type.GetCustomAttributes(typeof(EntityPropertyMappingAttribute), false))
         {
             BuildEpmInfo(attribute, type, clientTypeAnnotation, sourceTree);
             if (mappings == null)
             {
                 mappings = new ODataEntityPropertyMappingCollection();
             }
             mappings.Add(attribute);
         }
         if (mappings != null)
         {
             ODataEntityPropertyMappingCollection annotationValue = model.GetAnnotationValue <ODataEntityPropertyMappingCollection>(clientTypeAnnotation.EdmType);
             if (annotationValue != null)
             {
                 if (predicate == null)
                 {
                     predicate = oldM => !mappings.Any <EntityPropertyMappingAttribute>(newM => (oldM.SourcePath == newM.SourcePath));
                 }
                 foreach (EntityPropertyMappingAttribute attribute2 in annotationValue.Where <EntityPropertyMappingAttribute>(predicate).ToList <EntityPropertyMappingAttribute>())
                 {
                     mappings.Add(attribute2);
                 }
             }
             model.SetAnnotationValue <ODataEntityPropertyMappingCollection>(clientTypeAnnotation.EdmType, mappings);
         }
     }
 }
Esempio n. 4
0
 private static void BuildEpmInfo(EntityPropertyMappingAttribute epmAttr, Type definingType, ClientTypeAnnotation clientTypeAnnotation, System.Data.Services.Client.Serializers.EpmSourceTree sourceTree)
 {
     sourceTree.Add(new System.Data.Services.Client.Serializers.EntityPropertyMappingInfo(epmAttr, definingType, clientTypeAnnotation));
 }
Esempio n. 5
0
 private static void BuildEpmInfo(ClientTypeAnnotation clientTypeAnnotation, System.Data.Services.Client.Serializers.EpmSourceTree sourceTree)
 {
     BuildEpmInfo(clientTypeAnnotation.ElementType, clientTypeAnnotation, sourceTree);
 }