当前位置: 首页>>代码示例>>C#>>正文


C# Deserialization.ODataDeserializerProvider类代码示例

本文整理汇总了C#中System.Web.Http.OData.Formatter.Deserialization.ODataDeserializerProvider的典型用法代码示例。如果您正苦于以下问题:C# ODataDeserializerProvider类的具体用法?C# ODataDeserializerProvider怎么用?C# ODataDeserializerProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ODataDeserializerProvider类属于System.Web.Http.OData.Formatter.Deserialization命名空间,在下文中一共展示了ODataDeserializerProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ODataMediaTypeFormatter

        /// <summary>
        /// Initializes a new instance of the <see cref="ODataMediaTypeFormatter"/> class.
        /// </summary>
        /// <param name="deserializerProvider">The <see cref="ODataDeserializerProvider"/> to use.</param>
        /// <param name="serializerProvider">The <see cref="ODataSerializerProvider"/> to use.</param>
        /// <param name="payloadKinds">The kind of payloads this formatter supports.</param>
        public ODataMediaTypeFormatter(ODataDeserializerProvider deserializerProvider, ODataSerializerProvider serializerProvider,
            IEnumerable<ODataPayloadKind> payloadKinds)
        {
            if (deserializerProvider == null)
            {
                throw Error.ArgumentNull("deserializerProvider");
            }
            if (serializerProvider == null)
            {
                throw Error.ArgumentNull("serializerProvider");
            }
            if (payloadKinds == null)
            {
                throw Error.ArgumentNull("payloadKinds");
            }

            _deserializerProvider = deserializerProvider;
            _serializerProvider = serializerProvider;
            _payloadKinds = payloadKinds;

            // Maxing out the received message size as we depend on the hosting layer to enforce this limit.
            MessageWriterSettings = new ODataMessageWriterSettings
            {
                Indent = true,
                DisableMessageStreamDisposal = true,
                MessageQuotas = new ODataMessageQuotas { MaxReceivedMessageSize = Int64.MaxValue }
            };
            MessageReaderSettings = new ODataMessageReaderSettings
            {
                DisableMessageStreamDisposal = true,
                MessageQuotas = new ODataMessageQuotas { MaxReceivedMessageSize = Int64.MaxValue },
            };

            _version = DefaultODataVersion;
        }
开发者ID:sstrazan,项目名称:aspnetwebstack,代码行数:41,代码来源:ODataMediaTypeFormatter.cs

示例2: ApplyProperty

        internal static void ApplyProperty(ODataProperty property, IEdmStructuredTypeReference resourceType, object resource,
            ODataDeserializerProvider deserializerProvider, ODataDeserializerContext readContext)
        {
            IEdmProperty edmProperty = resourceType.FindProperty(property.Name);

            string propertyName = property.Name;
            IEdmTypeReference propertyType = edmProperty != null ? edmProperty.Type : null; // open properties have null values

            EdmTypeKind propertyKind;
            object value = ConvertValue(property.Value, ref propertyType, deserializerProvider, readContext, out propertyKind);

            if (propertyKind == EdmTypeKind.Collection)
            {
                SetCollectionProperty(resource, edmProperty, value);
            }
            else
            {
                if (propertyKind == EdmTypeKind.Primitive && !readContext.IsUntyped)
                {
                    value = EdmPrimitiveHelpers.ConvertPrimitiveValue(value, GetPropertyType(resource, propertyName));
                }

                SetProperty(resource, propertyName, value);
            }
        }
开发者ID:huangw-t,项目名称:aspnetwebstack,代码行数:25,代码来源:DeserializationHelpers.cs

示例3: CreateApplicationJson

        private static ODataMediaTypeFormatter CreateApplicationJson(ODataSerializerProvider serializerProvider, ODataDeserializerProvider deserializerProvider)
        {
            ODataMediaTypeFormatter formatter = CreateFormatterWithoutMediaTypes(
                serializerProvider,
                deserializerProvider,
                ODataPayloadKind.Feed,
                ODataPayloadKind.Entry,
                ODataPayloadKind.Property,
                ODataPayloadKind.EntityReferenceLink,
                ODataPayloadKind.EntityReferenceLinks,
                ODataPayloadKind.Collection,
                ODataPayloadKind.ServiceDocument,
                ODataPayloadKind.Error,
                ODataPayloadKind.Parameter);

            // Add minimal metadata as the first media type so it gets used when the request doesn't
            // ask for a specific content type
            formatter.SupportedMediaTypes.Add(ODataMediaTypes.ApplicationJsonODataMinimalMetadataStreamingTrue);
            formatter.SupportedMediaTypes.Add(ODataMediaTypes.ApplicationJsonODataMinimalMetadataStreamingFalse);
            formatter.SupportedMediaTypes.Add(ODataMediaTypes.ApplicationJsonODataMinimalMetadata);
            formatter.SupportedMediaTypes.Add(ODataMediaTypes.ApplicationJsonODataFullMetadataStreamingTrue);
            formatter.SupportedMediaTypes.Add(ODataMediaTypes.ApplicationJsonODataFullMetadataStreamingFalse);
            formatter.SupportedMediaTypes.Add(ODataMediaTypes.ApplicationJsonODataFullMetadata);
            formatter.SupportedMediaTypes.Add(ODataMediaTypes.ApplicationJsonODataNoMetadataStreamingTrue);
            formatter.SupportedMediaTypes.Add(ODataMediaTypes.ApplicationJsonODataNoMetadataStreamingFalse);
            formatter.SupportedMediaTypes.Add(ODataMediaTypes.ApplicationJsonODataNoMetadata);
            formatter.SupportedMediaTypes.Add(ODataMediaTypes.ApplicationJsonODataVerbose);
            formatter.SupportedMediaTypes.Add(ODataMediaTypes.ApplicationJsonStreamingTrue);
            formatter.SupportedMediaTypes.Add(ODataMediaTypes.ApplicationJsonStreamingFalse);
            formatter.SupportedMediaTypes.Add(ODataMediaTypes.ApplicationJson);
            return formatter;
        }
开发者ID:Rhombulus,项目名称:aspnetwebstack,代码行数:32,代码来源:ODataMediaTypeFormatters.cs

示例4: CreateRawValue

 private static ODataMediaTypeFormatter CreateRawValue(ODataSerializerProvider serializerProvider, ODataDeserializerProvider deserializerProvider)
 {
     ODataMediaTypeFormatter formatter = CreateFormatterWithoutMediaTypes(serializerProvider, deserializerProvider, ODataPayloadKind.Value);
     formatter.MediaTypeMappings.Add(new ODataPrimitiveValueMediaTypeMapping());
     formatter.MediaTypeMappings.Add(new ODataBinaryValueMediaTypeMapping());
     return formatter;
 }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:7,代码来源:ODataMediaTypeFormatters.cs

示例5: ApplyProperty

        internal static void ApplyProperty(ODataProperty property, IEdmStructuredTypeReference resourceType, object resource, ODataDeserializerProvider deserializerProvider, ODataDeserializerContext readContext)
        {
            IEdmProperty edmProperty = resourceType.FindProperty(property.Name);

            string propertyName = property.Name;
            IEdmTypeReference propertyType = edmProperty != null ? edmProperty.Type : null; // open properties have null values

            // If we are in patch mode and we are deserializing an entity object then we are updating Delta<T> and not T.
            bool isDelta = readContext.IsPatchMode && resourceType.IsEntity();

            EdmTypeKind propertyKind;
            object value = ConvertValue(property.Value, ref propertyType, deserializerProvider, readContext, out propertyKind);

            if (propertyKind == EdmTypeKind.Collection)
            {
                SetCollectionProperty(resource, propertyName, isDelta, value);
            }
            else
            {
                if (propertyKind == EdmTypeKind.Primitive)
                {
                    value = EdmPrimitiveHelpers.ConvertPrimitiveValue(value, GetPropertyType(resource, propertyName, isDelta));
                }

                SetProperty(resource, propertyName, isDelta, value);
            }
        }
开发者ID:naulizzang,项目名称:aspnetwebstack,代码行数:27,代码来源:ODataEntryDeserializer.cs

示例6: CreateApplicationAtomXmlTypeFeed

 private static ODataMediaTypeFormatter CreateApplicationAtomXmlTypeFeed(ODataSerializerProvider serializerProvider, ODataDeserializerProvider deserializerProvider)
 {
     ODataMediaTypeFormatter formatter = CreateFormatterWithoutMediaTypes(serializerProvider, deserializerProvider, ODataPayloadKind.Feed);
     formatter.SupportedMediaTypes.Add(ODataMediaTypes.ApplicationAtomXmlTypeFeed);
     formatter.SupportedMediaTypes.Add(ODataMediaTypes.ApplicationAtomXml);
     return formatter;
 }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:7,代码来源:ODataMediaTypeFormatters.cs

示例7: ODataActionPayloadDeserializer

 public ODataActionPayloadDeserializer(Type payloadType, ODataDeserializerProvider provider)
     : base(ODataPayloadKind.Parameter)
 {
     Contract.Assert(payloadType != null);
     Contract.Assert(provider != null);
     _payloadType = payloadType;
     _provider = provider;
 }
开发者ID:marojeri,项目名称:aspnetwebstack,代码行数:8,代码来源:ODataActionPayloadDeserializer.cs

示例8: CreateApplicationAtomSvcXml

        private static ODataMediaTypeFormatter CreateApplicationAtomSvcXml(ODataSerializerProvider serializerProvider, ODataDeserializerProvider deserializerProvider)
        {
            ODataMediaTypeFormatter formatter = CreateFormatterWithoutMediaTypes(serializerProvider, deserializerProvider, ODataPayloadKind.ServiceDocument);
            formatter.SupportedMediaTypes.Add(ODataMediaTypes.ApplicationAtomSvcXml);

            formatter.AddDollarFormatQueryStringMappings();

            return formatter;
        }
开发者ID:quentez,项目名称:aspnetwebstack,代码行数:9,代码来源:ODataMediaTypeFormatters.cs

示例9: ODataEdmTypeDeserializer

        /// <summary>
        /// Initializes a new instance of the <see cref="ODataEdmTypeDeserializer"/> class.
        /// </summary>
        /// <param name="payloadKind">The kind of OData payload this deserializer handles.</param>
        /// <param name="deserializerProvider">The <see cref="ODataDeserializerProvider"/>.</param>
        protected ODataEdmTypeDeserializer(ODataPayloadKind payloadKind, ODataDeserializerProvider deserializerProvider)
            : this(payloadKind)
        {
            if (deserializerProvider == null)
            {
                throw Error.ArgumentNull("deserializerProvider");
            }

            DeserializerProvider = deserializerProvider;
        }
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:15,代码来源:ODataEdmTypeDeserializer.cs

示例10: ODataActionPayloadDeserializer

        /// <summary>
        /// Initializes a new instance of the <see cref="ODataActionPayloadDeserializer"/> class.
        /// </summary>
        /// <param name="deserializerProvider">The deserializer provider to use to read inner objects.</param>
        public ODataActionPayloadDeserializer(ODataDeserializerProvider deserializerProvider)
            : base(ODataPayloadKind.Parameter)
        {
            if (deserializerProvider == null)
            {
                throw Error.ArgumentNull("deserializerProvider");
            }

            DeserializerProvider = deserializerProvider;
        }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:14,代码来源:ODataActionPayloadDeserializer.cs

示例11: CreateApplicationAtomXmlTypeEntry

        private static ODataMediaTypeFormatter CreateApplicationAtomXmlTypeEntry(ODataSerializerProvider serializerProvider, ODataDeserializerProvider deserializerProvider)
        {
            ODataMediaTypeFormatter formatter = CreateFormatterWithoutMediaTypes(serializerProvider, deserializerProvider, ODataPayloadKind.Entry);
            formatter.SupportedMediaTypes.Add(ODataMediaTypes.ApplicationAtomXmlTypeEntry);
            formatter.SupportedMediaTypes.Add(ODataMediaTypes.ApplicationAtomXml);

            formatter.AddDollarFormatQueryStringMappings();
            formatter.AddQueryStringMapping(DollarFormat, AtomFormat, ODataMediaTypes.ApplicationAtomXml);

            return formatter;
        }
开发者ID:quentez,项目名称:aspnetwebstack,代码行数:11,代码来源:ODataMediaTypeFormatters.cs

示例12: ODataFeedDeserializer

        /// <summary>
        /// Initializes a new instance of the <see cref="ODataFeedDeserializer"/> class.
        /// </summary>
        /// <param name="edmType">The entity collection type that this deserializer can read.</param>
        /// <param name="deserializerProvider">The deserializer provider to use to read inner objects.</param>
        public ODataFeedDeserializer(IEdmCollectionTypeReference edmType, ODataDeserializerProvider deserializerProvider)
            : base(edmType, ODataPayloadKind.Feed, deserializerProvider)
        {
            CollectionType = edmType;
            if (!edmType.ElementType().IsEntity())
            {
                throw Error.Argument("edmType", SRResources.TypeMustBeEntityCollection, edmType.ElementType().FullName(), typeof(IEdmEntityType).Name);
            }

            EntityType = CollectionType.ElementType().AsEntity();
        }
开发者ID:RhysC,项目名称:aspnetwebstack,代码行数:16,代码来源:ODataFeedDeserializer.cs

示例13: ODataMediaTypeFormatter

        internal ODataMediaTypeFormatter(ODataDeserializerProvider oDataDeserializerProvider, ODataSerializerProvider oDataSerializerProvider)
        {
            ODataDeserializerProvider = oDataDeserializerProvider;
            Model = oDataDeserializerProvider.EdmModel;
            ODataSerializerProvider = oDataSerializerProvider;

            SupportedMediaTypes.Add(ODataFormatterConstants.ApplicationAtomXmlMediaType);
            SupportedMediaTypes.Add(ODataFormatterConstants.ApplicationJsonMediaType);
            SupportedMediaTypes.Add(ODataFormatterConstants.ApplicationXmlMediaType);

            SupportedEncodings.Add(new UnicodeEncoding(bigEndian: false, byteOrderMark: true, throwOnInvalidBytes: true));
            SupportedEncodings.Add(new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true));
        }
开发者ID:mikevpeters,项目名称:aspnetwebstack,代码行数:13,代码来源:ODataMediaTypeFormatter.cs

示例14: ODataEntityDeserializerTests

 public ODataEntityDeserializerTests()
 {
     _edmModel = EdmTestHelpers.GetModel();
     IEdmEntitySet entitySet = _edmModel.EntityContainers().Single().FindEntitySet("Products");
     _readContext = new ODataDeserializerContext
     {
         Path = new ODataPath(new EntitySetPathSegment(entitySet)),
         Model = _edmModel
     };
     _productEdmType = _edmModel.GetEdmTypeReference(typeof(Product)).AsEntity();
     _supplierEdmType = _edmModel.GetEdmTypeReference(typeof(Supplier)).AsEntity();
     _deserializerProvider = new DefaultODataDeserializerProvider();
 }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:13,代码来源:ODataEntityDeserializerTests.cs

示例15: Create

 /// <summary>
 /// Creates a list of media type formatters to handle OData.
 /// </summary>
 /// <param name="serializerProvider">The serializer provider to use.</param>
 /// <param name="deserializerProvider">The deserializer provider to use.</param>
 /// <returns>A list of media type formatters to handle OData.</returns>
 public static IList<ODataMediaTypeFormatter> Create(ODataSerializerProvider serializerProvider, ODataDeserializerProvider deserializerProvider)
 {
     return new List<ODataMediaTypeFormatter>()
     {
         // Create atomsvc+xml formatter first to handle service document requests without an Accept header in an XML format
         CreateApplicationAtomSvcXml(serializerProvider, deserializerProvider),
         // Create JSON formatter next so it gets used when the request doesn't ask for a specific content type
         CreateApplicationJson(serializerProvider, deserializerProvider),
         CreateApplicationAtomXmlTypeFeed(serializerProvider, deserializerProvider),
         CreateApplicationAtomXmlTypeEntry(serializerProvider, deserializerProvider),
         CreateApplicationXml(serializerProvider, deserializerProvider),
         CreateTextXml(serializerProvider, deserializerProvider)
     };
 }
开发者ID:Rhombulus,项目名称:aspnetwebstack,代码行数:20,代码来源:ODataMediaTypeFormatters.cs


注:本文中的System.Web.Http.OData.Formatter.Deserialization.ODataDeserializerProvider类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。