本文整理汇总了C#中Microsoft.WindowsAzure.MobileServices.MobileServiceClient类的典型用法代码示例。如果您正苦于以下问题:C# MobileServiceClient类的具体用法?C# MobileServiceClient怎么用?C# MobileServiceClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MobileServiceClient类属于Microsoft.WindowsAzure.MobileServices命名空间,在下文中一共展示了MobileServiceClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoginAsync
public async Task<MobileServiceUser> LoginAsync(MobileServiceClient client, MobileServiceAuthenticationProvider provider)
{
try
{
var window = UIKit.UIApplication.SharedApplication.KeyWindow;
var root = window.RootViewController;
if(root != null)
{
var current = root;
while(current.PresentedViewController != null)
{
current = current.PresentedViewController;
}
Settings.LoginAttempts++;
var user = await client.LoginAsync(current, provider);
Settings.AuthToken = user?.MobileServiceAuthenticationToken ?? string.Empty;
Settings.UserId = user?.UserId ?? string.Empty;
return user;
}
}
catch(Exception e)
{
e.Data["method"] = "LoginAsync";
Xamarin.Insights.Report(e);
}
return null;
}
示例2: MainViewModel
public MainViewModel(IPopupService popupService, SynchronizationContext synchonizationContext)
{
var client = new MobileServiceClient(
_mobileServiceUrl,
_mobileServiceKey);
_liveAuthClient = new LiveAuthClient(_mobileServiceUrl);
// Apply a ServiceFilter to the mobile client to help with our busy indication
_mobileServiceClient = client.WithFilter(new DotoServiceFilter(
busy =>
{
IsBusy = busy;
}));
_popupService = popupService;
_synchronizationContext = synchonizationContext;
_invitesTable = _mobileServiceClient.GetTable<Invite>();
_itemsTable = _mobileServiceClient.GetTable<Item>();
_profilesTable = _mobileServiceClient.GetTable<Profile>();
_listMembersTable = _mobileServiceClient.GetTable<ListMembership>();
_devicesTable = _mobileServiceClient.GetTable<Device>();
_settingsTable = _mobileServiceClient.GetTable<Setting>();
SetupCommands();
LoadSettings();
}
示例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: ViewModelLocator
/// <summary>
/// Initializes a new instance of the ViewModelLocator class.
/// </summary>
public ViewModelLocator()
{
ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
ToggableNetworkInformation networkInfo = new ToggableNetworkInformation();
SimpleIoc.Default.Register<INetworkInformation>(() => networkInfo);
SimpleIoc.Default.Register<IStructuredStorage>(() => new SQLiteStructuredStorage("cache"));
SimpleIoc.Default.Register<ISynchronizer, TimestampSynchronizer>();
SimpleIoc.Default.Register<Func<Uri, bool>>(() => (u => true));
//SimpleIoc.Default.Register<ICacheProvider, DisabledCacheProvider>();
SimpleIoc.Default.Register<ICacheProvider, TimestampCacheProvider>();
SimpleIoc.Default.Register<NetworkInformationDelegate>(() =>
{
return new NetworkInformationDelegate(() => networkInfo.IsOnline, b => networkInfo.IsOnline = b);
});
SimpleIoc.Default.Register<MainViewModel>();
DelegatingHandler handler = new CacheHandler(SimpleIoc.Default.GetInstance<ICacheProvider>());
// Configure your mobile service here
MobileServiceClient MobileService = new MobileServiceClient(
Constants.MobileServiceUrl,
Constants.MobileServiceKey,
handler
);
SimpleIoc.Default.Register<IMobileServiceClient>(() => MobileService);
}
示例5: RegisterForRemotePushNotifications
public void RegisterForRemotePushNotifications(MobileServiceClient client, string channelName)
{
// Register for push with Mobile Services
IEnumerable<string> tag = new List<string>() { channelName };
var push = client.GetPush();
push.RegisterNativeAsync(DeviceToken, tag);
}
示例6: AzureDB
static AzureDB ()
{
CurrentPlatform.Init ();
MobileService = new MobileServiceClient (ApplicationURL, ApplicationKey);
GetScoreTable ();
GetUserAuthenticationTable ();
}
示例7: TodoItemManager
/// <summary>
/// Initializes a new instance of the <see cref="ToDo.TodoItemManager"/> class.
/// </summary>
public TodoItemManager ()
{
// Create the service client and make sure to use the native network stack via ModernHttpClient's NativeMessageHandler.
this.client = new MobileServiceClient (Constants.ApplicationURL, Constants.GatewayURL, new CustomMessageHandler ());
// This is where we want to store our local data.
this.store = new MobileServiceSQLiteStore (((App)App.Current).databaseFolderAndName);
// Create the tables.
this.store.DefineTable<TodoItem> ();
// Initializes the SyncContext using a specific IMobileServiceSyncHandler which handles sync errors.
this.client.SyncContext.InitializeAsync (store, new SyncHandler ());
// The ToDo items should be synced.
this.todoTable = client.GetSyncTable<TodoItem> ();
// Uncomment to clear all local data to have a fresh start. Then comment out again.
//this.todoTable.PurgeAsync();
// Create a Sqlite-Net connection to the SAME DB that is also used for syncing.
// Everything that gets inserted via this connection will not be synced.
// Azure Mobile always syncs everything, so we have to either use an alternative database or use another API to acces the same DB.
this.sqliteNetConn = new SQLiteAsyncConnection (((App)App.Current).databaseFolderAndName);
this.sqliteNetConn.CreateTableAsync<ConfigItem> ();
}
示例8: PerformUserLogin
private async void PerformUserLogin(object sender, System.Windows.Input.GestureEventArgs e)
{
username = userName.Text;
phoneNo = userPhone.Text;
if (MainPage.online == true)
{
Users user = new Users();
user.Name = username;
user.Phone_no = phoneNo;
user.uri = "uri here";
MobileService = new MobileServiceClient(
"https://shopappdata.azure-mobile.net/",
"dkwwuiuHYYQwbozjKaWRJYYpEiTjFt73"
);
userTable = MobileService.GetTable<Users>();
await userTable.InsertAsync(user);
user_id = user.Id;
MainPage.settings.Add("id", user_id);
MainPage.settings.Add("Pnumber", phoneNo);
MainPage.settings.Add("name", username);
}
else
{
// Prompt
}
// TODO: send this username and phoneno. to be added into the database
NavigationService.GoBack();
}
示例9: OnCreate
protected override async void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Activity_To_Do);
CurrentPlatform.Init ();
// Create the Mobile Service Client instance, using the provided
// Mobile Service URL
client = new MobileServiceClient(applicationURL);
await InitLocalStoreAsync();
// Set the current instance of TodoActivity.
instance = this;
// Make sure the GCM client is set up correctly.
GcmClient.CheckDevice(this);
GcmClient.CheckManifest(this);
// Get the Mobile Service sync table instance to use
toDoTable = client.GetSyncTable <ToDoItem> ();
textNewToDo = FindViewById<EditText> (Resource.Id.textNewToDo);
// Create an adapter to bind the items with the view
adapter = new ToDoItemAdapter (this, Resource.Layout.Row_List_To_Do);
var listViewToDo = FindViewById<ListView> (Resource.Id.listViewToDo);
listViewToDo.Adapter = adapter;
//// Load the items from the Mobile App backend.
//OnRefreshItemsSelected ();
}
开发者ID:ggailey777,项目名称:app-service-mobile-xamarin-android-quickstart-old,代码行数:34,代码来源:ToDoActivity.cs
示例10: ImagesListViewModel
public ImagesListViewModel(MobileServiceClient client)
{
_client = client;
//_UserName = "Demo User";
//_AlbumName = "Demo Album";
}
示例11: AuthenticateSilent
/// <summary>
/// Versucht Login, ohne einen entsprechenden Dialog zu zu zeigen.
/// </summary>
/// <returns>Ein MobileServiceUser, der awaited werden kann oder null bei Misserfolg.</returns>
internal static async Task<MobileServiceUser> AuthenticateSilent(MobileServiceClient mobileService)
{
LiveAuthClient liveAuthClient = new LiveAuthClient(APIKeys.LiveClientId);
session = (await liveAuthClient.InitializeAsync()).Session;
return await mobileService.LoginWithMicrosoftAccountAsync(session.AuthenticationToken);
}
示例12: App
public App()
{
TelemetryConfiguration.Active.InstrumentationKey = "5afcb70e-e5b7-41c5-9e57-aa6fb9f08c2a";
Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync(
Microsoft.ApplicationInsights.WindowsCollectors.Metadata |
Microsoft.ApplicationInsights.WindowsCollectors.Session |
Microsoft.ApplicationInsights.WindowsCollectors.PageView |
Microsoft.ApplicationInsights.WindowsCollectors.UnhandledException
);
InitializeComponent();
SplashFactory = (e) => new Views.Splash(e);
#region TelemetryClient Init
Telemetry = new TelemetryClient();
#endregion
MobileService =
new MobileServiceClient(
"https://petrolheadappuwp.azurewebsites.net"
);
#region App settings
var _settings = SettingsService.Instance;
RequestedTheme = _settings.AppTheme;
CacheMaxDuration = _settings.CacheMaxDuration;
ShowShellBackButton = _settings.UseShellBackButton;
#endregion
}
示例13: FinishedLaunching
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
Forms.Init ();
// create a new window instance based on the screen size
window = new UIWindow (UIScreen.MainScreen.Bounds);
#region Azure stuff
CurrentPlatform.Init ();
Client = new MobileServiceClient (
Constants.Url,
Constants.Key);
todoTable = Client.GetTable<TodoItem>();
todoItemManager = new TodoItemManager(todoTable);
App.SetTodoItemManager (todoItemManager);
#endregion region
#region Text to Speech stuff
App.SetTextToSpeech (new Speech ());
#endregion region
// If you have defined a view, add it here:
// window.RootViewController = navigationController;
window.RootViewController = App.GetMainPage ().CreateViewController ();
// make the window visible
window.MakeKeyAndVisible ();
return true;
}
示例14: App
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
this.InitializeComponent();
this.Suspending += OnSuspending;
mobileServiceClient = new MobileServiceClient("AZURE_URL_GOES_HERE", "AZURE_API_KEY_GOES_HERE");
}
示例15: ServicioDatosImpl
public ServicioDatosImpl()
{
client=new MobileServiceClient(Cadenas.UrlServicio,
Cadenas.TokenServicio);
}