本文整理汇总了C#中JsonServiceClient.Send方法的典型用法代码示例。如果您正苦于以下问题:C# JsonServiceClient.Send方法的具体用法?C# JsonServiceClient.Send怎么用?C# JsonServiceClient.Send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonServiceClient
的用法示例。
在下文中一共展示了JsonServiceClient.Send方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
client = new JsonServiceClient("http://vmredisserver.cloudapp.net/api");
PopulateSelectUsers();
Spinner usersSpinner = FindViewById<Spinner>(Resource.Id.usersSpinner);
usersSpinner.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) => {
TextView goalTextView = FindViewById<TextView>(Resource.Id.usersGoalTextView);
TextView totalTextView = FindViewById<TextView>(Resource.Id.usersTotalTextView);
var selectedUser = users[e.Position];
goalTextView.Text = selectedUser.Goal.ToString();
totalTextView.Text = selectedUser.Total.ToString();
};
//Adicionando novo usuario com a sua destinada meta de proteinas ao banco de dados.
var addUserButton = FindViewById<Button>(Resource.Id.addNewUerButton);
addUserButton.Click += (object sender, EventArgs e) =>
{
TextView nameTextView = FindViewById<TextView>(Resource.Id.nameTextView2);
TextView goalTextView = FindViewById<TextView>(Resource.Id.goalTextView2);
var goal = int.Parse(goalTextView.Text);
var response = client.Send(new AddUser { Goal = goal, Name = nameTextView.Text });
PopulateSelectUsers();
nameTextView.Text = string.Empty;
goalTextView.Text = string.Empty;
Toast.MakeText(this, "Add New User", ToastLength.Short).Show();
};
//Addicionando proteinas (amount) ao usuario selecionado no Spinner
var addProteinButton = FindViewById<Button>(Resource.Id.addProteinButton);
addProteinButton.Click += (object sender, EventArgs e) =>
{
TextView amountTextView = FindViewById<TextView>(Resource.Id.amountTextView);
var amount = int.Parse(amountTextView.Text);
var selectedUser = users[usersSpinner.SelectedItemPosition];
var response = client.Send(new AddProtein { Amount = amount, UserId = selectedUser.Id });
selectedUser.Total = response.NewTotal;
TextView totalTextView = FindViewById<TextView>(Resource.Id.usersTotalTextView);
totalTextView.Text = selectedUser.Total.ToString();
amountTextView.Text = string.Empty;
};
}
示例2: GetBicyclesWithSeedData
public void GetBicyclesWithSeedData()
{
List<Bicycle> bicycles = null;
"Given the seed data is created"
.Given(() => { });
"When a GET bicycles request is made using admin credentials"
.When(() =>
{
var restClient = new JsonServiceClient(BaseUrl);
restClient.Send(new Auth
{
provider = CredentialsAuthProvider.Name,
UserName = "[email protected]",
Password = "admin",
RememberMe = true,
});
bicycles = restClient.Get(new GetBicycles());
});
"Then the response is not null."
.Then(() =>
{
Assert.NotNull(bicycles);
});
"And 4 bicycles are returned."
.Then(() =>
{
Assert.Equal(4, bicycles.Count);
});
}
示例3: 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));
}
示例4: Main
public static void Main(string[] args)
{
Console.Write("What is your name? ");
var name = Console.ReadLine();
var client = new JsonServiceClient("http://127.0.0.1:8080/servicestack");
var response = client.Send<HelloResponse>(new Hello { Name = name });
Console.WriteLine(response.Result);
}
示例5: DoSendMessage
public static MessageResponse DoSendMessage(MessageOptions data)
{
JsonServiceClient client = new JsonServiceClient(ServiceUrl);
//var client = new RestClient(ServiceUrl);
var toSend = JsonSerializer.SerializeToString(data);
MessageResponse response = client.Send<MessageResponse>("POST","createMessage",data);
return response;
}
示例6: Can_Authenticate_with_Metadata
public void Can_Authenticate_with_Metadata()
{
var client = new JsonServiceClient(BaseUri);
var response = client.Send(new Authenticate
{
UserName = "[email protected]",
Password = "test",
Meta = new Dictionary<string, string> { { "custom", "metadata" } }
});
}
示例7: T00_Test_authenticate_with_user1_json
public void T00_Test_authenticate_with_user1_json()
{
var restClient = new JsonServiceClient("http://localhost:25000/json/asynconeway/AuthenticateRequest");
var response = restClient.Send<AuthenticateResponse>(
new AuthenticateRequest()
{
Username = "user1",
Password = "password"
}
);
}
示例8: Login
/// <summary>Login.</summary>
///
/// <param name="userName">Name of the user.</param>
/// <param name="password">The password.</param>
///
/// <returns>A JsonServiceClient.</returns>
public JsonServiceClient Login(string userName, string password)
{
var client = new JsonServiceClient(BaseUri);
client.Send(new Auth {
UserName = userName,
Password = password,
RememberMe = true,
});
return client;
}
示例9: Button_OnClicked
private void Button_OnClicked(object sender, EventArgs e)
{
Button button = (Button)sender;
var client = new JsonServiceClient("http://10.136.46.60:8088");
var authResponse = client.Send<AuthenticateResponse>(new Authenticate
{
UserName = "Admin",
Password = "Admin"
});
lblMessage.Text = "Logged in";
}
示例10: AuthenticateWithAdminUser
public JsonServiceClient AuthenticateWithAdminUser()
{
var registration = CreateAdminUser();
var adminServiceClient = new JsonServiceClient(BaseUri);
adminServiceClient.Send<AuthResponse>(new Auth {
UserName = registration.UserName,
Password = registration.Password,
RememberMe = true,
});
return adminServiceClient;
}
示例11: OnTestSetup
public void OnTestSetup()
{
_host = new ServiceTestAppHost();
_host.Init();
_host.Start(ServiceTestAppHost.BaseUrl);
_client = new JsonServiceClient(ServiceTestAppHost.BaseUrl);
IocBox.Kernel = new StandardKernel(new RealDomainModule(), new RealInfrastructureModule());
string pass;
_testUser = DbDataGenerator.AddUserToDatabase(out pass);
_testBlueprint = DbDataGenerator.AddBlueprintToDatabase(_testUser.Id);
_client.Send(new Auth {UserName = _testUser.Email, Password = pass});
}
示例12: Main
public static void Main(string[] args)
{
string url = "http://localhost/autenticacion";
using (JsonServiceClient client = new JsonServiceClient(url))
{
//var request = new LoginData { UserName="sistema", Password="billazoperrazo" };
var request = new LoginData { UserName="yadira", Password="ctyd1525" };
var response = client.Send<LoginResponse>(request);
Console.WriteLine(response.Success);
}
}
示例13: Main
static void Main(string[] args)
{
int amount = -1;
JsonServiceClient client = null;
client = new JsonServiceClient("http://localhost:4057") { UserName = "jsuser", Password = "password1" };
var assignRResp = client.Send<AssignRolesResponse>(new AssignRoles
{
UserName = "jsuser",
Roles = new ArrayOfString("StatusUser"),
Permissions = new ArrayOfString("GetStatus")
});
try
{
var repsspp = client.Send<StatusResponse>(new StatusQuery() { Date = DateTime.Now });
}
catch (WebServiceException ex)
{
if (ex.Message != null) { }
}
client.PostAsync<MagicResponse>(new MagicRequest { Id = 1 },
resp => Console.WriteLine(resp.OutId), (resp, err) => { Console.WriteLine(err.Message); });
while (amount != 0)
{
Console.WriteLine("Enter a protein amount (press 0 to exit)");
if (int.TryParse(Console.ReadLine(), out amount))
{
var response = client.Send<EntryResponse>(new Entry { Amount = amount, Time = DateTime.Now });
Console.WriteLine("Response, ID: " + response.Id);
}
}
var reps2 = client.Post<StatusResponse>("status", new StatusQuery { Date = DateTime.Now });
Console.WriteLine("{0} / {1}", reps2.Total, reps2.Goal);
Console.WriteLine(reps2.Message);
Console.ReadLine();
}
示例14: Main
public static void Main(string[] args)
{
using (var client = new JsonServiceClient(address))
{
var response = client.Send<LayerListResponse>(new LayerList()
{
LayerName = "123"
});
var response2 = client.Get(new LayerList()
{
LayerName = "Abc"
});
var response3 = client.Get(new LayerListAll());
}
}
示例15: Can_register_a_new_user
public void Can_register_a_new_user()
{
var client = new JsonServiceClient(ListeningOn);
var response = client.Send(new Registration
{
UserName = "newuser",
Password = "[email protected]",
DisplayName = "New User",
Email = "[email protected]",
FirstName = "New",
LastName = "User"
});
response.Should().NotBeNull();
response.UserId.Should().NotBeNullOrEmpty();
}