コード例 #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);
        }
コード例 #2
0
        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);
        }