本文整理汇总了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());
}
}
示例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 */);
}
示例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]#"));
}
示例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);
}
示例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");
}
示例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");
}
示例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");
}
示例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 = "";
}
}
示例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);
}
}
示例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.");
}
示例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(" да"))
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(" да"))
quest.furniture = 1;
quest.read = 0;
if (Read.Text.Equals(" да"))
quest.read = 1;
MobileServiceClient client = new MobileServiceClient();
client.addQuestionnaire(quest);
}
示例12: Start
public void Start()
{
setCredentials();
client = new MobileServiceClient(appUrl, appKey);
table = client.GetTable<Highscore>("Highscores");
QueryItemsByScore();
}
示例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);
}
示例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);
}
示例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;
}