Esempio n. 1
0
        /// <summary>
        /// Create message reader settings for consuming responses.
        /// </summary>
        /// <returns>Newly created message reader settings.</returns>
        internal ODataMessageReaderSettings CreateSettings()
        {
            ODataMessageReaderSettings settings = new ODataMessageReaderSettings();

            if (this.responseInfo.Context.EnableAtom)
            {
                // Enable ATOM in client
                settings.EnableAtomSupport();
            }

            Func <IEdmType, string, IEdmType> resolveWireTypeName = this.responseInfo.TypeResolver.ResolveWireTypeName;

            if (this.responseInfo.Context.Format.ServiceModel != null)
            {
                resolveWireTypeName = null;
            }

            settings.EnableWcfDataServicesClientBehavior(resolveWireTypeName);

            settings.BaseUri = this.responseInfo.BaseUriResolver.BaseUriOrNull;
            settings.UndeclaredPropertyBehaviorKinds = ODataUndeclaredPropertyBehaviorKinds.ReportUndeclaredLinkProperty;
            settings.MaxProtocolVersion = CommonUtil.ConvertToODataVersion(this.responseInfo.MaxProtocolVersion);
            if (this.responseInfo.IgnoreMissingProperties)
            {
                settings.UndeclaredPropertyBehaviorKinds |= ODataUndeclaredPropertyBehaviorKinds.IgnoreUndeclaredValueProperty;
            }

            CommonUtil.SetDefaultMessageQuotas(settings.MessageQuotas);

            this.responseInfo.ResponsePipeline.ExecuteReaderSettingsConfiguration(settings);
            return(settings);
        }
Esempio n. 2
0
        /// <summary>
        /// Create message reader settings for consuming responses.
        /// </summary>
        /// <param name="entryXmlCustomizer">Optional XML entry customization callback to be used.</param>
        /// <returns>Newly created message reader settings.</returns>
        internal ODataMessageReaderSettings CreateSettings(Func <ODataEntry, XmlReader, Uri, XmlReader> entryXmlCustomizer)
        {
            ODataMessageReaderSettings settings = new ODataMessageReaderSettings();

            if (!this.responseInfo.ResponsePipeline.HasAtomReadingEntityHandlers)
            {
                entryXmlCustomizer = null;
            }

            Func <IEdmType, string, IEdmType> resolveWireTypeName = this.responseInfo.TypeResolver.ResolveWireTypeName;

            if (this.responseInfo.Context.Format.ServiceModel != null)
            {
                resolveWireTypeName = null;
            }

            settings.EnableWcfDataServicesClientBehavior(
                resolveWireTypeName,
                this.responseInfo.DataNamespace,
                UriUtil.UriToString(this.responseInfo.TypeScheme),
                entryXmlCustomizer);

            settings.BaseUri            = this.responseInfo.BaseUriResolver.BaseUriOrNull;
            settings.MaxProtocolVersion = CommonUtil.ConvertToODataVersion(this.responseInfo.MaxProtocolVersion);
            settings.UndeclaredPropertyBehaviorKinds = this.responseInfo.UndeclaredPropertyBehaviorKinds
                                                       | ODataUndeclaredPropertyBehaviorKinds.ReportUndeclaredLinkProperty;

            CommonUtil.SetDefaultMessageQuotas(settings.MessageQuotas);

            this.responseInfo.ResponsePipeline.ExecuteReaderSettingsConfiguration(settings);
            return(settings);
        }
Esempio n. 3
0
        public void SetBehaviorTest()
        {
            ODataMessageReaderSettings settings = new ODataMessageReaderSettings();

            settings.EnableWcfDataServicesClientBehavior(null);
            this.CompareReaderBehavior(
                settings,
                /*formatBehaviorKind*/ ODataBehaviorKind.WcfDataServicesClient,
                /*apiBehaviorKind*/ ODataBehaviorKind.WcfDataServicesClient,
                true,
                /*typeResolver*/ null);

            Func <IEdmType, string, IEdmType> customTypeResolver = (expectedType, typeName) => expectedType;

            settings.EnableWcfDataServicesClientBehavior(customTypeResolver);
            this.CompareReaderBehavior(
                settings,
                /*formatBehaviorKind*/ ODataBehaviorKind.WcfDataServicesClient,
                /*apiBehaviorKind*/ ODataBehaviorKind.WcfDataServicesClient,
                true,
                customTypeResolver);

            settings.EnableODataServerBehavior();
            this.CompareReaderBehavior(
                settings,
                /*formatBehaviorKind*/ ODataBehaviorKind.ODataServer,
                /*apiBehaviorKind*/ ODataBehaviorKind.ODataServer,
                true,
                /*typeResolver*/ null);

            settings.EnableDefaultBehavior();
            this.CompareReaderBehavior(
                settings,
                /*formatBehaviorKind*/ ODataBehaviorKind.Default,
                /*apiBehaviorKind*/ ODataBehaviorKind.Default,
                false,
                /*typeResolver*/ null);
        }
Esempio n. 4
0
        internal static ODataMessageReaderSettings CreateODataMessageReaderSettings(ResponseInfo responseInfo, Func <ODataEntry, XmlReader, Uri, XmlReader> entryXmlCustomizer, bool projectionQuery)
        {
            ODataMessageReaderSettings settings = new ODataMessageReaderSettings();

            responseInfo.TypeResolver = new TypeResolver(responseInfo, projectionQuery);
            settings.EnableWcfDataServicesClientBehavior(new Func <IEdmType, string, IEdmType>(responseInfo.TypeResolver.ResolveWireTypeName), responseInfo.DataNamespace, CommonUtil.UriToString(responseInfo.TypeScheme), entryXmlCustomizer);
            settings.BaseUri = (responseInfo.BaseUriResolver.GetRawBaseUriValue() != null) ? responseInfo.BaseUriResolver.GetBaseUriWithSlash() : null;
            settings.UndeclaredPropertyBehaviorKinds = ODataUndeclaredPropertyBehaviorKinds.ReportUndeclaredLinkProperty;
            settings.MaxProtocolVersion = CommonUtil.ConvertToODataVersion(responseInfo.MaxProtocolVersion);
            if (responseInfo.IgnoreMissingProperties)
            {
                settings.UndeclaredPropertyBehaviorKinds |= ODataUndeclaredPropertyBehaviorKinds.IgnoreUndeclaredValueProperty;
            }
            settings.MessageQuotas.MaxEntityPropertyMappingsPerType = 0x7fffffff;
            settings.MessageQuotas.MaxNestingDepth           = 0x7fffffff;
            settings.MessageQuotas.MaxOperationsPerChangeset = 0x7fffffff;
            settings.MessageQuotas.MaxPartsPerBatch          = 0x7fffffff;
            settings.MessageQuotas.MaxReceivedMessageSize    = 0x7fffffffffffffffL;
            return(settings);
        }