Ejemplo n.º 1
0
        internal override void InferMessageDescription(OperationDescription operation, object owner, MessageDirection direction)
        {
            ContractInferenceHelper.CheckForDisposableParameters(operation, this.InternalDeclaredMessageType);

            string           overridingAction = null;
            SerializerOption serializerOption = SerializerOption.DataContractSerializer;
            Receive          receive          = owner as Receive;

            if (receive != null)
            {
                overridingAction = receive.Action;
                serializerOption = receive.SerializerOption;
            }
            else
            {
                ReceiveReply receiveReply = owner as ReceiveReply;
                Fx.Assert(receiveReply != null, "The owner of ReceiveMessageContent can only be Receive or ReceiveReply!");
                overridingAction = receiveReply.Action;
                serializerOption = receiveReply.Request.SerializerOption;
            }

            if (direction == MessageDirection.Input)
            {
                ContractInferenceHelper.AddInputMessage(operation, overridingAction, this.InternalDeclaredMessageType, serializerOption);
            }
            else
            {
                ContractInferenceHelper.AddOutputMessage(operation, overridingAction, this.InternalDeclaredMessageType, serializerOption);
            }
        }
Ejemplo n.º 2
0
        internal override void ValidateContract(NativeActivityContext context, OperationDescription targetOperation, object owner, MessageDirection direction)
        {
            MessageDescription targetMessage;
            string             overridingAction;
            bool             isResponse;
            SerializerOption serializerOption;

            if (direction == MessageDirection.Input)
            {
                Fx.Assert(targetOperation.Messages.Count >= 1, "There must be at least one MessageDescription in an OperationDescription!");
                targetMessage = targetOperation.Messages[0];

                Receive receive = owner as Receive;
                Fx.Assert(receive != null, "The parent of a ReceiveMessageContent with in-message can only be Receive!");

                overridingAction = receive.Action;
                serializerOption = receive.SerializerOption;

                isResponse = false;
            }
            else
            {
                Fx.Assert(targetOperation.Messages.Count == 2, "There must be exactly two MessageDescription objects for a two-way operation!");
                targetMessage = targetOperation.Messages[1];

                ReceiveReply receiveReply = owner as ReceiveReply;
                Fx.Assert(receiveReply != null, "The parent of a ReceiveMessageContent with out-message can only be ReceiveReply!");
                Fx.Assert(receiveReply.Request != null, "ReceiveReply.Request should not be null by now!");
                overridingAction = receiveReply.Action;
                serializerOption = receiveReply.Request.SerializerOption;

                isResponse = true;
            }

            ContractValidationHelper.ValidateAction(context, targetMessage, overridingAction, targetOperation, isResponse);
            if (ContractValidationHelper.IsReceiveParameterContent(targetOperation))
            {
                Constraint.AddValidationError(context, new ValidationError(SR.MisuseOfMessageContent(targetOperation.Name, targetOperation.DeclaringContract.Name)));
            }
            else
            {
                ContractValidationHelper.ValidateMessageContent(context, targetMessage, this.InternalDeclaredMessageType,
                                                                serializerOption, targetOperation, isResponse);
            }
        }
Ejemplo n.º 3
0
        static OperationDescription CreateOperationDescriptionCore(Send send, ReceiveReply receiveReply)
        {
            XName contractXName = send.ServiceContractName;

            ProvideDefaultNamespace(ref contractXName);

            // Infer Name, Namespace, ConfigurationName
            ContractDescription contract = new ContractDescription(contractXName.LocalName, contractXName.NamespaceName);

            contract.ConfigurationName = send.EndpointConfigurationName;

            OperationDescription operation = new OperationDescription(NamingHelper.XmlName(send.OperationName), contract);

            if (send.ProtectionLevel.HasValue)
            {
                operation.ProtectionLevel = send.ProtectionLevel.Value;
            }

            AddKnownTypesToOperation(operation, send.KnownTypes);

            // Infer In-Message
            send.InternalContent.InferMessageDescription(operation, send, MessageDirection.Input);

            // Infer Out-Message
            if (receiveReply != null)
            {
                receiveReply.InternalContent.InferMessageDescription(operation, receiveReply, MessageDirection.Output);
            }

            PostProcessOperation(operation);
            AddSerializerProvider(operation, send.SerializerOption);

            contract.Operations.Add(operation);

            return(operation);
        }
        static OperationDescription CreateOperationDescriptionCore(Send send, ReceiveReply receiveReply)
        {
            XName contractXName = send.ServiceContractName;
            ProvideDefaultNamespace(ref contractXName);

            // Infer Name, Namespace, ConfigurationName
            ContractDescription contract = new ContractDescription(contractXName.LocalName, contractXName.NamespaceName);
            contract.ConfigurationName = send.EndpointConfigurationName;

            OperationDescription operation = new OperationDescription(NamingHelper.XmlName(send.OperationName), contract);
            if (send.ProtectionLevel.HasValue)
            {
                operation.ProtectionLevel = send.ProtectionLevel.Value;
            }

            AddKnownTypesToOperation(operation, send.KnownTypes);

            // Infer In-Message
            send.InternalContent.InferMessageDescription(operation, send, MessageDirection.Input);

            // Infer Out-Message
            if (receiveReply != null)
            {
                receiveReply.InternalContent.InferMessageDescription(operation, receiveReply, MessageDirection.Output);
            }

            PostProcessOperation(operation);
            AddSerializerProvider(operation, send.SerializerOption);

            contract.Operations.Add(operation);

            return operation;
        }
 public static OperationDescription CreateTwoWayOperationDescription(Send send, ReceiveReply receiveReply)
 {
     Fx.Assert(send != null && receiveReply != null, "Arguments cannot be null!");
     return CreateOperationDescriptionCore(send, receiveReply);
 }
Ejemplo n.º 6
0
 public static OperationDescription CreateTwoWayOperationDescription(Send send, ReceiveReply receiveReply)
 {
     Fx.Assert(send != null && receiveReply != null, "Arguments cannot be null!");
     return(CreateOperationDescriptionCore(send, receiveReply));
 }
 public static OperationDescription CreateTwoWayOperationDescription(Send send, ReceiveReply receiveReply)
 {
     return CreateOperationDescriptionCore(send, receiveReply);
 }
 public static OperationDescription CreateTwoWayOperationDescription(Send send, ReceiveReply receiveReply)
 {
     return(CreateOperationDescriptionCore(send, receiveReply));
 }