本文整理汇总了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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例7: ODataActionPayloadDeserializer
public ODataActionPayloadDeserializer(Type payloadType, ODataDeserializerProvider provider)
: base(ODataPayloadKind.Parameter)
{
Contract.Assert(payloadType != null);
Contract.Assert(provider != null);
_payloadType = payloadType;
_provider = provider;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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));
}
示例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();
}
示例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)
};
}