本文整理汇总了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);
}
示例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));
}
示例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);
}
}
示例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);
}
示例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});
}
示例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));
}
示例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);
}
}
示例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));
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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>();
}