本文整理汇总了C#中JsonServiceClient.Put方法的典型用法代码示例。如果您正苦于以下问题:C# JsonServiceClient.Put方法的具体用法?C# JsonServiceClient.Put怎么用?C# JsonServiceClient.Put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonServiceClient
的用法示例。
在下文中一共展示了JsonServiceClient.Put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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));
}
示例2: AddUsers
void AddUsers(JsonServiceClient client, string[] users)
{
foreach (string userName in users)
{
User user = new User { UserName = userName, Password = MD5Helper.CalculateMD5Hash("password123") };
UserResponse response = client.Put<XamarinEvolveSSLibrary.UserResponse>("User", user);
}
}
示例3: Test10
void Test10(JsonServiceClient client)
{
Console.WriteLine("~~~~~ AddUser (newuser3) ~~~~~~~~~");
User user = new User()
{
UserName = "newuser3"
};
UserResponse response = client.Put<XamarinEvolveSSLibrary.UserResponse>("User", user);
Console.WriteLine();
}
示例4: Calling_not_implemented_method_returns_405
public void Calling_not_implemented_method_returns_405()
{
var client = new JsonServiceClient(ListeningOn);
try
{
var response = client.Put<MoviesZipResponse>("movies.zip", new MoviesZip());
Assert.Fail("Should throw 405 excetpion");
}
catch (WebServiceException ex)
{
Assert.That(ex.StatusCode, Is.EqualTo(405));
}
}
示例5: Update
public ActionResult Update(Models.Translation model)
{
using (var client = new JsonServiceClient())
{
var putUrl = new Uri(Request.Url, string.Format("/api/translation/{0}/{1}", model.Alpha2, model.Language));
var translation = new Api.Messages.Translation
{
Data = model.Name
};
var response = client.Put<Api.Messages.TranslationResponse>(putUrl.ToString(), translation);
}
return Redirect("Index");
}
示例6: Main
private static void Main(string[] args)
{
var client = new JsonServiceClient(Settings.Default.ServiceAddress);
client.Put(new PutMailCommand
{
Sender = "[email protected]",
Receivers = new List<string>
{
"[email protected]",
"[email protected]",
}
});
Console.WriteLine("Mail has been added");
Console.ReadKey();
}
示例7: Main
private static void Main()
{
AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;
// PerformanceTest();
var client = new JsonServiceClient(Settings.Default.ServiceAddress);
var createRequest = new CreateClientRequest
{
Email = "[email protected]"
};
var response = client.Post<ClientResponse>(createRequest);
Console.WriteLine("POST Response: {0}\n", response);
var updateRequest = new UpdateClientRequest
{
Email = "[email protected]",
Id = response.Id
};
response = client.Put<ClientResponse>(updateRequest);
Console.WriteLine("PUT Response: {0}\n", response);
var getClientRequest = new GetClientRequest
{
Id = response.Id,
Date = DateTime.Now.Date
};
response = client.Get<ClientResponse>(getClientRequest);
Console.WriteLine("GET Response: {0}\n", response);
var deleteRequest = new DeleteClientRequest
{
Id = response.Id
};
client.Delete(deleteRequest);
var certificate = new MemoryStream(File.ReadAllBytes("Certificate.cer"));
var uploadRequest = new UploadRequest
{
FileContents = certificate.ToArray(),
OriginalFileName = "MyFileName.cert",
UploaderId = Guid.NewGuid().ToString()
};
client.Post(uploadRequest);
Console.ReadKey();
}
示例8: Test1
void Test1(JsonServiceClient client)
{
Console.WriteLine("~~~~~ AddUser (newuser2) ~~~~~~~~~");
User user = new User()
{
UserName = "newuser2",
FullName = "Awesome guy",
City = "funkytown",
Email = "[email protected]",
Phone = "8675309",
Password = "pass",
Avatar = "avatar.jpg",
Title = "the man",
Company = "three's",
};
UserResponse response = client.Put<XamarinEvolveSSLibrary.UserResponse>("User", user);
Console.WriteLine();
}
示例9: UpdateThing
public void UpdateThing()
{
using (FakeServer fs = new FakeServer().StartWithRealRepos())
{
using(JsonServiceClient client = new JsonServiceClient(FakeServer.BaseUri)){
var newThing = new Thing(){ Name="d", Title="D", Description="Not C++", Quadrantid=Quadrant.Languages};
newThing = fs.RealThingsRepos.StoreNew(newThing);
var updatedThing = new Thing() { Name = "d", Description = ", whatever" };
client.Put(updatedThing);
ThingsRequest req = new ThingsRequest(){Names = new string[] { "d" }};
IEnumerable<Thing> res = client.Get(req.UrlEncodeNames());
res.Count().ShouldBe(1);
Thing result = res.Single();
result.Quadrantid.ShouldBe(newThing.Quadrantid);
result.Description.ShouldBe(updatedThing.Description);
}
}
}
示例10: Run
public void Run()
{
var restClient = new JsonServiceClient(BaseUri);
var player = restClient.Post<Player>(String.Format("{0}/players", BaseUri), new Player(new Position(33.051281, -96.676662)));
Assert.That(player.Id, Is.EqualTo(1));
Assert.That(player.Position.Latitude, Is.EqualTo(33.051281));
Assert.That(player.Position.Longitude, Is.EqualTo(-96.676662));
player.Position = new Position(33.051524, -96.677306);
player = restClient.Put<Player>(String.Format("{0}/players/{1}", BaseUri, player.Id), player);
Assert.That(player.Position.Latitude, Is.EqualTo(33.051524));
Assert.That(player.Position.Longitude, Is.EqualTo(-96.677306));
var newPlayer = restClient.Post<Player>(String.Format("{0}/players", BaseUri), new Player(new Position(33.051281, -96.676662)));
Assert.That(newPlayer.Id, Is.EqualTo(2));
Assert.That(newPlayer.Position.Latitude, Is.EqualTo(33.051281));
Assert.That(newPlayer.Position.Longitude, Is.EqualTo(-96.676662));
var nearby = restClient.Get<List<Player>>(String.Format("{0}/players/{1}/nearby", BaseUri, player.Id));
Assert.That(nearby.Count, Is.EqualTo(2));
nearby = restClient.Get<List<Player>>(String.Format("{0}/players/nearby/{1}/{2}", BaseUri, 33.050130, -96.676641));
Assert.That(nearby.Count, Is.EqualTo(2));
var heartbeat = restClient.Get<HeartBeatResponse>(String.Format("{0}/heartbeat/{1}/{2}", BaseUri, player.Position.Latitude, player.Position.Longitude));
Assert.NotNull(heartbeat);
var reset = restClient.Get<ResetPlayers>(String.Format("{0}/players/reset", BaseUri));
Assert.NotNull(reset);
try
{
restClient.Get<List<Player>>(String.Format("{0}/players/{1}/nearby", BaseUri, player.Id));
}
catch (Exception ex)
{
Assert.AreEqual(ex.Message, "ArgumentException");
}
}
示例11: Main
private static void Main()
{
AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;
// PerformanceTest();
var client = new JsonServiceClient(Settings.Default.ServiceAddress);
var createRequest = new CreateClientRequest
{
Email = "[email protected]"
};
var response = client.Post<ClientResponse>(createRequest);
Console.WriteLine("POST Response: {0}\n", response);
var updateRequest = new UpdateClientRequest
{
Email = "[email protected]",
Id = response.Id
};
response = client.Put<ClientResponse>(updateRequest);
Console.WriteLine("PUT Response: {0}\n", response);
var getClientRequest = new GetClientRequest
{
Id = response.Id,
Date = DateTime.Now.Date
};
response = client.Get<ClientResponse>(getClientRequest);
Console.WriteLine("GET Response: {0}\n", response);
var deleteRequest = new DeleteClientRequest
{
Id = response.Id
};
client.Delete(deleteRequest);
Console.ReadKey();
}
示例12: JsonServiceClient
//Обновить
public static void Записать(ТСДФорматыДанныхЗапрос ТСДФорматыДанныхЗапрос)
{
var Урл = "http://localhost:1337/Справочники/ТСДФорматыДанных?format=json";
var Клиент = new JsonServiceClient(Урл);
var ТСДФорматыДанныхОтвет = Клиент.Put(ТСДФорматыДанныхЗапрос);
}
示例13: JsonServiceClient
//Обновить
public static void Записать(ТипыСкидокНаценокЗапрос ТипыСкидокНаценокЗапрос)
{
var Урл = "http://localhost:1337/Справочники/ТипыСкидокНаценок?format=json";
var Клиент = new JsonServiceClient(Урл);
var ТипыСкидокНаценокОтвет = Клиент.Put(ТипыСкидокНаценокЗапрос);
}
示例14: JsonServiceClient
//Обновить
public static void Записать(УсловияПродажЗапрос УсловияПродажЗапрос)
{
var Урл = "http://localhost:1337/Справочники/УсловияПродаж?format=json";
var Клиент = new JsonServiceClient(Урл);
var УсловияПродажОтвет = Клиент.Put(УсловияПродажЗапрос);
}
示例15: JsonServiceClient
//Обновить
public static void Записать(ВидыНалоговыхОргановЗапрос ВидыНалоговыхОргановЗапрос)
{
var Урл = "http://localhost:1337/Справочники/ВидыНалоговыхОрганов?format=json";
var Клиент = new JsonServiceClient(Урл);
var ВидыНалоговыхОргановОтвет = Клиент.Put(ВидыНалоговыхОргановЗапрос);
}