本文整理汇总了C#中ISettingsService.SettingsObservable方法的典型用法代码示例。如果您正苦于以下问题:C# ISettingsService.SettingsObservable方法的具体用法?C# ISettingsService.SettingsObservable怎么用?C# ISettingsService.SettingsObservable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISettingsService
的用法示例。
在下文中一共展示了ISettingsService.SettingsObservable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetupVM
public SetupVM(
ISettingsService Settings,
IConnectivityService Connectivity,
[Dispatcher] IScheduler Dispatcher,
IDiversityServiceClient Repository
)
{
this.Repository = Repository;
this.Settings = Settings;
// On First Page Visit (App Launch)
// If There already is a configuration (Settings)
// Go To Home Page
this.FirstActivation()
.SelectMany(_ => Settings.CurrentSettings())
.Select(x => (x != null) ? Page.Home : Page.SetupWelcome)
.ToMessage(Messenger);
_IsOnlineAvailable = this.ObservableToProperty(Connectivity.WifiAvailable(), x => x.IsOnlineAvailable, false, Dispatcher);
// Show current login data in case of Reset
Settings.SettingsObservable()
.Subscribe(SetLogin);
// Command To begin Setup
this.ShowLogin = new ReactiveCommand();
ShowLogin.Select(_ => Page.SetupLogin)
.ToMessage(Messenger);
// Command Condition
var userPassAndWifi =
Observable.CombineLatest(
Connectivity.WifiAvailable(),
this.WhenAny(x => x.UserName, x => x.GetValue()).Select(string.IsNullOrWhiteSpace),
this.WhenAny(x => x.Password, x => x.GetValue()).Select(string.IsNullOrWhiteSpace),
(wifi, a, b) => wifi & !(a | b));
// Command and Errorhandling
this.GetRepositories = new ReactiveAsyncCommand(userPassAndWifi);
GetRepositories.ShowInFlightNotification(Notifications, DiversityResources.Setup_Info_ValidatingLogin);
GetRepositories.ThrownExceptions
.ShowServiceErrorNotifications(Notifications)
.ShowErrorNotifications(Notifications)
.Subscribe();
var loginAndRepo = GetRepositories.RegisterAsyncObservable(GetRepositoriesObservable).Publish().PermaRef();
// Page Navigation if Login Successful
// i.e. Any repositories have been returned
loginAndRepo
.Snd()
.Subscribe(NavigateOrNotifyInvalidCredentials);
// Repo Selection
this.Database = new ListSelectionHelper<string>(Dispatcher);
loginAndRepo
.Select(t => t.Item2)
.Merge(EmptyProjectsOnLoginStart())
.Subscribe(Database.ItemsObserver);
// Settings Propagation
LatestLogin = loginAndRepo
.Fst()
.MostRecent(null)
.GetEnumerator();
// Command Condition
var repoSelected = Database.SelectedItemObservable
.Select(repo => repo != NoRepo)
.AndNoItemsInFlight(GetRepositories);
// Command and Errorhandling
this.GetProjects = new ReactiveAsyncCommand(repoSelected);
GetProjects.ShowInFlightNotification(Notifications, DiversityResources.Setup_Info_GettingProjects);
GetProjects.ThrownExceptions
.ShowServiceErrorNotifications(Notifications)
.ShowErrorNotifications(Notifications)
.Subscribe();
var loginAndProjects = GetProjects.RegisterAsyncObservable(GetProjectsObservable).Publish().PermaRef();
// Page Navigation
loginAndProjects
.Select(_ => Page.SetupProject)
.ToMessage(Messenger);
// Project Selection
Project = new ListSelectionHelper<Project>(Dispatcher);
loginAndProjects
.Snd()
.Merge(
EmptyReposOnRepoChange()
)
.Subscribe(Project.ItemsObserver);
// Settings Propagation
LatestLoginWithRepo = loginAndProjects
.Fst()
.MostRecent(null)
.GetEnumerator();
// Command Condition
//.........这里部分代码省略.........
示例2: SettingsVM
public SettingsVM(
ISettingsService Settings,
ICleanupData Cleanup,
IConnectivityService Connectivity
) {
this.Cleanup = Cleanup;
this.Settings = Settings;
this.Connectivity = Connectivity;
this.WhenAny(x => x.Model, x => x.Value)
.Where(x => x != null)
.Select(m => m.UseGPS)
.Subscribe(x => UseGPS = x);
Reset = new ReactiveAsyncCommand(Connectivity.WifiAvailable());
Reset.RegisterAsyncTask(OnReset);
var setting_changed =
this.WhenAny(x => x.UseGPS, x => x.Model,
(gps, model) => (model.Value != null) ? model.Value.UseGPS != gps.Value : false);
Save = new ReactiveCommand(setting_changed);
Messenger.RegisterMessageSource(
Save
.Do(_ => saveModel())
.Select(_ => Page.Previous)
);
RefreshVocabulary = new ReactiveCommand(Connectivity.WifiAvailable());
RefreshVocabulary
.Subscribe(_ => {
Messenger.SendMessage(Page.SetupVocabulary);
});
ManageTaxa = new ReactiveCommand();
Messenger.RegisterMessageSource(
ManageTaxa
.Select(_ => Page.TaxonManagement)
);
UploadData = new ReactiveCommand();
Messenger.RegisterMessageSource(
UploadData
.Select(_ => Page.Upload)
);
DownloadData = new ReactiveCommand();
Messenger.RegisterMessageSource(
DownloadData
.Select(_ => Page.Download)
);
Info = new ReactiveCommand();
Messenger.RegisterMessageSource(
Info
.Select(_ => Page.Info)
);
ImportExport = new ReactiveCommand();
Messenger.RegisterMessageSource(
ImportExport
.Select(_ => Page.ImportExport)
);
Settings
.SettingsObservable()
.Subscribe(x => Model = x);
}