本文整理汇总了C#中ObservableAsPropertyHelper类的典型用法代码示例。如果您正苦于以下问题:C# ObservableAsPropertyHelper类的具体用法?C# ObservableAsPropertyHelper怎么用?C# ObservableAsPropertyHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ObservableAsPropertyHelper类属于命名空间,在下文中一共展示了ObservableAsPropertyHelper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: OAPHShouldRethrowErrors
public void OAPHShouldRethrowErrors()
{
var input = new Subject<int>();
var sched = new TestScheduler();
var fixture = new ObservableAsPropertyHelper<int>(input,
_ => { }, -5, sched);
Assert.AreEqual(-5, fixture.Value);
(new[] { 1, 2, 3, 4 }).Run(x => input.OnNext(x));
sched.Run();
Assert.AreEqual(4, fixture.Value);
input.OnError(new Exception("Die!"));
sched.Run();
try {
Assert.AreEqual(4, fixture.Value);
} catch {
return;
}
Assert.Fail("We should've threw there");
}
开发者ID:charles-cai,项目名称:ReactiveXaml,代码行数:26,代码来源:ObservableAsPropertyHelperTest.cs
示例2: LoginRouteViewModel
public LoginRouteViewModel(IScreen hostScreen)
{
HostScreen = hostScreen;
var authentication = new Authentication();
var canLogin = this.WhenAny(x => x.LoginName,
x => x.Password,
(l, p) => !String.IsNullOrWhiteSpace(l.Value) && !String.IsNullOrWhiteSpace(p.Value));
LoginCommand = new ReactiveCommand(canLogin);
var loggedIn = LoginCommand.RegisterAsync(_ => Observable.Start(() =>
{
var authenticationResult = authentication.AuthenticateAsync(LoginName,
Password).
Result;
return authenticationResult == AuthenticationResult.Authenticated
? "Přihlášen"
: "Nepřihlášen";
}));
loggedIn.Subscribe(s =>
{
if (s == "Přihlášen")
HostScreen.Router.Navigate.Execute(new PersonListViewModel(HostScreen));
});
message = new ObservableAsPropertyHelper<string>(loggedIn,
s => raisePropertyChanged("Message"));
}
开发者ID:jiravanet,项目名称:Prezentace-ReactiveUI,代码行数:25,代码来源:LoginRouteViewModel.cs
示例3: CountryViewModel
public CountryViewModel(string name, float population, Task<IBitmap> countryFlag, double longitude, double latitude)
: base(name, population, longitude, latitude)
{
this.countryFlag = countryFlag
.ToObservable()
.ToProperty(this, x => x.CountryFlag);
}
开发者ID:dotnetcurry,项目名称:wpf-items-control,代码行数:7,代码来源:MainWindow.xaml.cs
示例4: IndexViewModel
public IndexViewModel(IRepository repo)
{
this.repo = repo;
this.refreshCommand = ReactiveCommand.Create();
this.repositoryStatus = this.refreshCommand.Select(u =>
{
return repo.RetrieveStatus(new StatusOptions() { Show = StatusShowOption.IndexAndWorkDir });
}).ToProperty(this, vm => vm.RepositoryStatus);
this.statusEntries = this
.WhenAny(vm => vm.RepositoryStatus, change =>
{
var status = change.GetValue();
return status.CreateDerivedCollection(s => s, null, null, null, this.refreshCommand);
}).ToProperty(this, vm => vm.StatusEntries);
var resetSignal = this.WhenAny(vm => vm.StatusEntries, change =>
{
return 0;
});
var allEntries = this.WhenAny(vm => vm.StatusEntries, change => change.GetValue());
this.unstagedEntries = allEntries.Select(s =>
{
return s.CreateDerivedCollection(i => i, i => Unstaged(i.State), null, resetSignal);
}).ToProperty(this, vm => vm.UnstagedEntries);
this.stagedEntries = allEntries.Select(s =>
{
return s.CreateDerivedCollection(i => i, i => Staged(i.State), null, resetSignal);
}).ToProperty(this, vm => vm.StagedEntries);
}
开发者ID:abbottdev,项目名称:gitreminder,代码行数:35,代码来源:IndexViewModel.cs
示例5: MainViewModel
public MainViewModel()
{
_multiEngine = this.ObservableToProperty(
Engines.Changed.Select(_ => Engines.Count > 1),
vm => vm.MultiEngine);
_singleEngine = this.ObservableToProperty(
Engines.Changed.Select(_ => Engines.Count == 1),
vm => vm.SingleEngine);
_languages = this.ObservableToProperty(
this.ObservableForProperty(vm => vm.SelectedEngine)
.Select(_ => SelectedEngine.Value.Languages),
vm => vm.Languages);
_languages.Subscribe(_ => EnsureLanguage());
Engines.Changed.Subscribe(_ => EnsureEngine());
Observable.Merge(
this.ObservableForProperty(vm => vm.DesignTimeMode).IgnoreValues(),
this.ObservableForProperty(vm => vm.SelectedEngine).IgnoreValues(),
this.ObservableForProperty(vm => vm.SelectedLanguage).IgnoreValues(),
this.ObservableForProperty(vm => vm.RazorCode).IgnoreValues())
.ObserveOn(RxApp.DeferredScheduler)
.Subscribe(_ => Regenerate());
this.PropertyChanged += MainViewModel_PropertyChanged;
}
开发者ID:Kathy2013,项目名称:RazorSpy,代码行数:25,代码来源:MainViewModel.cs
示例6: VisualTreeViewModel
public VisualTreeViewModel(Control root)
{
Nodes = VisualTreeNode.Create(root);
_details = this.WhenAnyValue(x => x.SelectedNode)
.Select(x => x != null ? new ControlDetailsViewModel(x.Control) : null)
.ToProperty(this, x => x.Details);
}
开发者ID:Arlorean,项目名称:Perspex,代码行数:7,代码来源:VisualTreeViewModel.cs
示例7: MiniMainWindowViewModel
public MiniMainWindowViewModel(ITrayMainWindowViewModel trayMainWindowViewModel) {
TrayViewModel = trayMainWindowViewModel;
_taskbarToolTip = this.WhenAnyValue(x => x.DisplayName, x => x.TrayViewModel.Status,
trayMainWindowViewModel.FormatTaskbarToolTip)
.ToProperty(this, x => x.TaskbarToolTip);
OpenPopup = ReactiveCommand.Create();
ShowNotification = ReactiveCommand.CreateAsyncTask(async x => (ITrayNotificationViewModel) x);
Deactivate = ReactiveCommand.Create().DefaultSetup("Deactivate");
Deactivate.Subscribe(x => {
if (TrayViewModel.MainArea is IWelcomeViewModel)
return;
Close.Execute(null);
});
OpenPopup
.Take(1)
.Delay(TimeSpan.FromSeconds(20))
.ObserveOnMainThread()
.Subscribe(x => TrayViewModel.RemoveUpdatedState());
// TODO: Make this a setting?
/* Listen<ApiUserActionStarted>()
.ObserveOnMainThread()
.InvokeCommand(OpenPopup);*/
Listen<AppStateUpdated>()
.Where(x => x.UpdateState == AppUpdateState.Updating)
.ObserveOnMainThread()
.InvokeCommand(OpenPopup);
Listen<ShowTrayNotification>()
.Select(x => new TrayNotificationViewModel(x.Subject, x.Text, x.CloseIn, x.Actions))
.ObserveOnMainThread()
.InvokeCommand(ShowNotification);
}
开发者ID:MaHuJa,项目名称:withSIX.Desktop,代码行数:33,代码来源:MiniMainWindowViewModel.cs
示例8: ClientAnnotationViewModel
public ClientAnnotationViewModel(ISharedDataService sharedDataService, MeetingViewModel meeting) : base(sharedDataService, meeting)
{
// create the client annotations property, a mapped version of the agent's properties based on the screen sizes.
_annotationsChangedSub = _clientAnnotations = AnnotationsModel
.WhenAnyValue(v => v.Annotations, v => v.Select(p => CreateAnnotationViewModel(p)))
.ToProperty(this, v => v.Annotations);
}
开发者ID:reactiveui-forks,项目名称:VirtualSales,代码行数:7,代码来源:ClientAnnotationViewModel.cs
示例9: MainWindowViewModel
public MainWindowViewModel()
{
var whenAnyColorChanges = this.WhenAny(x => x.Red, x => x.Green, x => x.Blue,
(r, g, b) => Tuple.Create(r.Value, g.Value, b.Value))
.Select(intsToColor);
_FinalColor = whenAnyColorChanges
.Where(x => x != null)
.Select(x => x.Value)
.ToProperty(this, x => x.FinalColor);
Ok = ReactiveCommand.Create(whenAnyColorChanges.Select(x => x != null));
_Images = this.WhenAny(x => x.FinalColor, x => x.Value)
.Throttle(TimeSpan.FromSeconds(0.7), RxApp.MainThreadScheduler)
.Do(_ => IsBusy = true)
.Select(x => imagesForColor(x))
.Switch()
.SelectMany(imageListToImages)
.ObserveOn(RxApp.MainThreadScheduler)
.Do(_ => IsBusy = false)
.ToProperty(this, x => x.Images);
_Images.ThrownExceptions.Subscribe(ex => this.Log().WarnException("Can't load images", ex));
}
开发者ID:modulexcite,项目名称:RxUI_QCon,代码行数:25,代码来源:MainWindowViewModel.cs
示例10: SoundCloudSongViewModel
public SoundCloudSongViewModel(SoundCloudSong model)
: base(model)
{
this.hasThumbnail = this.WhenAnyValue(x => x.Thumbnail)
.Select(x => x != null)
.ToProperty(this, x => x.HasThumbnail);
}
开发者ID:reactiveui-forks,项目名称:Espera,代码行数:7,代码来源:SoundCloudSongViewModel.cs
示例11: GistCreationViewModel
public GistCreationViewModel(
IRepositoryHost repositoryHost,
ISelectedTextProvider selectedTextProvider,
IGistPublishService gistPublishService,
IUsageTracker usageTracker)
{
Title = Resources.CreateGistTitle;
apiClient = repositoryHost.ApiClient;
this.gistPublishService = gistPublishService;
this.usageTracker = usageTracker;
FileName = VisualStudio.Services.GetFileNameFromActiveDocument() ?? Resources.DefaultGistFileName;
SelectedText = selectedTextProvider.GetSelectedText();
// This class is only instantiated after we are logged into to a github account, so we should be safe to grab the first one here as the defaut.
account = repositoryHost.ModelService.GetAccounts()
.FirstAsync()
.Select(a => a.First())
.ObserveOn(RxApp.MainThreadScheduler)
.ToProperty(this, vm => vm.Account);
var canCreateGist = this.WhenAny(
x => x.FileName,
fileName => !String.IsNullOrEmpty(fileName.Value));
CreateGist = ReactiveCommand.CreateAsyncObservable(canCreateGist, OnCreateGist);
}
开发者ID:github,项目名称:VisualStudio,代码行数:27,代码来源:GistCreationViewModel.cs
示例12: MyIssuesViewModel
public MyIssuesViewModel(ISessionService sessionService)
: base(sessionService)
{
_sessionService = sessionService;
Title = "My Issues";
Filter = MyIssuesFilterModel.CreateOpenFilter();
_selectedFilter = this.WhenAnyValue(x => x.Filter)
.Select(x =>
{
if (x == null || _openFilter.Equals(x))
return 0;
return _closedFilter.Equals(x) ? 1 : -1;
})
.ToProperty(this, x => x.SelectedFilter);
this.WhenAnyValue(x => x.Filter).Skip(1).Subscribe(filter => {
InternalItems.Clear();
LoadCommand.ExecuteIfCan();
CustomFilterEnabled = !(filter == _closedFilter || filter == _openFilter);
});
GoToFilterCommand = ReactiveCommand.Create();
GoToFilterCommand.Subscribe(_ => {
var vm = this.CreateViewModel<MyIssuesFilterViewModel>();
vm.Init(Filter);
vm.SaveCommand.Subscribe(filter => Filter = filter);
NavigateTo(vm);
});
}
开发者ID:runt18,项目名称:CodeHub,代码行数:31,代码来源:MyIssuesViewModel.cs
示例13: Threshold
public Threshold(IObservable<int> thresholdState)
{
//this.WhenAny(vm => vm.Good, vm => vm.Bad, vm => vm.OK, (g, b, o) =>
//{
//});
this.Good = new Range();
this.Bad = new Range();
this.OK = new Range();
var obs = thresholdState.Select(value =>
{
if (value.Between(this.Good.Min, this.Good.Max))
return "Good";
if (value.Between(this.OK.Min, this.ok.Max))
return "OK";
if (value.Between(this.Bad.Min, this.bad.Max))
return "Bad";
return "";
});
this.state = obs.ToProperty(this, vm => vm.State);
obs.Subscribe(_ =>
{
Trace.WriteLine(_);
});
}
开发者ID:abbottdev,项目名称:gitreminder,代码行数:31,代码来源:Threshold.cs
示例14: OAuthFlowLoginViewModel
public OAuthFlowLoginViewModel(
IAccountsRepository accountsRepository,
IActionMenuFactory actionMenuService,
IAlertDialogFactory alertDialogService)
{
_accountsRepository = accountsRepository;
_alertDialogService = alertDialogService;
Title = "Login";
var oauthLogin = ReactiveCommand.Create().WithSubscription(_ =>
NavigateTo(this.CreateViewModel<OAuthTokenLoginViewModel>()));
var canLogin = this.WhenAnyValue(x => x.Code).Select(x => !string.IsNullOrEmpty(x));
var loginCommand = ReactiveCommand.CreateAsyncTask(canLogin,_ => Login(Code));
loginCommand.Subscribe(x => MessageBus.Current.SendMessage(new LogoutMessage()));
LoginCommand = loginCommand;
ShowLoginOptionsCommand = ReactiveCommand.CreateAsyncTask(sender =>
{
var actionMenu = actionMenuService.Create();
actionMenu.AddButton("Login via Token", oauthLogin);
return actionMenu.Show(sender);
});
_loginUrl = this.WhenAnyValue(x => x.WebDomain)
.IsNotNull()
.Select(x => x.TrimEnd('/'))
.Select(x =>
string.Format(x + "/login/oauth/authorize?client_id={0}&redirect_uri={1}&scope={2}",
ClientId, Uri.EscapeDataString(RedirectUri), Uri.EscapeDataString(string.Join(",", OctokitClientFactory.Scopes))))
.ToProperty(this, x => x.LoginUrl);
WebDomain = DefaultWebDomain;
}
开发者ID:runt18,项目名称:CodeHub,代码行数:35,代码来源:OAuthFlowLoginViewModel.cs
示例15: SettingsViewModel
public SettingsViewModel(
IScreen screen,
ISettingsProvider settingsProvider,
IFolderHelper folderHelper,
IAppContext appContext)
{
HostScreen = screen;
BackCommand = new ReactiveAsyncCommand();
BackCommand.RegisterAsyncAction(_ => HostScreen.Router.NavigateBack.Execute(null));
SelectFolder = new ReactiveAsyncCommand();
SelectFolder.RegisterAsyncAction(_ =>
{
var result = folderHelper.SelectFolder();
if (result.Result == true) {
UpdateLocation = result.Folder;
}
}, appContext.DispatcherScheduler);
UpdateLocation = settingsProvider.UpdateLocation;
_IsError = this.WhenAny(vm => vm.UpdateLocation, vm => vm.Value)
.DistinctUntilChanged()
.Throttle(TimeSpan.FromMilliseconds(500))
.ObserveOn(appContext.DispatcherScheduler)
.Select(text => !IsUrlOrFolder(text))
.Do(error => {
if (!error) {
settingsProvider.UpdateLocation = UpdateLocation;
}
})
.ToProperty(this, vm => vm.IsError, setViaReflection: false);
}
开发者ID:rzhw,项目名称:Squirrel.Samples,代码行数:34,代码来源:SettingsViewModel.cs
示例16: TreePageViewModel
public TreePageViewModel(TreeNode[] nodes)
{
Nodes = nodes;
_details = this.WhenAnyValue(x => x.SelectedNode)
.Select(x => x != null ? new ControlDetailsViewModel(x.Control) : null)
.ToProperty(this, x => x.Details);
}
开发者ID:KvanTTT,项目名称:Perspex,代码行数:7,代码来源:TreePageViewModel.cs
示例17: PlaylistViewModel
/// <summary>
/// Initializes a new instance of the <see cref="PlaylistViewModel" /> class.
/// </summary>
/// <param name="playlist">The playlist info.</param>
/// <param name="renameRequest">
/// A function that requests the rename of the playlist. Return true, if the rename is
/// granted, otherwise false.
/// </param>
public PlaylistViewModel(Playlist playlist, Func<string, bool> renameRequest)
{
this.playlist = playlist;
this.renameRequest = renameRequest;
this.disposable = new CompositeDisposable();
this.entries = playlist
.CreateDerivedCollection(entry => new PlaylistEntryViewModel(entry))
.DisposeWith(this.disposable);
this.entries.ItemsRemoved.Subscribe(x => x.Dispose());
this.playlist.WhenAnyValue(x => x.CurrentSongIndex).ToUnit()
.Merge(this.entries.Changed.ToUnit())
.Subscribe(_ => this.UpdateCurrentSong())
.DisposeWith(this.disposable);
IObservable<List<PlaylistEntryViewModel>> remainingSongs = this.entries.Changed
.Select(x => Unit.Default)
.Merge(this.playlist.WhenAnyValue(x => x.CurrentSongIndex).ToUnit())
.Select(x => this.entries.Reverse().TakeWhile(entry => !entry.IsPlaying).ToList());
this.songsRemaining = remainingSongs
.Select(x => x.Count)
.ToProperty(this, x => x.SongsRemaining)
.DisposeWith(this.disposable);
this.timeRemaining = remainingSongs
.Select(x => x.Any() ? x.Select(entry => entry.Duration).Aggregate((t1, t2) => t1 + t2) : (TimeSpan?)null)
.ToProperty(this, x => x.TimeRemaining)
.DisposeWith(this.disposable);
this.CurrentPlayingEntry = this.Model.WhenAnyValue(x => x.CurrentSongIndex).Select(x => x == null ? null : this.entries[x.Value]);
}
开发者ID:hur1can3,项目名称:Espera,代码行数:42,代码来源:PlaylistViewModel.cs
示例18: AgentAnnotationViewModel
public AgentAnnotationViewModel(ISharedDataService sharedDataService, MeetingViewModel meeting)
: base(sharedDataService, meeting)
{
_annotations = new ReactiveList<AnnotationViewModel>();
var annotationsChangedObs = _annotations
.WhenAnyObservable(p => p.Changed)
.Select(p => AreThereAnnotationInTheCurrentPage());
var activeToolObs = Meeting.WhenAnyValue(vm => vm.ActiveTool).Where(t => t != null);
var pageChangedObs = activeToolObs
.Select(t => t.WhenAnyValue(v => v.CurrentPageNumber, p => AreThereAnnotationInTheCurrentPage()))
.Switch(); // Only listen to the most recent sequence of property changes (active tool)
var toolChangedObs = activeToolObs.Select(t => AreThereAnnotationInTheCurrentPage());
_containsAnnotationsForCurrentPage = toolChangedObs.Merge(pageChangedObs).Merge(annotationsChangedObs)
.ToProperty(this, p => p.ContainsAnnotationsForCurrentPage);
AnnotationTools = new AnnotationToolViewModel(this);
// when the IsEditing flag changes to false, it means an edit has just completed and we can send
// the updates annotations to the client
_isEditingSub = this.WhenAnyValue(p => p.IsEditing)
.Where(p => !p)
.Subscribe(_ => UpdateAnnotationModelAnnotations());
}
开发者ID:reactiveui-forks,项目名称:VirtualSales,代码行数:26,代码来源:AgentAnnotationViewModel.cs
示例19: CreateFileViewModel
public CreateFileViewModel(ISessionService applicationService, IAlertDialogFactory alertDialogFactory)
{
Title = "Create File";
this.WhenAnyValue(x => x.Name).Subscribe(x => CommitMessage = "Created " + x);
_canCommit = this.WhenAnyValue(x => x.Name)
.Select(x => !string.IsNullOrEmpty(x))
.ToProperty(this, x => x.CanCommit);
SaveCommand = ReactiveCommand.CreateAsyncTask(
this.WhenAnyValue(x => x.Name).Select(x => !string.IsNullOrEmpty(x)),
async _ =>
{
var content = Content ?? string.Empty;
var path = Path;
if (string.IsNullOrEmpty(Path))
path = "/";
path = System.IO.Path.Combine(path, Name);
var request = applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].UpdateContentFile(path, CommitMessage, content, null, Branch);
await applicationService.Client.ExecuteAsync(request);
Dismiss();
});
DismissCommand = ReactiveCommand.CreateAsyncTask(async t =>
{
if (string.IsNullOrEmpty(Name) && string.IsNullOrEmpty(Content)) return true;
return await alertDialogFactory.PromptYesNo("Discard File?", "Are you sure you want to discard this file?");
});
DismissCommand.Where(x => x).Subscribe(_ => Dismiss());
}
开发者ID:zdd910,项目名称:CodeHub,代码行数:32,代码来源:CreateFileViewModel.cs
示例20: InsertGistViewModel
public InsertGistViewModel()
{
//var client = new GitHubClient() { Username = "octocat", Password = "FillMeInHere" };
var privateImage = new BitmapImage(new Uri(@"pack://application:,,,/data/private.png"));
var publicImage = new BitmapImage(new Uri(@"pack://application:,,,/data/public.png"));
_PublicPrivateIcon = this.WhenAny(x => x.IsPrivateGist, x => x.Value)
.Select(x => x ? privateImage : publicImage)
.ToProperty(this, x => x.PublicPrivateIcon);
CreateGist = new ReactiveAsyncCommand();
CreateGist.RegisterAsyncObservable(_ => client.CreateGist(SelectionText, !IsPrivateGist))
.Select(x => x.html_url)
.BindTo(this, x => x.LastGistUrl);
CopyToClipboard = new ReactiveCommand(
this.WhenAny(x => x.LastGistUrl, x => !String.IsNullOrWhiteSpace(x.Value)));
CopyToClipboard.Subscribe(_ => Clipboard.SetText(LastGistUrl));
this.WhenAny(x => x.SelectionText, x => x.Value)
.Where(_ => LastGistUrl != null)
.Subscribe(_ => LastGistUrl = null);
}
开发者ID:paulcbetts,项目名称:GistForVS,代码行数:26,代码来源:InsertGistViewModel.cs
注:本文中的ObservableAsPropertyHelper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论