Пример #1
0
        static MessageDescriptionCollection MessageContractToMessagesDescription(
            Type src, string defaultNamespace, string action)
        {
            MessageContractAttribute mca =
                ContractDescriptionGenerator.GetMessageContractAttribute(src);

            if (mca == null)
            {
                throw new ArgumentException(String.Format("Type {0} and its ancestor types do not have MessageContract attribute.", src));
            }

            MessageDescriptionCollection messages = new MessageDescriptionCollection();

            messages.Add(ContractDescriptionGenerator.CreateMessageDescription(src, defaultNamespace, action, true, mca));
            messages.Add(ContractDescriptionGenerator.CreateMessageDescription(src, defaultNamespace, action, false, mca));
            return(messages);
        }
Пример #2
0
 public OperationDescription(string name, ContractDescription declaringContract)
 {
     if (name == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(name));
     }
     if (name.Length == 0)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                   new ArgumentOutOfRangeException(nameof(name), SR.SFxOperationDescriptionNameCannotBeEmpty));
     }
     XmlName            = new XmlName(name, true /*isEncoded*/);
     _declaringContract = declaringContract ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(declaringContract));
     IsInitiating       = true;
     IsTerminating      = false;
     Faults             = new FaultDescriptionCollection();
     Messages           = new MessageDescriptionCollection();
     Behaviors          = new KeyedByTypeCollection <IOperationBehavior>();
     KnownTypes         = new Collection <Type>();
 }
Пример #3
0
        private CodeExpression[] ExportMessages(MessageDescriptionCollection messages, CodeMemberMethod method, bool return_args)
        {
            CodeExpression [] args = null;
            foreach (MessageDescription md in messages)
            {
                if (md.Direction == MessageDirection.Output)
                {
                    if (md.Body.ReturnValue != null)
                    {
                        ExportDataContract(md.Body.ReturnValue);
                        method.ReturnType = md.Body.ReturnValue.CodeTypeReference;
                    }
                    continue;
                }

                if (return_args)
                {
                    args = new CodeExpression [md.Body.Parts.Count];
                }

                MessagePartDescriptionCollection parts = md.Body.Parts;
                for (int i = 0; i < parts.Count; i++)
                {
                    ExportDataContract(parts [i]);

                    method.Parameters.Add(
                        new CodeParameterDeclarationExpression(
                            parts [i].CodeTypeReference,
                            parts [i].Name));

                    if (return_args)
                    {
                        args [i] = new CodeArgumentReferenceExpression(parts [i].Name);
                    }
                }
            }

            return(args);
        }
Пример #4
0
 public OperationDescription(string name, ContractDescription declaringContract)
 {
     if (name == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("name");
     }
     if (name.Length == 0)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                   new ArgumentOutOfRangeException("name", SR.SFxOperationDescriptionNameCannotBeEmpty));
     }
     _name = new XmlName(name, true /*isEncoded*/);
     if (declaringContract == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("declaringContract");
     }
     _declaringContract = declaringContract;
     _isInitiating      = true;
     _faults            = new FaultDescriptionCollection();
     _messages          = new MessageDescriptionCollection();
     _behaviors         = new KeyedByTypeCollection <IOperationBehavior>();
     _knownTypes        = new Collection <Type>();
 }
Пример #5
0
 public OperationDescription(string name, ContractDescription declaringContract)
 {
     this.validateRpcWrapperName = true;
     if (name == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("name");
     }
     if (name.Length == 0)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("name", System.ServiceModel.SR.GetString("SFxOperationDescriptionNameCannotBeEmpty")));
     }
     this.name = new System.ServiceModel.Description.XmlName(name, true);
     if (declaringContract == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("declaringContract");
     }
     this.declaringContract = declaringContract;
     this.isInitiating      = true;
     this.isTerminating     = false;
     this.faults            = new FaultDescriptionCollection();
     this.messages          = new MessageDescriptionCollection();
     this.behaviors         = new KeyedByTypeCollection <IOperationBehavior>();
     this.knownTypes        = new Collection <Type>();
 }