本文整理汇总了C#中MobileServiceClient.GetTable方法的典型用法代码示例。如果您正苦于以下问题:C# MobileServiceClient.GetTable方法的具体用法?C# MobileServiceClient.GetTable怎么用?C# MobileServiceClient.GetTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MobileServiceClient
的用法示例。
在下文中一共展示了MobileServiceClient.GetTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
}
示例2: 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());
}
}
示例3: Start
public void Start()
{
setCredentials();
client = new MobileServiceClient(appUrl, appKey);
table = client.GetTable<Highscore>("Highscores");
QueryItemsByScore();
}
示例4: ReadAsync_Throws_IfAbsoluteUriHostNameDoesNotMatch
public async Task ReadAsync_Throws_IfAbsoluteUriHostNameDoesNotMatch()
{
IMobileServiceClient service = new MobileServiceClient(MobileAppUriValidator.DummyMobileApp, new TestHttpHandler());
IMobileServiceTable<ToDo> table = service.GetTable<ToDo>();
var ex = await AssertEx.Throws<ArgumentException>(async () => await table.ReadAsync<ToDo>("http://www.contoso.com/about?$filter=a eq b&$orderby=c"));
Assert.AreEqual(ex.Message, "The query uri must be on the same host as the Mobile Service.");
}
示例5: Start
public void Start()
{
setCredentials();
namePanel.SetActive(false);
scoreText.transform.localPosition = new Vector2(0, 140);
pgms = gameObject.AddComponent<PregameMenuSingle>();
client = new MobileServiceClient(appUrl, appKey);
table = client.GetTable<Highscore>("Highscores");
score = pgms.getScore();
playerText.text = "Your score: " + score;
QueryItemsByScore();
}
示例6: ReadAsync_WithAbsoluteUri_Generic
public async Task ReadAsync_WithAbsoluteUri_Generic()
{
var hijack = new TestHttpHandler();
hijack.SetResponseContent("[{\"col1\":\"Hey\"}]");
IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...", hijack);
IMobileServiceTable<ToDo> table = service.GetTable<ToDo>();
await table.ReadAsync<ToDo>("http://www.test.com/about?$filter=a eq b&$orderby=c");
Assert.AreEqual("TT,LH", hijack.Request.Headers.GetValues("X-ZUMO-FEATURES").First());
Assert.AreEqual("http://www.test.com/about?$filter=a eq b&$orderby=c", hijack.Request.RequestUri.ToString());
}
示例7: DateOffsetUri
public async Task DateOffsetUri()
{
TestHttpHandler hijack = new TestHttpHandler();
IMobileServiceClient client = new MobileServiceClient("http://www.test.com", null, hijack);
IMobileServiceTable<DateOffsetExample> table = client.GetTable<DateOffsetExample>();
hijack.Response = new HttpResponseMessage(HttpStatusCode.OK);
hijack.SetResponseContent("[]");
var date = DateTimeOffset.Parse("2009-11-21T06:22:59.8600000-08:00");
await table.Where(b => b.Date == date).ToEnumerableAsync();
Assert.EndsWith(hijack.Request.RequestUri.ToString(), "$filter=(DateOffsetExampleDate eq datetimeoffset'2009-11-21T06:22:59.8600000-08:00')");
}
示例8: DateOffsetUri
public async Task DateOffsetUri()
{
TestHttpHandler hijack = new TestHttpHandler();
IMobileServiceClient client = new MobileServiceClient("http://www.test.com", null, hijack);
IMobileServiceTable<DateOffsetExample> table = client.GetTable<DateOffsetExample>();
hijack.Response.StatusCode = HttpStatusCode.OK;
hijack.SetResponseContent("[]");
DateTimeOffset date = new DateTimeOffset(2009, 11, 21, 14, 22, 59, 860, TimeSpan.FromHours(-8));
await table.Where(b => b.Date == date).ToEnumerableAsync();
Assert.EndsWith(hijack.Request.RequestUri.ToString(), "$filter=(DateOffsetExampleDate eq datetimeoffset'2009-11-21T14:22:59.8600000-08:00')");
}
示例9: LookupAsyncGeneric
public async Task LookupAsyncGeneric()
{
TestHttpHandler hijack = new TestHttpHandler();
IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...", hijack);
IMobileServiceTable<StringType> table = service.GetTable<StringType>();
hijack.SetResponseContent("{\"id\":12,\"String\":\"Hello\"}");
StringType expected = await table.LookupAsync(12);
Assert.Contains(hijack.Request.RequestUri.ToString(), "12");
Assert.AreEqual(12, expected.Id);
Assert.AreEqual("Hello", expected.String);
}
示例10: ReadAsyncWithStringIdTypeAndNullIdResponseContent
public async Task ReadAsyncWithStringIdTypeAndNullIdResponseContent()
{
TestHttpHandler hijack = new TestHttpHandler();
hijack.SetResponseContent("[{\"id\":null,\"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(null, items[0].Id);
Assert.AreEqual("Hey", items[0].String);
}
示例11: LookupAsyncGenericWithUserParameters
public async Task LookupAsyncGenericWithUserParameters()
{
var userDefinedParameters = new Dictionary<string, string>() { { "state", "CA" } };
TestHttpHandler hijack = new TestHttpHandler();
IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...", hijack);
IMobileServiceTable<StringType> table = service.GetTable<StringType>();
hijack.SetResponseContent("{\"id\":12,\"String\":\"Hello\"}");
StringType expected = await table.LookupAsync(12, userDefinedParameters);
Assert.Contains(hijack.Request.RequestUri.ToString(), "12");
Assert.Contains(hijack.Request.RequestUri.Query, "state=CA");
Assert.AreEqual(12, expected.Id);
Assert.AreEqual("Hello", expected.String);
}
示例12: ReadAsyncGeneric
public async Task ReadAsyncGeneric()
{
TestHttpHandler hijack = new TestHttpHandler();
hijack.SetResponseContent("[{\"id\":12,\"String\":\"Hey\"}]");
IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...", hijack);
IMobileServiceTable<StringType> table = service.GetTable<StringType>();
IEnumerable<StringType> results = await table.ReadAsync();
StringType[] people = results.Cast<StringType>().ToArray();
Assert.Contains(hijack.Request.RequestUri.ToString(), "StringType");
Assert.AreEqual(1, people.Count());
Assert.AreEqual(12, people[0].Id);
Assert.AreEqual("Hey", people[0].String);
}
示例13: ReadAsync_ModifiesStringId_IfItContainsIsoDateValue
[AsyncTestMethod] // this is the default buggy behavior that we've already shipped
public async Task ReadAsync_ModifiesStringId_IfItContainsIsoDateValue()
{
var hijack = new TestHttpHandler();
hijack.SetResponseContent(@"[{
""id"": ""2014-01-29T23:01:33.444Z"",
""__createdAt"": ""2014-01-29T23:01:33.444Z""
}]");
IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...", hijack);
IMobileServiceTable<ToDoWithSystemPropertiesType> table = service.GetTable<ToDoWithSystemPropertiesType>();
IEnumerable<ToDoWithSystemPropertiesType> results = await table.ReadAsync();
ToDoWithSystemPropertiesType item = results.First();
Assert.AreEqual(item.Id, "01/29/2014 23:01:33");
Assert.AreEqual(item.CreatedAt, DateTime.Parse("2014-01-29T23:01:33.444Z"));
}
示例14: ReadAsync
public async Task ReadAsync()
{
TestHttpHandler hijack = new TestHttpHandler();
hijack.SetResponseContent("{\"Count\":1, People: [{\"Id\":\"12\", \"String\":\"Hey\"}] }");
IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...", hijack);
IMobileServiceTable table = service.GetTable("tests");
JToken people = await table.ReadAsync("$filter=id eq 12");
Assert.Contains(hijack.Request.RequestUri.ToString(), "tests");
Assert.Contains(hijack.Request.RequestUri.ToString(), "$filter=id eq 12");
Assert.AreEqual(1, (int)people["Count"]);
Assert.AreEqual(12, (int)people["People"][0]["Id"]);
Assert.AreEqual("Hey", (string)people["People"][0]["String"]);
}
示例15: SingleHttpHandlerConstructor
public async Task SingleHttpHandlerConstructor()
{
TestHttpHandler hijack = new TestHttpHandler();
IMobileServiceClient service =
new MobileServiceClient(MobileAppUriValidator.DummyMobileApp, handlers: hijack);
MobileAppUriValidator mobileAppUriValidator = new MobileAppUriValidator(service);
// Ensure properties are copied over
Assert.AreEqual(MobileAppUriValidator.DummyMobileApp, service.MobileAppUri.ToString());
// Set the handler to return an empty array
hijack.SetResponseContent("[]");
JToken response = await service.GetTable("foo").ReadAsync("bar");
// Verify the handler was in the loop
Assert.StartsWith(hijack.Request.RequestUri.ToString(), mobileAppUriValidator.TableBaseUri);
}