Ejemplo n.º 1
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;
        }
Ejemplo n.º 2
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.Format));
            this.primitiveValueMaterializationPolicy = new PrimitiveValueMaterializationPolicy(this.MaterializerContext, this.lazyPrimitivePropertyConverter);
            this.collectionValueMaterializationPolicy = new CollectionValueMaterializationPolicy(this.MaterializerContext, this.primitiveValueMaterializationPolicy);
            this.complexValueMaterializerPolicy = new ComplexValueMaterializationPolicy(this.MaterializerContext, this.lazyPrimitivePropertyConverter);
            this.instanceAnnotationMaterializationPolicy = new InstanceAnnotationMaterializationPolicy(this.MaterializerContext);
            this.collectionValueMaterializationPolicy.ComplexValueMaterializationPolicy = this.complexValueMaterializerPolicy;
            this.collectionValueMaterializationPolicy.InstanceAnnotationMaterializationPolicy = this.instanceAnnotationMaterializationPolicy;
            this.complexValueMaterializerPolicy.CollectionValueMaterializationPolicy = this.collectionValueMaterializationPolicy;
            this.complexValueMaterializerPolicy.InstanceAnnotationMaterializationPolicy = this.instanceAnnotationMaterializationPolicy;
            this.instanceAnnotationMaterializationPolicy.ComplexValueMaterializationPolicy = this.complexValueMaterializerPolicy;
            this.instanceAnnotationMaterializationPolicy.CollectionValueMaterializationPolicy = this.collectionValueMaterializationPolicy;
            this.instanceAnnotationMaterializationPolicy.EnumValueMaterializationPolicy = this.enumValueMaterializationPolicy;
        }
        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;
        }