/// <summary>Initializes a new instance of the <see cref="T:Microsoft.OData.Core.ODataMessageReaderSettings" /> class with default values.</summary> public ODataMessageReaderSettings() : base() { this.DisablePrimitiveTypeConversion = false; this.DisableMessageStreamDisposal = false; this.UndeclaredPropertyBehaviorKinds = ODataUndeclaredPropertyBehaviorKinds.None; // Create the default reader behavior this.readerBehavior = ODataReaderBehavior.DefaultBehavior; this.MaxProtocolVersion = ODataConstants.ODataDefaultProtocolVersion; this.EnableFullValidation = true; }
/// <summary>Initializes a new instance of the <see cref="T:Microsoft.OData.Core.ODataMessageReaderSettings" /> class.</summary> /// <param name="other">The other message reader settings.</param> public ODataMessageReaderSettings(ODataMessageReaderSettings other) : base(other) { ExceptionUtils.CheckArgumentNotNull(other, "other"); this.BaseUri = other.BaseUri; this.DisableMessageStreamDisposal = other.DisableMessageStreamDisposal; this.DisablePrimitiveTypeConversion = other.DisablePrimitiveTypeConversion; this.UndeclaredPropertyBehaviorKinds = other.UndeclaredPropertyBehaviorKinds; this.MaxProtocolVersion = other.MaxProtocolVersion; // NOTE: reader behavior is immutable; copy by reference is ok. this.readerBehavior = other.ReaderBehavior; this.EnableAtom = other.EnableAtom; this.EnableFullValidation = other.EnableFullValidation; }
/// <summary>Initializes a new instance of the <see cref="T:Microsoft.OData.Core.ODataMessageReaderSettings" /> class.</summary> /// <param name="other">The other message reader settings.</param> public ODataMessageReaderSettings(ODataMessageReaderSettings other) : base(other) { ExceptionUtils.CheckArgumentNotNull(other, "other"); this.BaseUri = other.BaseUri; this.DisableMessageStreamDisposal = other.DisableMessageStreamDisposal; this.DisablePrimitiveTypeConversion = other.DisablePrimitiveTypeConversion; this.UndeclaredPropertyBehaviorKinds = other.UndeclaredPropertyBehaviorKinds; this.MaxProtocolVersion = other.MaxProtocolVersion; // NOTE: reader behavior is immutable; copy by reference is ok. this.readerBehavior = other.ReaderBehavior; this.EnableAtom = other.EnableAtom; this.EnableFullValidation = other.EnableFullValidation; this.UseKeyAsSegment = other.UseKeyAsSegment; this.mediaTypeResolver = other.mediaTypeResolver; this.ODataSimplified = other.ODataSimplified; }
/// <summary> /// Resolved the payload type name to the type. /// </summary> /// <param name="model">The model to use for the resolution.</param> /// <param name="expectedTypeReference">The expected type reference, or null if no expected type is available.</param> /// <param name="payloadTypeName">The payload type name to resolve.</param> /// <param name="expectedTypeKind">The default payload type kind, this is used when the resolution is not possible, /// but the type name is not empty. (Should be either Complex or Entity).</param> /// <param name="readerBehavior">Reader behavior to use for compatibility.</param> /// <param name="payloadTypeKind">This is set to the detected payload type kind, or None if the type was not specified.</param> /// <returns>The resolved type. This may be null if either no user-specified model is specified, or the type name is not recognized by the model.</returns> /// <remarks>The method detects the payload kind even if the model does not recognize the type. It figures out primitive and collection types always, /// and uses the <paramref name="expectedTypeKind"/> for the rest.</remarks> internal static IEdmType ResolvePayloadTypeName( IEdmModel model, IEdmTypeReference expectedTypeReference, string payloadTypeName, EdmTypeKind expectedTypeKind, ODataReaderBehavior readerBehavior, out EdmTypeKind payloadTypeKind) { if (payloadTypeName == null) { payloadTypeKind = EdmTypeKind.None; return null; } // Empty type names are allowed. if (payloadTypeName.Length == 0) { payloadTypeKind = expectedTypeKind; return null; } IEdmType payloadType = MetadataUtils.ResolveTypeNameForRead( model, expectedTypeReference == null ? null : expectedTypeReference.Definition, payloadTypeName, readerBehavior, out payloadTypeKind); if (payloadTypeKind == EdmTypeKind.None) { payloadTypeKind = expectedTypeKind; } return payloadType; }
/// <summary> /// Enables the same behavior that the WCF Data Services client has. Also, lets the user set the values for custom data namespace and type scheme. /// </summary> /// <param name="typeResolver">Custom type resolver which takes both expected type and type name. /// This function is used instead of the IEdmModel.FindType if it's specified. /// The first parameter to the function is the expected type (the type inferred from the parent property or specified by the external caller). /// The second parameter is the type name from the payload. /// The function should return the resolved type, or null if no such type was found.</param> public void EnableWcfDataServicesClientBehavior(Func<IEdmType, string, IEdmType> typeResolver) { this.readerBehavior = ODataReaderBehavior.CreateWcfDataServicesClientBehavior(typeResolver); }
/// <summary>Specifies whether the OData server behavior is enabled.</summary> public void EnableODataServerBehavior() { // We have to reset the ATOM entry XML customization since in the server behavior no atom entry customization is used. this.readerBehavior = ODataReaderBehavior.CreateWcfDataServicesServerBehavior(); }
/// <summary>Enables the default behavior.</summary> public void EnableDefaultBehavior() { // We have to reset the ATOM entry XML customization since in the default behavior no atom entry customization is used. this.readerBehavior = ODataReaderBehavior.DefaultBehavior; }
/// <summary> /// Enables the same behavior that the WCF Data Services client has. Also, lets the user set the values for custom data namespace and type scheme. /// </summary> /// <param name="typeResolver">Custom type resolver which takes both expected type and type name. /// This function is used instead of the IEdmModel.FindType if it's specified. /// The first parameter to the function is the expected type (the type inferred from the parent property or specified by the external caller). /// The second parameter is the type name from the payload. /// The function should return the resolved type, or null if no such type was found.</param> public void EnableWcfDataServicesClientBehavior(Func <IEdmType, string, IEdmType> typeResolver) { this.readerBehavior = ODataReaderBehavior.CreateWcfDataServicesClientBehavior(typeResolver); }