public ODataMessageReaderSettings()
 {
     this.DisablePrimitiveTypeConversion = false;
     this.DisableMessageStreamDisposal = false;
     this.UndeclaredPropertyBehaviorKinds = ODataUndeclaredPropertyBehaviorKinds.None;
     this.CheckCharacters = false;
     this.EnableAtomMetadataReading = false;
     this.readerBehavior = ODataReaderBehavior.DefaultBehavior;
     this.MaxProtocolVersion = ODataVersion.V3;
 }
Example #2
0
 public ODataMessageReaderSettings()
 {
     this.DisablePrimitiveTypeConversion  = false;
     this.DisableMessageStreamDisposal    = false;
     this.UndeclaredPropertyBehaviorKinds = ODataUndeclaredPropertyBehaviorKinds.None;
     this.CheckCharacters           = false;
     this.EnableAtomMetadataReading = false;
     this.readerBehavior            = ODataReaderBehavior.DefaultBehavior;
     this.MaxProtocolVersion        = ODataVersion.V3;
 }
        public void EnableWcfDataServicesClientBehavior(
            Func <IEdmType, string, IEdmType> typeResolver,
            string odataNamespace,
            string typeScheme,
            Func <ODataEntry, XmlReader, Uri, XmlReader> entryXmlCustomizationCallback)
        {
            ExceptionUtils.CheckArgumentNotNull(odataNamespace, "odataNamespace");
            ExceptionUtils.CheckArgumentNotNull(typeScheme, "typeScheme");

            this.SetAtomEntryXmlCustomizationCallback(entryXmlCustomizationCallback);
            this.readerBehavior = ODataReaderBehavior.CreateWcfDataServicesClientBehavior(typeResolver, odataNamespace, typeScheme);
        }
        /// <summary>Initializes a new instance of the <see cref="T:Microsoft.Data.OData.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;
        }
Example #5
0
 public ODataMessageReaderSettings(ODataMessageReaderSettings other)
 {
     ExceptionUtils.CheckArgumentNotNull <ODataMessageReaderSettings>(other, "other");
     this.BaseUri         = other.BaseUri;
     this.CheckCharacters = other.CheckCharacters;
     this.DisableMessageStreamDisposal   = other.DisableMessageStreamDisposal;
     this.DisablePrimitiveTypeConversion = other.DisablePrimitiveTypeConversion;
     this.EnableAtomMetadataReading      = other.EnableAtomMetadataReading;
     this.messageQuotas = new ODataMessageQuotas(other.MessageQuotas);
     this.UndeclaredPropertyBehaviorKinds = other.UndeclaredPropertyBehaviorKinds;
     this.MaxProtocolVersion = other.MaxProtocolVersion;
     this.readerBehavior     = other.ReaderBehavior;
 }
 public ODataMessageReaderSettings(ODataMessageReaderSettings other)
 {
     ExceptionUtils.CheckArgumentNotNull<ODataMessageReaderSettings>(other, "other");
     this.BaseUri = other.BaseUri;
     this.CheckCharacters = other.CheckCharacters;
     this.DisableMessageStreamDisposal = other.DisableMessageStreamDisposal;
     this.DisablePrimitiveTypeConversion = other.DisablePrimitiveTypeConversion;
     this.EnableAtomMetadataReading = other.EnableAtomMetadataReading;
     this.messageQuotas = new ODataMessageQuotas(other.MessageQuotas);
     this.UndeclaredPropertyBehaviorKinds = other.UndeclaredPropertyBehaviorKinds;
     this.MaxProtocolVersion = other.MaxProtocolVersion;
     this.readerBehavior = other.ReaderBehavior;
 }
        /// <summary>Initializes a new instance of the <see cref="T:Microsoft.Data.OData.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;
            this.atomFormatEntryXmlCustomizationCallback = other.atomFormatEntryXmlCustomizationCallback;

            // NOTE: reader behavior is immutable; copy by reference is ok.
            this.readerBehavior = other.ReaderBehavior;
        }
        /// <summary>
        /// Copy constructor.
        /// </summary>
        /// <param name="other">The instance to copy.</param>
        public ODataMessageReaderSettings(ODataMessageReaderSettings other)
        {
            ExceptionUtils.CheckArgumentNotNull(other, "other");

            this.BaseUri = other.BaseUri;
            this.CheckCharacters = other.CheckCharacters;
            this.DisableMessageStreamDisposal = other.DisableMessageStreamDisposal;
            this.DisablePrimitiveTypeConversion = other.DisablePrimitiveTypeConversion;
            this.EnableAtomMetadataReading = other.EnableAtomMetadataReading;
            this.messageQuotas = new ODataMessageQuotas(other.MessageQuotas);
            this.UndeclaredPropertyBehaviorKinds = other.UndeclaredPropertyBehaviorKinds;
            this.MaxProtocolVersion = other.MaxProtocolVersion;
            this.atomFormatEntryXmlCustomizationCallback = other.atomFormatEntryXmlCustomizationCallback;

            // NOTE: reader behavior is immutable; copy by reference is ok.
            this.readerBehavior = other.ReaderBehavior;
        }
        /// <summary>
        /// Constructor to create default settings for OData readers.
        /// </summary>
        public ODataMessageReaderSettings()
        {
            this.DisablePrimitiveTypeConversion = false;
            this.DisableMessageStreamDisposal = false;
            this.UndeclaredPropertyBehaviorKinds = ODataUndeclaredPropertyBehaviorKinds.None;

            // On reading the default value for 'CheckCharacters' is set to false so that we 
            // can consume valid and invalid Xml documents per default.
            this.CheckCharacters = false;

            // ATOM metadata reading is disabled by default for performance reasons and because 
            // few clients will need the ATOM metadata.
            this.EnableAtomMetadataReading = false;

            // Create the default reader behavior
            this.readerBehavior = ODataReaderBehavior.DefaultBehavior;

            this.MaxProtocolVersion = ODataConstants.ODataDefaultProtocolVersion;
        }
        /// <summary>
        /// Constructor to create default settings for OData readers.
        /// </summary>
        public ODataMessageReaderSettings()
        {
            this.DisablePrimitiveTypeConversion  = false;
            this.DisableMessageStreamDisposal    = false;
            this.UndeclaredPropertyBehaviorKinds = ODataUndeclaredPropertyBehaviorKinds.None;

            // On reading the default value for 'CheckCharacters' is set to false so that we
            // can consume valid and invalid Xml documents per default.
            this.CheckCharacters = false;

            // ATOM metadata reading is disabled by default for performance reasons and because
            // few clients will need the ATOM metadata.
            this.EnableAtomMetadataReading = false;

            // Create the default reader behavior
            this.readerBehavior = ODataReaderBehavior.DefaultBehavior;

            this.MaxProtocolVersion = ODataConstants.ODataDefaultProtocolVersion;
        }
        internal static IEdmType ResolvePayloadTypeName(IEdmModel model, IEdmTypeReference expectedTypeReference, string payloadTypeName, EdmTypeKind expectedTypeKind, ODataReaderBehavior readerBehavior, ODataVersion version, out EdmTypeKind payloadTypeKind)
        {
            if (payloadTypeName == null)
            {
                payloadTypeKind = EdmTypeKind.None;
                return(null);
            }
            if (payloadTypeName.Length == 0)
            {
                payloadTypeKind = expectedTypeKind;
                return(null);
            }
            IEdmType type = MetadataUtils.ResolveTypeNameForRead(model, (expectedTypeReference == null) ? null : expectedTypeReference.Definition, payloadTypeName, readerBehavior, version, out payloadTypeKind);

            if (payloadTypeKind == EdmTypeKind.None)
            {
                payloadTypeKind = expectedTypeKind;
            }
            return(type);
        }
 /// <summary>Specifies whether the WCF data services server behavior is enabled.</summary>
 /// <param name="usesV1Provider">true to use V1 provider; otherwise, false.</param>
 public void EnableWcfDataServicesServerBehavior(bool usesV1Provider)
 {
     // We have to reset the ATOM entry XML customization since in the server behavior no atom entry customization is used.
     this.SetAtomEntryXmlCustomizationCallback(null);
     this.readerBehavior = ODataReaderBehavior.CreateWcfDataServicesServerBehavior(usesV1Provider);
 }
 public void EnableDefaultBehavior()
 {
     this.readerBehavior = ODataReaderBehavior.DefaultBehavior;
 }
Example #14
0
 public void EnableWcfDataServicesServerBehavior(bool usesV1Provider)
 {
     this.readerBehavior = ODataReaderBehavior.CreateWcfDataServicesServerBehavior(usesV1Provider);
 }
 /// <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.SetAtomEntryXmlCustomizationCallback(null);
     this.readerBehavior = ODataReaderBehavior.DefaultBehavior;
 }
Example #16
0
 public void EnableDefaultBehavior()
 {
     this.readerBehavior = ODataReaderBehavior.DefaultBehavior;
 }
 public void EnableWcfDataServicesClientBehavior(Func<IEdmType, string, IEdmType> typeResolver, string odataNamespace, string typeScheme, Func<ODataEntry, XmlReader, Uri, XmlReader> entryXmlCustomizationCallback)
 {
     ExceptionUtils.CheckArgumentNotNull<string>(odataNamespace, "odataNamespace");
     ExceptionUtils.CheckArgumentNotNull<string>(typeScheme, "typeScheme");
     this.readerBehavior = ODataReaderBehavior.CreateWcfDataServicesClientBehavior(typeResolver, odataNamespace, typeScheme, entryXmlCustomizationCallback);
 }
 public void EnableWcfDataServicesServerBehavior(bool usesV1Provider)
 {
     this.readerBehavior = ODataReaderBehavior.CreateWcfDataServicesServerBehavior(usesV1Provider);
 }
 /// <summary>
 /// Enables the same behavior that the WCF Data Services server has.
 /// </summary>
 /// <param name="usesV1Provider">true if the server uses a V1 provider; otherwise false.</param>
 public void EnableWcfDataServicesServerBehavior(bool usesV1Provider)
 {
     // We have to reset the ATOM entry XML customization since in the server behavior no atom entry customization is used.
     this.SetAtomEntryXmlCustomizationCallback(null);
     this.readerBehavior = ODataReaderBehavior.CreateWcfDataServicesServerBehavior(usesV1Provider);
 }
        /// <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="version">The version of the payload being read.</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,
            ODataVersion version,
            out EdmTypeKind payloadTypeKind)
        {
            DebugUtils.CheckNoExternalCallers();

            if (payloadTypeName == null)
            {
                payloadTypeKind = EdmTypeKind.None;
                return null;
            }

            if (payloadTypeName.Length == 0)
            {
                payloadTypeKind = expectedTypeKind;
                return null;
            }

            IEdmType payloadType = MetadataUtils.ResolveTypeNameForRead(
                model,
                expectedTypeReference == null ? null : expectedTypeReference.Definition,
                payloadTypeName,
                readerBehavior,
                version,
                out payloadTypeKind);
            if (payloadTypeKind == EdmTypeKind.None)
            {
                payloadTypeKind = expectedTypeKind;
            }

            return payloadType;
        }
Example #21
0
 internal static IEdmType ResolveTypeNameForRead(IEdmModel model, IEdmType expectedType, string typeName, ODataReaderBehavior readerBehavior, ODataVersion version, out EdmTypeKind typeKind)
 {
     Func<IEdmType, string, IEdmType> customTypeResolver = (readerBehavior == null) ? null : readerBehavior.TypeResolver;
     return ResolveTypeName(model, expectedType, typeName, customTypeResolver, version, out typeKind);
 }
 /// <summary>
 /// Enables the default behavior of the OData library.
 /// </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.SetAtomEntryXmlCustomizationCallback(null);
     this.readerBehavior = ODataReaderBehavior.DefaultBehavior;
 }