Invoke() публичный Метод

public Invoke ( string methodPath, WoopsaValue>.Dictionary arguments ) : WoopsaClientRequest
methodPath string
arguments WoopsaValue>.Dictionary
Результат WoopsaClientRequest
 private bool RegisterSubscriptions(List<WoopsaClientSubscription> subscriptions)
 {
     if (_localSubscriptionService == null)
     {
         // Prepare remote subscription using multirequest
         Dictionary<WoopsaClientSubscription, WoopsaClientRequest> requests =
             new Dictionary<WoopsaClientSubscription, WoopsaClientRequest>();
         WoopsaClientMultiRequest multiRequest = new WoopsaClientMultiRequest();
         foreach (var item in subscriptions)
             requests[item] = multiRequest.Invoke(RegisterSubscriptionMethodPath,
                 WoopsaSubscriptionServiceConst.RegisterSubscriptionArguments,
                 _subscriptionOpenChannel.Value, item.ServicePath,
                 item.MonitorInterval, item.PublishInterval);
         try
         {
             // Prevent receiving new notifications until the new subscriptions are all registered
             // Otherwise, we will not be able to dispatch properly notifications coming
             // from those new subscriptions
             lock (_subscriptionLock)
             {
                 _client.ExecuteMultiRequest(multiRequest);
                 // Assign the subscriptionIds
                 foreach (var item in subscriptions)
                 {
                     WoopsaClientRequest request = requests[item];
                     if (request.Result.ResultType == WoopsaClientRequestResultType.Value)
                         item.SubscriptionId = request.Result.Value;
                     item.FailedSubscription = item.SubscriptionId == null;
                     if (!item.FailedSubscription)
                         _registeredSubscriptions[item.SubscriptionId.Value] = item;
                 }
             }
             return true;
         }
         catch
         {
             return false;
         }
     }
     else
     {
         // local service subscription
         foreach (var item in subscriptions)
         {
             try
             {
                 item.SubscriptionId = _localSubscriptionService.RegisterSubscription(
                     _subscriptionOpenChannel.Value, item.ServicePath,
                     item.MonitorInterval, item.PublishInterval);
             }
             catch
             {
             }
             item.FailedSubscription = item.SubscriptionId == null;
             if (!item.FailedSubscription)
                 _registeredSubscriptions[item.SubscriptionId.Value] = item;
         }
         return true;
     }
 }
 private bool UnregisterSubscriptions(IEnumerable<WoopsaClientSubscription> unsubscriptions)
 {
     if (_localSubscriptionService == null)
     {
         // Remote unsubscription using multirequest
         Dictionary<WoopsaClientSubscription, WoopsaClientRequest> requests =
             new Dictionary<WoopsaClientSubscription, WoopsaClientRequest>();
         WoopsaClientMultiRequest multiRequest = new WoopsaClientMultiRequest();
         foreach (var item in unsubscriptions)
             if (item.SubscriptionId.HasValue)
                 requests[item] = multiRequest.Invoke(UnregisterSubscriptionMethodPath,
                     WoopsaSubscriptionServiceConst.UnregisterSubscriptionArguments,
                     _subscriptionOpenChannel.Value, item.SubscriptionId);
         try
         {
             _client.ExecuteMultiRequest(multiRequest);
             // Remove the unsubscribed subscriptions
             foreach (var item in unsubscriptions)
                 if (item.SubscriptionId.HasValue)
                 {
                     WoopsaClientRequest request = requests[item];
                     if (request.Result.ResultType == WoopsaClientRequestResultType.Value)
                     {
                         lock (_subscriptions)
                         {
                             _registeredSubscriptions.Remove(item.SubscriptionId.Value);
                             _subscriptions.Remove(item);
                         }
                         item.SubscriptionId = null;
                     }
                 }
             return true;
         }
         catch
         {
             return false;
         }
     }
     else
     {
         foreach (var item in unsubscriptions)
         {
             if (item.SubscriptionId.HasValue)
                 _localSubscriptionService.UnregisterSubscription(
                     _subscriptionOpenChannel.Value, item.SubscriptionId.Value);
             lock (_subscriptions)
             {
                 if (item.SubscriptionId.HasValue)
                     _registeredSubscriptions.Remove(item.SubscriptionId.Value);
                 _subscriptions.Remove(item);
             }
             item.SubscriptionId = null;
         }
         return true;
     }
 }
        public void ExecuteMultiRequestTestSerie(WoopsaClient client, TestObjectMultiRequest objectServer)
        {
            WoopsaClientMultiRequest multiRequest = new WoopsaClientMultiRequest();

            WoopsaClientRequest request1 = multiRequest.Write("TestObject/A", 1);
            WoopsaClientRequest request2 = multiRequest.Write("TestObject/B", 2);
            WoopsaClientRequest request3 = multiRequest.Read("TestObject/Sum");
            WoopsaClientRequest request4 = multiRequest.Write("TestObject/C", 4);
            WoopsaClientRequest request5 = multiRequest.Meta("TestObject");

            WoopsaMethodArgumentInfo[] argumentInfosSet = new WoopsaMethodArgumentInfo[]
            {
                        new WoopsaMethodArgumentInfo("a", WoopsaValueType.Real),
                        new WoopsaMethodArgumentInfo("b", WoopsaValueType.Real)
            };
            WoopsaClientRequest request6 = multiRequest.Invoke("TestObject/Set",
                argumentInfosSet, 4, 5);
            WoopsaClientRequest request7 = multiRequest.Read("TestObject/Sum");
            WoopsaClientRequest request8 = multiRequest.Invoke("TestObject/Click",
                new Dictionary<string, WoopsaValue>());
            WoopsaClientRequest request9 = multiRequest.Read("TestObject/IsClicked");
            WoopsaClientRequest request10 = multiRequest.Write("TestObject/IsClicked", false);
            WoopsaClientRequest request11 = multiRequest.Read("TestObject/IsClicked");

            WoopsaMethodArgumentInfo[] argumentInfosSetS = new WoopsaMethodArgumentInfo[]
            {
                        new WoopsaMethodArgumentInfo("value", WoopsaValueType.Text)
            };
            WoopsaClientRequest request12 = multiRequest.Invoke("TestObject/SetS",
                argumentInfosSetS, "Hello");
            WoopsaClientRequest request13 = multiRequest.Read("TestObject/S");
            WoopsaClientRequest request14 = multiRequest.Write("TestObject/S", "ABC");
            WoopsaClientRequest request15 = multiRequest.Read("TestObject/S");

            client.ExecuteMultiRequest(multiRequest);
            Assert.AreEqual(objectServer.A, 4);
            Assert.AreEqual(objectServer.B, 5);
            Assert.AreEqual(request3.Result.ResultType, WoopsaClientRequestResultType.Value);
            Assert.AreEqual(request3.Result.Value, 3.0);
            Assert.AreEqual(request4.Result.ResultType, WoopsaClientRequestResultType.Error);
            Assert.IsNotNull(request4.Result.Error);
            Assert.AreEqual(request5.Result.ResultType, WoopsaClientRequestResultType.Meta);
            Assert.IsNotNull(request5.Result.Meta);
            Assert.AreEqual(request6.Result.ResultType, WoopsaClientRequestResultType.Value);
            Assert.IsNotNull(request6.Result.Value);
            Assert.AreEqual(request6.Result.Value.Type, WoopsaValueType.Null);
            Assert.AreEqual(request7.Result.ResultType, WoopsaClientRequestResultType.Value);
            Assert.IsNotNull(request7.Result.Value);
            Assert.AreEqual(request7.Result.Value, 9.0);
            Assert.AreEqual(request8.Result.ResultType, WoopsaClientRequestResultType.Value);
            Assert.AreEqual(request8.Result.Value.Type, WoopsaValueType.Null);
            Assert.IsTrue(request9.Result.Value);
            Assert.AreEqual(request10.Result.ResultType, WoopsaClientRequestResultType.Value);
            Assert.IsFalse(request11.Result.Value);
            Assert.AreEqual(request12.Result.ResultType, WoopsaClientRequestResultType.Value);
            Assert.AreEqual(request12.Result.Value.Type, WoopsaValueType.Null);
            Assert.AreEqual(request13.Result.ResultType, WoopsaClientRequestResultType.Value);
            Assert.IsNotNull(request13.Result.Value);
            Assert.AreEqual(request13.Result.Value, "Hello");
            Assert.AreEqual(objectServer.S, "ABC");
            Assert.AreEqual(request15.Result.ResultType, WoopsaClientRequestResultType.Value);
            Assert.IsNotNull(request15.Result.Value);
            Assert.AreEqual(request15.Result.Value, "ABC");
        }