示例#1
0
        internal CollectionValueMaterializationPolicy CreateCollectionValueMaterializationPolicy(IODataMaterializerContext materializerContext)
        {
            var lazyPrimitivePropertyConverter   = new DSClient.SimpleLazy <PrimitivePropertyConverter>(() => new PrimitivePropertyConverter());
            var primitiveValueMaterializerPolicy = new PrimitiveValueMaterializationPolicy(materializerContext, lazyPrimitivePropertyConverter);
            var collectionPolicy         = new CollectionValueMaterializationPolicy(materializerContext, primitiveValueMaterializerPolicy);
            var instanceAnnotationPolicy = new InstanceAnnotationMaterializationPolicy(materializerContext);

            collectionPolicy.InstanceAnnotationMaterializationPolicy = instanceAnnotationPolicy;

            return(collectionPolicy);
        }
        internal ComplexValueMaterializationPolicy CreatePrimitiveValueMaterializationPolicy(TestMaterializerContext context)
        {
            var lazyPrimitivePropertyConverter   = new DSClient.SimpleLazy <PrimitivePropertyConverter>(() => new PrimitivePropertyConverter(ODataFormat.Json));
            var primitiveValueMaterializerPolicy = new PrimitiveValueMaterializationPolicy(context, lazyPrimitivePropertyConverter);
            var complexPolicy           = new ComplexValueMaterializationPolicy(context, lazyPrimitivePropertyConverter);
            var collectionPolicy        = new CollectionValueMaterializationPolicy(context, primitiveValueMaterializerPolicy);
            var intanceAnnotationPolicy = new InstanceAnnotationMaterializationPolicy(context);

            collectionPolicy.ComplexValueMaterializationPolicy    = complexPolicy;
            complexPolicy.CollectionValueMaterializationPolicy    = collectionPolicy;
            complexPolicy.InstanceAnnotationMaterializationPolicy = intanceAnnotationPolicy;

            return(complexPolicy);
        }
示例#3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ODataMaterializer" /> class.
        /// </summary>
        /// <param name="materializerContext">The materializer context.</param>
        /// <param name="expectedType">The expected type.</param>
        protected ODataMaterializer(IODataMaterializerContext materializerContext, Type expectedType)
        {
            this.ExpectedType        = expectedType;
            this.MaterializerContext = materializerContext;
            this.nextLinkTable       = new Dictionary <IEnumerable, DataServiceQueryContinuation>(DSClient.ReferenceEqualityComparer <IEnumerable> .Instance);

            this.enumValueMaterializationPolicy          = new EnumValueMaterializationPolicy(this.MaterializerContext);
            this.lazyPrimitivePropertyConverter          = new DSClient.SimpleLazy <PrimitivePropertyConverter>(() => new PrimitivePropertyConverter());
            this.primitiveValueMaterializationPolicy     = new PrimitiveValueMaterializationPolicy(this.MaterializerContext, this.lazyPrimitivePropertyConverter);
            this.collectionValueMaterializationPolicy    = new CollectionValueMaterializationPolicy(this.MaterializerContext, this.primitiveValueMaterializationPolicy);
            this.instanceAnnotationMaterializationPolicy = new InstanceAnnotationMaterializationPolicy(this.MaterializerContext);
            this.collectionValueMaterializationPolicy.InstanceAnnotationMaterializationPolicy = this.instanceAnnotationMaterializationPolicy;
            this.instanceAnnotationMaterializationPolicy.CollectionValueMaterializationPolicy = this.collectionValueMaterializationPolicy;
            this.instanceAnnotationMaterializationPolicy.EnumValueMaterializationPolicy       = this.enumValueMaterializationPolicy;
        }
示例#4
0
        internal EntryValueMaterializationPolicy CreateEntryMaterializationPolicy(TestMaterializerContext materializerContext = null)
        {
            var clientEdmModel = new ClientEdmModel(ODataProtocolVersion.V4);
            var context        = new DataServiceContext();

            materializerContext = materializerContext ?? new TestMaterializerContext()
            {
                Model = clientEdmModel, Context = context
            };
            var adapter = new EntityTrackingAdapter(new TestEntityTracker(), MergeOption.OverwriteChanges, clientEdmModel, context);
            var lazyPrimitivePropertyConverter   = new Microsoft.OData.Client.SimpleLazy <PrimitivePropertyConverter>(() => new PrimitivePropertyConverter());
            var primitiveValueMaterializerPolicy = new PrimitiveValueMaterializationPolicy(materializerContext, lazyPrimitivePropertyConverter);
            var entryPolicy             = new EntryValueMaterializationPolicy(materializerContext, adapter, lazyPrimitivePropertyConverter, null);
            var collectionPolicy        = new CollectionValueMaterializationPolicy(materializerContext, primitiveValueMaterializerPolicy);
            var intanceAnnotationPolicy = new InstanceAnnotationMaterializationPolicy(materializerContext);

            entryPolicy.CollectionValueMaterializationPolicy    = collectionPolicy;
            entryPolicy.InstanceAnnotationMaterializationPolicy = intanceAnnotationPolicy;

            return(entryPolicy);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="CollectionValueMaterializationPolicy" /> class.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="primitivePolicy">The primitive policy.</param>
 internal CollectionValueMaterializationPolicy(IODataMaterializerContext context, PrimitiveValueMaterializationPolicy primitivePolicy)
 {
     this.materializerContext = context;
     this.primitiveValueMaterializationPolicy = primitivePolicy;
 }