public void GetChildrenAsync(
     string promptName,
     string parameterName,
     ObservableCollection <ParameterValue> parameterValues,
     Action <PromptLevel> callback,
     Action <string> errorCallback)
 {
     _client.PostAsync <PromptLevel>(
         _uri,
         new ChildPromptItemsRequest
     {
         PromptName      = promptName,
         ParameterName   = parameterName,
         ParameterValues = parameterValues
     },
         result => Deployment.Current.Dispatcher.BeginInvoke(() => callback(result)),
         (result, e) => Deployment.Current.Dispatcher.BeginInvoke(() => errorCallback(e.Message)));
 }
 public void GetPromptsForReportAsync(
     string path,
     Action <IEnumerable <PromptInfo> > callback,
     Action <string> errorCallback)
 {
     _client.PostAsync <IEnumerable <PromptInfo> >(
         _uri,
         new PromptsRequest {
         Path = path
     },
         result => Deployment.Current.Dispatcher.BeginInvoke(() => callback(result)),
         (result, e) => Deployment.Current.Dispatcher.BeginInvoke(() => errorCallback(e.Message)));
 }
Example #3
0
 public void SetPromptSelectionsAsync(
     string path,
     ObservableCollection <PromptSelectionInfo> promptSelections,
     Action <string> callback,
     Action <string> errorCallback)
 {
     _client.PostAsync <string>(
         _uri,
         new SetPromptSelectionsRequest
     {
         Path             = path,
         PromptSelections = promptSelections
     },
         result => Deployment.Current.Dispatcher.BeginInvoke(() => callback(result)),
         (result, e) => Deployment.Current.Dispatcher.BeginInvoke(() => errorCallback(e.Message)));
 }
Example #4
0
        static void Main(string[] args)
        {
            var serviceClient = new JsonRestClientAsync("http://g-un--:1337/");
            var responseSubject = new BehaviorSubject<Unit>(Unit.Default);

            responseSubject.Subscribe(_ =>
                {
                    serviceClient.PostAsync<ResourceResponse>(
                        "/async",
                        new ResourceRequest()
                        {
                            ResourceKey = Guid.NewGuid().ToString()
                        },
                        response =>
                        {
                            Console.WriteLine("Data received");
                            Console.WriteLine(response.ResourceData);
                            responseSubject.OnNext(Unit.Default);
                        },
                        (response, ex) =>
                        {
                            Console.WriteLine("Exception on calling service post method");
                            Console.WriteLine(ex);
                            responseSubject.OnCompleted();
                        });
                });

            Observable.Interval(TimeSpan.FromSeconds(1))
                .Subscribe(_ =>
                    {
                        var newClient = new JsonRestClientAsync("http://g-un--:1337/");
                        newClient.PutAsync<object>(
                            "/async",
                            new ResourceRequest() { ResourceKey = Guid.NewGuid().ToString() },
                            response =>
                            {
                                Console.WriteLine("Put was sent!");
                            },
                            (response, exception) =>
                            {
                                Console.WriteLine(exception);
                            });
                    });

            Console.ReadLine();
        }
        public static void SendAsync <TResult>(this JsonRestClientAsync client, HttpMethods method, string relativeOrAbsoluteUrl, Action <TResult> onSuccess, Action <TResult, Exception> onError, object request = null)
        {
            switch (method)
            {
            case HttpMethods.GET:
                client.GetAsync(relativeOrAbsoluteUrl, onSuccess, onError);
                break;

            case HttpMethods.PUT:
                client.PutAsync(relativeOrAbsoluteUrl, request, onSuccess, onError);
                break;

            case HttpMethods.DELETE:
                client.DeleteAsync(relativeOrAbsoluteUrl, onSuccess, onError);
                break;

            case HttpMethods.POST:
                client.PostAsync(relativeOrAbsoluteUrl, request, onSuccess, onError);
                break;

            default:
                throw new ArgumentOutOfRangeException("HttpMethod not in use");
            }
        }