private static OperationFormatter GetOperationFormatter(System.Type t, Attribute formatAttribute, string defaultNS, string action) { bool flag = formatAttribute is XmlSerializerFormatAttribute; MessageDescription description = new TypeLoader().CreateTypedMessageDescription(t, null, null, defaultNS, action, MessageDirection.Output); ContractDescription declaringContract = new ContractDescription("dummy_contract", defaultNS); OperationDescription operation = new OperationDescription(NamingHelper.XmlName(t.Name), declaringContract, false) { Messages = { description } }; if (flag) { return(XmlSerializerOperationBehavior.CreateOperationFormatter(operation, (XmlSerializerFormatAttribute)formatAttribute)); } return(new DataContractSerializerOperationFormatter(operation, (DataContractFormatAttribute)formatAttribute, null)); }
static OperationFormatter GetOperationFormatter(Type t, Attribute formatAttribute, string defaultNS, string action) { bool isXmlSerializer = (formatAttribute is XmlSerializerFormatAttribute); TypeLoader typeLoader = new TypeLoader(); MessageDescription message = typeLoader.CreateTypedMessageDescription(t, null, null, defaultNS, action, MessageDirection.Output); ContractDescription contract = new ContractDescription("dummy_contract", defaultNS); OperationDescription operation = new OperationDescription(NamingHelper.XmlName(t.Name), contract, false); operation.Messages.Add(message); if (isXmlSerializer) { return(XmlSerializerOperationBehavior.CreateOperationFormatter(operation, (XmlSerializerFormatAttribute)formatAttribute)); } else { return(new DataContractSerializerOperationFormatter(operation, (DataContractFormatAttribute)formatAttribute, null)); } }