Exemple #1
0
        public static MessageDescription CreateFromMessageContract(OperationDescription operation, bool isResponse, MessageDirection direction, string overridingAction, Type messageContractType)
        {
            string     action = overridingAction ?? NamingHelper.GetMessageAction(operation, isResponse);
            TypeLoader loader = new TypeLoader();

            return(loader.CreateTypedMessageDescription(messageContractType, null, null, operation.DeclaringContract.Namespace, action, direction));
        }
        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);
        }
        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));
            }
        }
 public static MessageDescription CreateFromMessageContract(OperationDescription operation, bool isResponse, MessageDirection direction, string overridingAction, Type messageContractType)
 {
     string action = overridingAction ?? NamingHelper.GetMessageAction(operation, isResponse);
     TypeLoader loader = new TypeLoader();
     return loader.CreateTypedMessageDescription(messageContractType, null, null, operation.DeclaringContract.Namespace, action, direction);
 }