Example #1
0
        public async Task M()
        {
            var client = new JsonServiceClient("");

            client.DeserializeFromStream <object>(new MemoryStream());   // not a sink

            client.Get(new ReqDto1());
            client.Get(new ReqDto2());
            client.Get <ResponseDto>("relativeOrAbsoluteUrl");          // not a sink
            client.Get <ResponseDto>(new object());
            client.Get("relativeOrAbsoluteUrl");                        // not a sink
            client.Get(new object());

            await client.GetAsync <ResponseDto>("relativeOrAbsoluteUrl");    // not a sink

            await client.GetAsync <ResponseDto>(new object());

            await client.GetAsync(new ReqDto1());

            await client.GetAsync(new ReqDto2());


            client.CustomMethod("GET", new ReqDto2());
            client.CustomMethod <ResponseDto>("GET", "relativeOrAbsoluteUrl", new ReqDto1());
            client.CustomMethod <ResponseDto>("GET", new ReqDto1());
            client.CustomMethod <ResponseDto>("GET", new object());
            client.CustomMethod("GET", "relativeOrAbsoluteUrl", new object());
            client.CustomMethod("GET", (IReturnVoid)null);
            await client.CustomMethodAsync("GET", new ReqDto2());

            await client.CustomMethodAsync <ResponseDto>("GET", "relativeOrAbsoluteUrl", new ReqDto1());

            await client.CustomMethodAsync <ResponseDto>("GET", new ReqDto1());

            await client.CustomMethodAsync <ResponseDto>("GET", new object());

            client.DownloadBytes("GET", "requestUri", new object());
            await client.DownloadBytesAsync("GET", "relativeOrAbsoluteUrl", new object());

            client.Head(new object());
            client.Patch(new object());
            client.Post(new object());
            client.Put(new object());

            client.Send <ResponseDto>(new object());
            client.Publish(new ReqDto1());
            client.SendOneWay(new object());
        }
        public void Can_generate_CustomMethod()
        {
            var requestDto = new GetOrganizationRequest
            {
                Id = new Guid("ca61162b0c30491d8d91e74230f23a66"),
                IncludeAddresses = true
            };

            ServiceClientBase.GlobalRequestFilter = httpReq =>
            {
                httpReq.RequestUri.ToString().Print();
                Assert.That(httpReq.RequestUri.ToString(),
                            Is.EqualTo("http://www.google.com/organizations/ca61162b0c30491d8d91e74230f23a66?includeAddresses=True"));
            };

            var client = new JsonServiceClient("http://www.google.com/");

            try
            {
                client.CustomMethod("GET", requestDto);
            }
            catch (WebServiceException) { }

            try
            {
                client.CustomMethodAsync("GET", requestDto).Wait();
            }
            catch (AggregateException aex)
            {
                if (!(aex.UnwrapIfSingleException() is WebServiceException))
                {
                    throw;
                }
            }

            try
            {
                client.Get(requestDto);
            }
            catch (WebServiceException) { }
        }
        public void Can_generate_CustomMethod()
        {
            var requestDto = new GetOrganizationRequest
            {
                Id = new Guid("ca61162b0c30491d8d91e74230f23a66"),
                IncludeAddresses = true
            };

            ServiceClientBase.GlobalRequestFilter = httpReq =>
            {
                httpReq.RequestUri.ToString().Print();
                Assert.That(httpReq.RequestUri.ToString(),
                    Is.EqualTo("http://www.google.com/organizations/ca61162b0c30491d8d91e74230f23a66?includeAddresses=True"));
            };

            var client = new JsonServiceClient("http://www.google.com/");

            try
            {
                client.CustomMethod("GET", requestDto);
            }
            catch (WebServiceException) { }

            try
            {
                client.CustomMethodAsync("GET", requestDto).Wait();
            }
            catch (AggregateException aex)
            {
                if (!(aex.UnwrapIfSingleException() is WebServiceException))
                    throw;
            }

            try
            {
                client.Get(requestDto);
            }
            catch (WebServiceException) { }
        }