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


C# JsonServiceClient.Send方法代码示例

本文整理汇总了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;

            };

        }
开发者ID:mauriliofilho,项目名称:ProteinTracker,代码行数:59,代码来源:MainActivity.cs

示例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);
                });
        }
开发者ID:garora,项目名称:AngularJSForDotNet,代码行数:34,代码来源:BicyclesServiceSpecs.cs

示例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));
        }
开发者ID:jaohaohsuan,项目名称:master-detail,代码行数:25,代码来源:HyperCommand.cs

示例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);
 }
开发者ID:defacas,项目名称:TryServiceStack,代码行数:8,代码来源:Main.cs

示例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;
        }
开发者ID:joshua1,项目名称:PortalProject2,代码行数:9,代码来源:PushService.cs

示例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" } }
            });
        }
开发者ID:CLupica,项目名称:ServiceStack,代码行数:11,代码来源:AuthWebTests.cs

示例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"
         }
     );
 }
开发者ID:roland,项目名称:TestServiceStackService,代码行数:11,代码来源:AuthenticateTests.cs

示例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;
		}
开发者ID:Qasemt,项目名称:NServiceKit,代码行数:17,代码来源:AuthTestsBase.cs

示例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";
 }
开发者ID:MBrekhof,项目名称:ssforms,代码行数:11,代码来源:Login.xaml.cs

示例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;
        }
开发者ID:anton-nesterenko,项目名称:ServiceStack,代码行数:12,代码来源:AuthTestsBase.cs

示例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});
 }
开发者ID:HyveMynd,项目名称:BlueprintCS,代码行数:12,代码来源:PathFindingRestTest.cs

示例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);

            }
        }
开发者ID:aicl,项目名称:SuperGym,代码行数:13,代码来源:Main.cs

示例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();
        }
开发者ID:OleksandrKulchytskyi,项目名称:NServiceStack-Test,代码行数:39,代码来源:Program.cs

示例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());

            }
        }
开发者ID:majorsilence,项目名称:WebServiceDotNetTesting,代码行数:17,代码来源:Main.cs

示例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();
        }
开发者ID:khalidabuhakmeh,项目名称:EndToEnd,代码行数:17,代码来源:RegistrationTests.cs


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