public static ValueSet InvokeChannel(this AppServiceConnection connection, Type contractType, object argument,
     string method)
 {
     var channelWriteHelper = new ChannelWriteHelper(contractType);
     var message = channelWriteHelper.FormatOutput(argument, method);
     var sendMessageTask = connection.SendMessageAsync(new ValueSet {{contractType.Name, message}}).AsTask();
     sendMessageTask.Wait();
     return sendMessageTask.Result.Status != AppServiceResponseStatus.Success
         ? null
         : sendMessageTask.Result.Message;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Sends a new message using the AppServiceConnection, containing the contract name, the method name and the serialized argument
        /// </summary>
        public static ValueSet InvokeChannel(this AppServiceConnection connection, Type contractType, object argument,
            string method)
        {

            //Create a new instance of the channel writer and format the message (format: <Method> <Argument - can be null and is serialized as JSON>)
            var channelWriteHelper = new ChannelWriteHelper(contractType);
            var message = channelWriteHelper.FormatOutput(argument, method);

            //Send the message with the key being the contract name and the value being the serialized message
            var sendMessageTask = connection.SendMessageAsync(new ValueSet {{contractType.Name, message}}).AsTask();
            sendMessageTask.Wait();

            //If the message send resulted in a failure, return null, otherwise return the ValueSet result
            return sendMessageTask.Result.Status != AppServiceResponseStatus.Success
                ? null
                : sendMessageTask.Result.Message;
        }