当前位置: 首页>>代码示例>>C#>>正文


C# JsonServiceClient.Get方法代码示例

本文整理汇总了C#中JsonServiceClient.Get方法的典型用法代码示例。如果您正苦于以下问题:C# JsonServiceClient.Get方法的具体用法?C# JsonServiceClient.Get怎么用?C# JsonServiceClient.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JsonServiceClient的用法示例。


在下文中一共展示了JsonServiceClient.Get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RunTests

        public void RunTests()
        {
            string username = "passuser";
            string passHash = MD5Helper.CalculateMD5Hash("password");

            JsonServiceClient client = new JsonServiceClient(SystemConstants.WebServiceBaseURL);
            Login(client, username, passHash);

            client.Get<XamarinEvolveSSLibrary.UserResponse>("User");

            Logout(client);

            client.Get<XamarinEvolveSSLibrary.UserResponse>("User");

            Login(client, username, passHash);

            User user = new User()
            {
                UserName = username,
                City = "changedtown",
                Email = "[email protected]"
            };

            client.Post<XamarinEvolveSSLibrary.UserResponse>("User", user);

            Logout(client);

            client.Post<XamarinEvolveSSLibrary.UserResponse>("User", user);
        }
开发者ID:bholmes,项目名称:XamarinEvolve2013Project,代码行数:29,代码来源:AuthTest.cs

示例2: TestCanUpdateCustomer

        public void TestCanUpdateCustomer()
        {
            JsonServiceClient client = new JsonServiceClient("http://localhost:2337/");
            //Force cache
            client.Get(new GetCustomer { Id = 1 });
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();
            var cachedResponse = client.Get(new GetCustomer { Id = 1 });
            stopwatch.Stop();
            var cachedTime = stopwatch.ElapsedTicks;
            stopwatch.Reset();

            client.Put(new UpdateCustomer { Id = 1, Name = "Johno" });

            stopwatch.Start();
            var nonCachedResponse = client.Get(new GetCustomer { Id = 1 });
            stopwatch.Stop();
            var nonCacheTime = stopwatch.ElapsedTicks;

            Assert.That(cachedResponse.Result, Is.Not.Null);
            Assert.That(cachedResponse.Result.Orders.Count, Is.EqualTo(5));

            Assert.That(nonCachedResponse.Result, Is.Not.Null);
            Assert.That(nonCachedResponse.Result.Orders.Count, Is.EqualTo(5));
            Assert.That(nonCachedResponse.Result.Name, Is.EqualTo("Johno"));

            Assert.That(cachedTime, Is.LessThan(nonCacheTime));
        }
开发者ID:quyenbc,项目名称:AwsGettingStarted,代码行数:28,代码来源:UnitTest1.cs

示例3: DeployApp

        public static void DeployApp(string endpoint, string appName)
        {
            try
            {
                JsonServiceClient client = new JsonServiceClient(endpoint);

                Console.WriteLine("----> Compressing files");
                byte[] folder = CompressionHelper.CompressFolderToBytes(Environment.CurrentDirectory);

                Console.WriteLine("----> Uploading files (" + ((float)folder.Length / (1024.0f*1024.0f)) + " MB)");

                File.WriteAllBytes("deploy.gzip", folder);
                client.PostFile<int>("/API/Deploy/" + appName, new FileInfo("deploy.gzip"), "multipart/form-data");
                File.Delete("deploy.gzip");

                DeployAppStatusRequest request = new DeployAppStatusRequest() { AppName = appName };
                DeployAppStatusResponse response = client.Get(request);
                while (!response.Completed)
                {
                    Console.Write(response.Log);
                    response = client.Get(request);
                }
            }
            catch (WebServiceException e)
            {
                Console.WriteLine(e.ResponseBody);
                Console.WriteLine(e.ErrorMessage);
                Console.WriteLine(e.ServerStackTrace);
            }
        }
开发者ID:zanders3,项目名称:katla,代码行数:30,代码来源:DeployAppClient.cs

示例4: UseSameRestClientError

		public void UseSameRestClientError()
		{
			var restClient = new JsonServiceClient(BaseUrl);
			var errorList = restClient.Get<ErrorCollectionResponse>("error");
			Assert.That(errorList.Result.Count, Is.EqualTo(1));

			var error = restClient.Get<ErrorResponse>("error/Test");
			Assert.That(error, !Is.Null);
		}
开发者ID:Qasemt,项目名称:NServiceKit,代码行数:9,代码来源:ErrorRestTests.cs

示例5: Main

        private static void Main()
        {
            const string serverPath = "http://localhost/";

            var client = new JsonServiceClient(serverPath);

            var regions = client.Get(new Distilleries());

            var distilleries = client.Get(new Distilleries {Region = regions[0].Region});
        }
开发者ID:cyberzed,项目名称:ServiceStack_Lightningtalk_Intro,代码行数:10,代码来源:Program.cs

示例6: Does_create_correct_instances_per_scope

        public void Does_create_correct_instances_per_scope()
        {
            var restClient = new JsonServiceClient(ListeningOn);
            var response1 = restClient.Get<IocScopeResponse>("iocscope");
            var response2 = restClient.Get<IocScopeResponse>("iocscope");

            Console.WriteLine(response2.Dump());

            Assert.That(response2.Results[typeof(FunqSingletonScope).Name], Is.EqualTo(1));
            Assert.That(response2.Results[typeof(FunqRequestScope).Name], Is.EqualTo(2));
            Assert.That(response2.Results[typeof(FunqNoneScope).Name], Is.EqualTo(4));
        }
开发者ID:support-dot-com,项目名称:ServiceStack,代码行数:12,代码来源:IocServiceTests.cs

示例7: CreateApp

        public static void CreateApp(string endpoint, string appName)
        {
            JsonServiceClient client = new JsonServiceClient(endpoint);
            client.Post(new Server.CreateAppRequest()
            {
                AppName = appName
            });

            try
            {
                Server.CreateAppStatus status;
                do
                {
                    status = client.Get(new Server.CreateAppStatusRequest() { AppName = appName });
                    if (status == null) break;
                    Console.Write(status.Log);
                    Thread.Sleep(200);
                }
                while (!status.Completed);
            }
            catch (WebServiceException e)
            {
                Console.WriteLine(e.ResponseBody);
                Console.WriteLine(e.ErrorMessage);
                Console.WriteLine(e.ServerStackTrace);
            }
        }
开发者ID:zanders3,项目名称:katla,代码行数:27,代码来源:CreateAppClient.cs

示例8: HyperCommand

        public HyperCommand(JsonServiceClient client ,Grandsys.Wfm.Services.Outsource.ServiceModel.Link link)
        {
            Content = link.Name;
            Command = new ReactiveAsyncCommand();
            Method = link.Method;
            Request = link.Request;
            Response = Command.RegisterAsyncFunction(_ => {

                Model.EvaluationItem response;
                if (string.IsNullOrEmpty(Method))
                    return null;

                switch (Method)
                {
                    default:
                        response = client.Send<Model.EvaluationItem>(Method, Request.ToUrl(Method), _ ?? Request);
                        break;
                    case "GET":
                        response = client.Get<Model.EvaluationItem>(Request.ToUrl(Method));
                        break;
                }
                return response;
            });
            Command.ThrownExceptions.Subscribe(ex => Console.WriteLine(ex.Message));
        }
开发者ID:jaohaohsuan,项目名称:master-detail,代码行数:25,代码来源:HyperCommand.cs

示例9: Test11

 void Test11(JsonServiceClient client)
 {
     Console.WriteLine("~~~~~ FindUser (newuser3) ~~~~~~~~~");
     UserResponse response = client.Get<XamarinEvolveSSLibrary.UserResponse>("User/newuser3");
     Console.WriteLine("Expected null: " + response.Exception);
     Console.WriteLine();
 }
开发者ID:bholmes,项目名称:XamarinEvolve2013Project,代码行数:7,代码来源:SSTests.cs

示例10: Main

 public static void Main(string[] args)
 {
     JsonServiceClient client = new JsonServiceClient("http://127.0.0.1:8888/");
     client.Timeout = TimeSpan.FromSeconds(60);
     client.ReadWriteTimeout = TimeSpan.FromSeconds(60);
     client.DisableAutoCompression = true;
     int success = 0, error = 0;
     Parallel.For(0, 100, i => {
         try
         {
             Console.WriteLine(i.ToString());
             StatesResult result = client.Get(new GetLastStates());
             if(result.List.Count < 4000)
                 error++;
             Console.WriteLine("Received " + result.List.Count + " items");
             success++;
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex.ToString());
             error++;
         }
     });
     Console.WriteLine(string.Format("Test completed. Success count:{0}; Error count:{1}",success,error));
     client.Dispose();
 }
开发者ID:baurzhan,项目名称:servicestacktest,代码行数:26,代码来源:Program.cs

示例11: JsonClientShouldGetPlacesToVisit

 public void JsonClientShouldGetPlacesToVisit()
 {
     var client = new JsonServiceClient(_listeningOn);
     var testRequest = new AllPlacesToVisitRequest();
     var response = client.Get(testRequest);
     Assert.AreEqual("Capital city of Australia",response.Places.FirstOrDefault().Description);
 }
开发者ID:Reidson-Industries,项目名称:places-to-visit,代码行数:7,代码来源:PlacesToVisitFunctionalTests.cs

示例12: Test_PostAndGetMessage

        public void Test_PostAndGetMessage()
        {
            // Create message
            var postRequest = new CreateMessage
            {
                ApplicationId = 1,
                Bcc = new[] { "[email protected]" },
                Body = "This is a test email.",
                Cc = new[] { "[email protected]" },
                Connection = new Connection
                {
                    EnableSsl = false,
                    Host = "localhost",
                    Port = 25
                },
                Credential = new Credential(),
                From = "[email protected]",
                ReplyTo = new[] { "[email protected]" },
                Sender = "[email protected]",
                Subject = "Test Message",
                To = new[] { "[email protected]" }
            };
            var client = new JsonServiceClient("http://localhost:59200/");
            var postResponse = client.Post(postRequest);

            // Get message
            var getRequest = new GetMessage
            {
                Id = postResponse.Id
            };
            var getResponse = client.Get(getRequest);

            Assert.Equal(2, getResponse.Status.TypeMessageStatusId);
            Assert.Equal(postResponse.Id, getResponse.Id);
        }
开发者ID:rwinte,项目名称:SendEmailHelper,代码行数:35,代码来源:MessageServiceTests.cs

示例13: CanPerform_PartialUpdate

        public void CanPerform_PartialUpdate()
        {
            var client = new JsonServiceClient("http://localhost:53990/api/");

            // back date for readability
            var created = DateTime.Now.AddHours(-2);

            // Create a record so we can patch it
            var league = new League() {Name = "BEFORE", Abbreviation = "BEFORE", DateUpdated = created, DateCreated = created};
            var newLeague = client.Post<League>(league);

            // Update Name and DateUpdated fields. Notice I don't want to update DateCreatedField.
            // I also added a fake field to show it does not cause any errors
            var updated = DateTime.Now;
            newLeague.Name = "AFTER";
            newLeague.Abbreviation = "AFTER"; // setting to after but it should not get updated
            newLeague.DateUpdated = updated;

            client.Patch<League>("http://localhost:53990/api/leagues/" + newLeague.Id + "?fields=Name,DateUpdated,thisFieldDoesNotExist", newLeague);

            var updatedLeague = client.Get<League>(newLeague);

            Assert.AreEqual(updatedLeague.Name, "AFTER");
            Assert.AreEqual(updatedLeague.Abbreviation, "BEFORE");
            Assert.AreEqual(updatedLeague.DateUpdated.ToString(), updated.ToString(), "update fields don't match");
            Assert.AreEqual(updatedLeague.DateCreated.ToString(), created.ToString(), "created fields don't match");

            // double check
            Assert.AreNotEqual(updatedLeague.DateCreated, updatedLeague.DateUpdated);
        }
开发者ID:jokecamp,项目名称:ServiceStackv4-Demo-TeamsApi,代码行数:30,代码来源:PartialUpdateTests.cs

示例14: check_secured_get_requires_credentials

 public void check_secured_get_requires_credentials()
 {
     var restClient = new JsonServiceClient(WebServerUrl);
     var error = Assert.Throws<WebServiceException>(() => restClient.Get<SecuredResponse>("/Secured/Ryan"));
     Assert.AreEqual("Unauthorized", error.Message);
     Assert.AreEqual((int)HttpStatusCode.Unauthorized, error.StatusCode);
 }
开发者ID:ryandavidhartman,项目名称:AngularAuthTutorial,代码行数:7,代码来源:SecuredServiceTest.cs

示例15: getCountries

		private IEnumerable<SelectListItem> getCountries(JsonServiceClient client, Uri countriesEn)
		{
			var countriesResponse = client.Get<Api.Messages.CountriesResponse>(countriesEn.ToString());
			return (countriesResponse != null && countriesResponse.ResponseStatus == null) ?
				countriesResponse.Countries.Select(c => new SelectListItem { Value = c.Alpha2_Code, Text = c.Name }) :
				Enumerable.Empty<SelectListItem>();
		}
开发者ID:dgg,项目名称:Crowdsource-it.org,代码行数:7,代码来源:CountriesController.cs


注:本文中的JsonServiceClient.Get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。