public WebHttpBehavior() { defaultOutgoingRequestFormat = WebMessageFormat.Xml; defaultOutgoingReplyFormat = WebMessageFormat.Xml; this.defaultBodyStyle = WebMessageBodyStyle.Bare; xmlSerializerManager = new UnwrappedTypesXmlSerializerManager(); }
public static IDispatchMessageFormatter CreateXmlAndJsonDispatchFormatter(OperationDescription operation, Type type, bool isRequestFormatter, UnwrappedTypesXmlSerializerManager xmlSerializerManager, string callbackParameterName) { IDispatchMessageFormatter xmlFormatter = CreateDispatchFormatter(operation, type, isRequestFormatter, false, xmlSerializerManager, null); if (!WebHttpBehavior.SupportsJsonFormat(operation)) { return xmlFormatter; } IDispatchMessageFormatter jsonFormatter = CreateDispatchFormatter(operation, type, isRequestFormatter, true, xmlSerializerManager, callbackParameterName); Dictionary<WebContentFormat, IDispatchMessageFormatter> map = new Dictionary<WebContentFormat, IDispatchMessageFormatter>(); map.Add(WebContentFormat.Xml, xmlFormatter); map.Add(WebContentFormat.Json, jsonFormatter); return new DemultiplexingDispatchMessageFormatter(map, xmlFormatter); }
public static IClientMessageFormatter CreateXmlAndJsonClientFormatter(OperationDescription operation, Type type, bool isRequestFormatter, UnwrappedTypesXmlSerializerManager xmlSerializerManager) { IClientMessageFormatter xmlFormatter = CreateClientFormatter(operation, type, isRequestFormatter, false, xmlSerializerManager); if (!WebHttpBehavior.SupportsJsonFormat(operation)) { return xmlFormatter; } IClientMessageFormatter jsonFormatter = CreateClientFormatter(operation, type, isRequestFormatter, true, xmlSerializerManager); Dictionary<WebContentFormat, IClientMessageFormatter> map = new Dictionary<WebContentFormat, IClientMessageFormatter>(); map.Add(WebContentFormat.Xml, xmlFormatter); map.Add(WebContentFormat.Json, jsonFormatter); return new DemultiplexingClientMessageFormatter(map, xmlFormatter); }
public SingleBodyParameterXmlSerializerMessageFormatter(OperationDescription operation, Type parameterType, bool isRequestFormatter, XmlSerializerOperationBehavior xsob, UnwrappedTypesXmlSerializerManager serializerManager) : base(operation, isRequestFormatter, "XmlSerializer") { if (operation == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("operation"); } if (parameterType == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parameterType"); } if (xsob == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("xsob"); } if (serializerManager == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("serializerManager"); } this.serializerManager = serializerManager; this.parameterType = parameterType; List <Type> operationTypes = new List <Type>(); operationTypes.Add(parameterType); this.knownTypes = new List <Type>(); if (operation.KnownTypes != null) { foreach (Type knownType in operation.KnownTypes) { this.knownTypes.Add(knownType); operationTypes.Add(knownType); } } Type nullableType = SingleBodyParameterDataContractMessageFormatter.UnwrapNullableType(this.parameterType); if (nullableType != this.parameterType) { this.knownTypes.Add(nullableType); operationTypes.Add(nullableType); } this.serializerManager.RegisterType(this, operationTypes); thisLock = new Object(); }
public SingleBodyParameterXmlSerializerMessageFormatter(OperationDescription operation, Type parameterType, bool isRequestFormatter, XmlSerializerOperationBehavior xsob, UnwrappedTypesXmlSerializerManager serializerManager) : base(operation, isRequestFormatter, "XmlSerializer") { if (operation == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("operation"); } if (parameterType == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parameterType"); } if (xsob == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("xsob"); } if (serializerManager == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("serializerManager"); } this.serializerManager = serializerManager; this.parameterType = parameterType; List<Type> operationTypes = new List<Type>(); operationTypes.Add(parameterType); this.knownTypes = new List<Type>(); if (operation.KnownTypes != null) { foreach (Type knownType in operation.KnownTypes) { this.knownTypes.Add(knownType); operationTypes.Add(knownType); } } Type nullableType = SingleBodyParameterDataContractMessageFormatter.UnwrapNullableType(this.parameterType); if (nullableType != this.parameterType) { this.knownTypes.Add(nullableType); operationTypes.Add(nullableType); } this.serializerManager.RegisterType(this, operationTypes); thisLock = new Object(); }
public static SingleBodyParameterMessageFormatter CreateXmlFormatter(OperationDescription operation, Type type, bool isRequestFormatter, UnwrappedTypesXmlSerializerManager xmlSerializerManager) { DataContractSerializerOperationBehavior dcsob = operation.Behaviors.Find<DataContractSerializerOperationBehavior>(); if (dcsob != null) { return new SingleBodyParameterDataContractMessageFormatter(operation, type, isRequestFormatter, false, dcsob); } XmlSerializerOperationBehavior xsob = operation.Behaviors.Find<XmlSerializerOperationBehavior>(); if (xsob != null) { return new SingleBodyParameterXmlSerializerMessageFormatter(operation, type, isRequestFormatter, xsob, xmlSerializerManager); } throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR2.GetString(SR2.OnlyDataContractAndXmlSerializerTypesInUnWrappedMode, operation.Name))); }
internal static IDispatchMessageFormatter CreateDispatchFormatter(OperationDescription operation, Type type, bool isRequestFormatter, bool useJson, UnwrappedTypesXmlSerializerManager xmlSerializerManager, string callbackParameterName) { if (type == null) { return new NullMessageFormatter(useJson, callbackParameterName); } else if (useJson) { return CreateJsonFormatter(operation, type, isRequestFormatter); } else { return CreateXmlFormatter(operation, type, isRequestFormatter, xmlSerializerManager); } }
internal static IClientMessageFormatter CreateClientFormatter(OperationDescription operation, Type type, bool isRequestFormatter, bool useJson, UnwrappedTypesXmlSerializerManager xmlSerializerManager) { if (type == null) { return new NullMessageFormatter(false, null); } else if (useJson) { return CreateJsonFormatter(operation, type, isRequestFormatter); } else { return CreateXmlFormatter(operation, type, isRequestFormatter, xmlSerializerManager); } }
public static IDispatchMessageFormatter CreateXmlAndJsonDispatchFormatter(OperationDescription operation, Type type, bool isRequestFormatter, UnwrappedTypesXmlSerializerManager xmlSerializerManager, string callbackParameterName) { IDispatchMessageFormatter xmlFormatter = CreateDispatchFormatter(operation, type, isRequestFormatter, false, xmlSerializerManager, null); if (!WebHttpBehavior.SupportsJsonFormat(operation)) { return(xmlFormatter); } IDispatchMessageFormatter jsonFormatter = CreateDispatchFormatter(operation, type, isRequestFormatter, true, xmlSerializerManager, callbackParameterName); Dictionary <WebContentFormat, IDispatchMessageFormatter> map = new Dictionary <WebContentFormat, IDispatchMessageFormatter>(); map.Add(WebContentFormat.Xml, xmlFormatter); map.Add(WebContentFormat.Json, jsonFormatter); return(new DemultiplexingDispatchMessageFormatter(map, xmlFormatter)); }
public static IClientMessageFormatter CreateXmlAndJsonClientFormatter(OperationDescription operation, Type type, bool isRequestFormatter, UnwrappedTypesXmlSerializerManager xmlSerializerManager) { IClientMessageFormatter xmlFormatter = CreateClientFormatter(operation, type, isRequestFormatter, false, xmlSerializerManager); if (!WebHttpBehavior.SupportsJsonFormat(operation)) { return(xmlFormatter); } IClientMessageFormatter jsonFormatter = CreateClientFormatter(operation, type, isRequestFormatter, true, xmlSerializerManager); Dictionary <WebContentFormat, IClientMessageFormatter> map = new Dictionary <WebContentFormat, IClientMessageFormatter>(); map.Add(WebContentFormat.Xml, xmlFormatter); map.Add(WebContentFormat.Json, jsonFormatter); return(new DemultiplexingClientMessageFormatter(map, xmlFormatter)); }
public static SingleBodyParameterMessageFormatter CreateXmlFormatter(OperationDescription operation, Type type, bool isRequestFormatter, UnwrappedTypesXmlSerializerManager xmlSerializerManager) { DataContractSerializerOperationBehavior dcsob = operation.Behaviors.Find <DataContractSerializerOperationBehavior>(); if (dcsob != null) { return(new SingleBodyParameterDataContractMessageFormatter(operation, type, isRequestFormatter, false, dcsob)); } XmlSerializerOperationBehavior xsob = operation.Behaviors.Find <XmlSerializerOperationBehavior>(); if (xsob != null) { return(new SingleBodyParameterXmlSerializerMessageFormatter(operation, type, isRequestFormatter, xsob, xmlSerializerManager)); } throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR2.GetString(SR2.OnlyDataContractAndXmlSerializerTypesInUnWrappedMode, operation.Name))); }
internal static IDispatchMessageFormatter CreateDispatchFormatter(OperationDescription operation, Type type, bool isRequestFormatter, bool useJson, UnwrappedTypesXmlSerializerManager xmlSerializerManager, string callbackParameterName) { if (type == null) { return(new NullMessageFormatter(useJson, callbackParameterName)); } else if (useJson) { return(CreateJsonFormatter(operation, type, isRequestFormatter)); } else { return(CreateXmlFormatter(operation, type, isRequestFormatter, xmlSerializerManager)); } }
internal static IClientMessageFormatter CreateClientFormatter(OperationDescription operation, Type type, bool isRequestFormatter, bool useJson, UnwrappedTypesXmlSerializerManager xmlSerializerManager) { if (type == null) { return(new NullMessageFormatter(false, null)); } else if (useJson) { return(CreateJsonFormatter(operation, type, isRequestFormatter)); } else { return(CreateXmlFormatter(operation, type, isRequestFormatter, xmlSerializerManager)); } }