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


C# MobileServiceClient类代码示例

本文整理汇总了C#中MobileServiceClient的典型用法代码示例。如果您正苦于以下问题:C# MobileServiceClient类的具体用法?C# MobileServiceClient怎么用?C# MobileServiceClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: ReadAsync_WithRelativeUri_Generic

        public async Task ReadAsync_WithRelativeUri_Generic()
        {
            var data = new[]
            {
                new 
                {
                    ServiceUri = "http://www.test.com", 
                    QueryUri = "/about?$filter=a eq b&$orderby=c", 
                    RequestUri = "http://www.test.com/about?$filter=a eq b&$orderby=c"
                },
                new 
                {
                    ServiceUri = "http://www.test.com/", 
                    QueryUri = "/about?$filter=a eq b&$orderby=c", 
                    RequestUri = "http://www.test.com/about?$filter=a eq b&$orderby=c"
                }
            };

            foreach (var item in data)
            {
                var hijack = new TestHttpHandler();
                hijack.SetResponseContent("[{\"col1\":\"Hey\"}]");
                IMobileServiceClient service = new MobileServiceClient(item.ServiceUri, "secret...", hijack);

                IMobileServiceTable<ToDo> table = service.GetTable<ToDo>();

                await table.ReadAsync<ToDo>(item.QueryUri);

                Assert.AreEqual("TT", hijack.Request.Headers.GetValues("X-ZUMO-FEATURES").First());
                Assert.AreEqual(item.RequestUri, hijack.Request.RequestUri.ToString());
            }
        }
开发者ID:RecursosOnline,项目名称:azure-mobile-services,代码行数:32,代码来源:MobileServiceTable.Generic.Test.cs

示例2: Setup

 public void Setup()
 {
     if (_item == null)
         _item = new Item {Text = "Just some random text"};
     if (_client == null)
         _client = new MobileServiceClient(string.Empty /* Your endpoint */, string.Empty /* Your Api key */);
 }
开发者ID:DeonHeyns,项目名称:Heyns.ZumoClient,代码行数:7,代码来源:TableTests.cs

示例3: Construction

        public void Construction()
        {
            string appUrl = "http://www.test.com/";
            string appKey = "secret...";

            MobileServiceClient service = new MobileServiceClient(new Uri(appUrl), appKey);
            Assert.AreEqual(appUrl, service.ApplicationUri.ToString());
            Assert.AreEqual(appKey, service.ApplicationKey);

            service = new MobileServiceClient(appUrl, appKey);
            Assert.AreEqual(appUrl, service.ApplicationUri.ToString());
            Assert.AreEqual(appKey, service.ApplicationKey);

            service = new MobileServiceClient(new Uri(appUrl));
            Assert.AreEqual(appUrl, service.ApplicationUri.ToString());
            Assert.AreEqual(null, service.ApplicationKey);

            service = new MobileServiceClient(appUrl);
            Assert.AreEqual(appUrl, service.ApplicationUri.ToString());
            Assert.AreEqual(null, service.ApplicationKey);

            Uri none = null;
            Throws<ArgumentNullException>(() => new MobileServiceClient(none));
            Throws<FormatException>(() => new MobileServiceClient("not a valid [email protected]#[email protected]#"));
        }
开发者ID:RecursosOnline,项目名称:azure-mobile-services,代码行数:25,代码来源:MobileServiceClient.Test.cs

示例4: ExecuteTest

        /// <summary>
        /// Utility method that can be used to execute a test.  It will capture any exceptions throw
        /// during the execution of the test and return a message with details of the exception thrown.
        /// </summary>
        /// <param name="testName">The name of the test being executed.
        /// </param>
        /// <param name="test">A test to execute.
        /// </param>
        /// <returns>
        /// Either the result of the test if the test passed, or a message with the exception
        /// that was thrown.
        /// </returns>
        public static async Task<string> ExecuteTest(string testName, Func<Task<string>> test)
        {
            string resultText = null;
            bool didPass = false;

            if (client == null)
            {
                string appUrl = null;
                string appKey = null;
                App.Harness.Settings.Custom.TryGetValue("MobileServiceRuntimeUrl", out appUrl);
                App.Harness.Settings.Custom.TryGetValue("MobileServiceRuntimeKey", out appKey);

                client = new MobileServiceClient(appUrl, appKey);
            }

            try
            {
                resultText = await test();
                didPass = true;
            }
            catch (Exception exception)
            {
                resultText = string.Format("ExceptionType: {0} Message: {1} StackTrace: {2}",
                                               exception.GetType().ToString(),
                                               exception.Message,
                                               exception.StackTrace);
            }

            return string.Format("Test '{0}' {1}.\n{2}",
                                 testName,
                                 didPass ? "PASSED" : "FAILED",
                                 resultText);
        }
开发者ID:KevinOrtman,项目名称:azure-mobile-services,代码行数:45,代码来源:LoginTests.cs

示例5: RegisterAsync_ErrorEmptyChannelUri

 public async Task RegisterAsync_ErrorEmptyChannelUri()
 {
     var mobileClient = new MobileServiceClient(DefaultServiceUri);
     var exception = await AssertEx.Throws<ArgumentNullException>(
    () => mobileClient.GetPush().RegisterAsync(""));
     Assert.AreEqual(exception.Message, "Value cannot be null.\r\nParameter name: channelUri");
 }
开发者ID:brettsam,项目名称:azure-mobile-apps-net-client,代码行数:7,代码来源:PushUnit.Test.cs

示例6: RegisterAsync_ErrorEmptyChannelUri

 public async Task RegisterAsync_ErrorEmptyChannelUri()
 {
     var mobileClient = new MobileServiceClient(DefaultServiceUri);
     NSData deviceToken = null;
     var exception = await AssertEx.Throws<ArgumentNullException>(() => mobileClient.GetPush().RegisterAsync(deviceToken));
     Assert.AreEqual(exception.ParamName, "deviceToken");
 }
开发者ID:Azure,项目名称:azure-mobile-apps-net-client,代码行数:7,代码来源:PushUnit.Test.cs

示例7: RegisterAsync_ErrorEmptyChannelUri

 public async Task RegisterAsync_ErrorEmptyChannelUri()
 {
     var mobileClient = new MobileServiceClient(DefaultServiceUri);
     string emptyRegistrationId = string.Empty;
     var exception = await AssertEx.Throws<ArgumentNullException>(() => mobileClient.GetPush().RegisterAsync(emptyRegistrationId));
     Assert.AreEqual(exception.ParamName, "registrationId");
 }
开发者ID:Azure,项目名称:azure-mobile-apps-net-client,代码行数:7,代码来源:PushUnit.Test.cs

示例8: Statistika_Click

        protected void Statistika_Click(object sender, EventArgs e)
        {
            MobileServiceClient client = new MobileServiceClient();

            if (OS.Checked == true)
            {
                int []mas = new int[4];
                mas = client.statOS();
                Info.Text = "Кол-во пользователей Android: " + mas[0];
                Info1.Text = "Кол-во пользователей iOS: " + mas[1];
                Info2.Text = "Кол-во пользователей WindowsPhone: " + mas[2];
                Info3.Text = "Кол-во пользователей других ОС: " + mas[3];
            }
            if (Read.Checked == true)
            {
                Info.Text = "Для чтения телефон использует " + client.statRead()+ " людей";
                Info1.Text = "";
                Info2.Text = "";
                Info3.Text = "";
            }
            if (Price.Checked == true)
            {
                Info.Text = "Средняя цена, которую люди готовы заплатить за новый мобильный телефон: "+client.statPrice()+"$";
                Info1.Text = "";
                Info2.Text = "";
                Info3.Text = "";
            }
        }
开发者ID:NiceButterflies,项目名称:MyWorks,代码行数:28,代码来源:About.aspx.cs

示例9: ReadAsyncWithStringIdTypeAndStringIdResponseContent

        public async Task ReadAsyncWithStringIdTypeAndStringIdResponseContent()
        {
            string[] testIdData = IdTestData.ValidStringIds.Concat(
                                  IdTestData.EmptyStringIds).Concat(
                                  IdTestData.InvalidStringIds).ToArray();

            foreach (string testId in testIdData)
            {
                TestHttpHandler hijack = new TestHttpHandler();

                // Make the testId JSON safe
                string jsonTestId = testId.Replace("\\", "\\\\").Replace("\"", "\\\"");

                hijack.SetResponseContent("[{\"id\":\"" + jsonTestId + "\",\"String\":\"Hey\"}]");
                IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...", hijack);

                IMobileServiceTable<StringIdType> table = service.GetTable<StringIdType>();

                IEnumerable<StringIdType> results = await table.ReadAsync();
                StringIdType[] items = results.ToArray();

                Assert.AreEqual(1, items.Count());
                Assert.AreEqual(testId, items[0].Id);
                Assert.AreEqual("Hey", items[0].String);
            }
        }
开发者ID:rfaisal,项目名称:azure-mobile-services,代码行数:26,代码来源:MobileServiceTable.Generic.Test.cs

示例10: ListRegistrations_Native

        public async Task ListRegistrations_Native()
        {
            // Ensure Uri and method are correct for request and specify body to return for registrations list with only 1 native registration
            var expectedUri = this.GetExpectedListUri();
            var hijack = CreateTestHttpHandler(expectedUri, HttpMethod.Get, this.pushTestUtility.GetListNativeRegistrationResponse());

            MobileServiceClient mobileClient = new MobileServiceClient(DefaultServiceUri, null, hijack);
            var pushHttpClient = new PushHttpClient(mobileClient);

            var registrations = await pushHttpClient.ListRegistrationsAsync(DefaultChannelUri);

            Assert.AreEqual(registrations.Count(), 1, "Expected 1 registration.");

            var firstRegistration = registrations.First();
            var nativeReg = this.pushUtility.GetNewNativeRegistration();
            Assert.AreEqual(nativeReg.GetType(), firstRegistration.GetType(), "The type of the registration returned from ListRegistrationsAsync is not of the correct type.");

            Assert.AreEqual(firstRegistration.RegistrationId, DefaultRegistrationId, "The registrationId returned from ListRegistrationsAsync is not correct.");

            var tags = firstRegistration.Tags.ToList();
            Assert.AreEqual(tags[0], "fooWns", "tag[0] on the registration is not correct.");
            Assert.AreEqual(tags[1], "barWns", "tag[1] on the registration is not correct.");
            Assert.AreEqual(tags[2], "4de2605e-fd09-4875-a897-c8c4c0a51682", "tag[2] on the registration is not correct.");

            Assert.AreEqual(firstRegistration.PushHandle, DefaultChannelUri, "The DeviceId on the registration is not correct.");
        }
开发者ID:RecursosOnline,项目名称:azure-mobile-services,代码行数:26,代码来源:PushHttpClient.Test.cs

示例11: Button1_Click

        protected void Button1_Click(object sender, EventArgs e)
        {
            questionnaire quest = new questionnaire();
            quest.sex = Sex.Text;
            quest.age = Convert.ToInt32(Age.Text);
            quest.profession = Profession.Text;
            quest.income = Convert.ToInt32(Income.Text);
            quest.mobile_existence = 0;
            if (MobileExistence.Text.Equals("&nbspда"))
                quest.mobile_existence = 1;
            quest.brand = Brand.Text;
            quest.price = Convert.ToInt32(Price.Text);
            quest.OS = OS.Text;
            quest.furniture = 0;
            if (Furniture.Text.Equals("&nbspда"))
                quest.furniture = 1;
            quest.read = 0;
            if (Read.Text.Equals("&nbspда"))
                quest.read = 1;
            

            MobileServiceClient client = new MobileServiceClient();
            client.addQuestionnaire(quest);


        }
开发者ID:NiceButterflies,项目名称:MyWorks,代码行数:26,代码来源:Default.aspx.cs

示例12: Start

 public void Start()
 {
     setCredentials();
     client = new MobileServiceClient(appUrl, appKey);
     table = client.GetTable<Highscore>("Highscores");
     QueryItemsByScore();
 }
开发者ID:JunSmith,项目名称:Phone-Minigame,代码行数:7,代码来源:HighScore.cs

示例13: InstallationId

        public void InstallationId()
        {
            MobileServiceClient service = new MobileServiceClient("http://test.com");

            //string settings = ApplicationData.Current.LocalSettings.Values["MobileServices.Installation.config"] as string;
            //string id = (string)JToken.Parse(settings)["applicationInstallationId"];
            //Assert.IsNotNull(id);
        }
开发者ID:RecursosOnline,项目名称:azure-mobile-services,代码行数:8,代码来源:MobileServiceClient.Test.cs

示例14: RegisterAsync_ErrorHttp

 public async Task RegisterAsync_ErrorHttp()
 {
     MobileServiceClient mobileClient = new MobileServiceClient(DefaultServiceUri);
     var expectedUri = string.Format("{0}{1}/{2}", DefaultServiceUri, InstallationsPath, mobileClient.GetPush().InstallationId);
     var hijack = TestHttpDelegatingHandler.CreateTestHttpHandler(expectedUri, HttpMethod.Put, null, HttpStatusCode.BadRequest);
     mobileClient = new MobileServiceClient(DefaultServiceUri, hijack);
     var exception = await AssertEx.Throws<MobileServiceInvalidOperationException>(() => mobileClient.GetPush().RegisterAsync(this.registrationId));
     Assert.AreEqual(exception.Response.StatusCode, HttpStatusCode.BadRequest);
 }
开发者ID:Azure,项目名称:azure-mobile-apps-net-client,代码行数:9,代码来源:PushUnit.Test.cs

示例15: GetClient

 /// <summary>
 /// Get a client pointed at the test server without request logging.
 /// </summary>
 /// <returns>The test client.</returns>
 public MobileServiceClient GetClient()
 {
     if (staticClient == null)
     {
         string runtimeUrl = this.GetTestSetting("MobileServiceRuntimeUrl");
         staticClient = new MobileServiceClient(runtimeUrl, new LoggingHttpHandler(this));
     }
     return staticClient;
 }
开发者ID:brettsam,项目名称:azure-mobile-apps-net-client,代码行数:13,代码来源:FunctionalTestBase.cs


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