本文整理汇总了C#中ReactiveList.SimpleCollectionLoad方法的典型用法代码示例。如果您正苦于以下问题:C# ReactiveList.SimpleCollectionLoad方法的具体用法?C# ReactiveList.SimpleCollectionLoad怎么用?C# ReactiveList.SimpleCollectionLoad使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReactiveList
的用法示例。
在下文中一共展示了ReactiveList.SimpleCollectionLoad方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BaseRepositoriesViewModel
protected BaseRepositoriesViewModel(ISessionService applicationService)
{
ApplicationService = applicationService;
ShowRepositoryOwner = true;
Title = "Repositories";
var gotoRepository = new Action<RepositoryItemViewModel>(x => {
var vm = this.CreateViewModel<RepositoryViewModel>();
vm.Init(x.Owner, x.Name);
NavigateTo(vm);
});
var repositories = new ReactiveList<RepositoryItemViewModel>();
Repositories = repositories.CreateDerivedCollection(
x => x,
filter: x => x.Name.ContainsKeyword(SearchKeyword),
signalReset: this.WhenAnyValue(x => x.SearchKeyword));
//Filter = applicationService.Account.Filters.GetFilter<RepositoriesFilterModel>(filterKey);
LoadCommand = ReactiveCommand.CreateAsyncTask(t =>
repositories.SimpleCollectionLoad(CreateRequest(),
x => new RepositoryItemViewModel(x.Name, x.Owner.Login, x.Owner.AvatarUrl,
ShowRepositoryDescription ? x.Description : string.Empty, x.StargazersCount, x.ForksCount,
ShowRepositoryOwner, gotoRepository),
x => LoadMoreCommand = x == null ? null : ReactiveCommand.CreateAsyncTask(_ => x())));
// _repositories.FilteringFunction = x => Repositories.Filter.Ascending ? x.OrderBy(y => y.Name) : x.OrderByDescending(y => y.Name);
// _repositories.GroupingFunction = CreateGroupedItems;
}
示例2: BaseUsersViewModel
protected BaseUsersViewModel()
{
var users = new ReactiveList<BasicUserModel>();
Users = users.CreateDerivedCollection(x => {
var isOrg = string.Equals(x.Type, "organization", StringComparison.OrdinalIgnoreCase);
return new UserItemViewModel(x.Login, x.AvatarUrl, isOrg, () => {
if (isOrg)
{
var vm = this.CreateViewModel<OrganizationViewModel>();
vm.Init(x.Login);
NavigateTo(vm);
}
else
{
var vm = this.CreateViewModel<UserViewModel>();
vm.Init(x.Login);
NavigateTo(vm);
}
});
},
x => x.Login.StartsWith(SearchKeyword ?? string.Empty, StringComparison.OrdinalIgnoreCase),
signalReset: this.WhenAnyValue(x => x.SearchKeyword));
LoadCommand = ReactiveCommand.CreateAsyncTask(t =>
users.SimpleCollectionLoad(CreateRequest(),
x => LoadMoreCommand = x == null ? null : ReactiveCommand.CreateAsyncTask(_ => x())));
}
示例3: IssueMilestonesViewModel
public IssueMilestonesViewModel(IApplicationService applicationService)
{
Milestones = new ReactiveList<MilestoneModel>();
SelectMilestoneCommand = ReactiveCommand.CreateAsyncTask(async t =>
{
var milestone = t as MilestoneModel;
if (milestone != null)
SelectedMilestone = milestone;
if (SaveOnSelect)
{
try
{
int? milestoneNumber = null;
if (SelectedMilestone != null) milestoneNumber = SelectedMilestone.Number;
var updateReq = applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].Issues[IssueId].UpdateMilestone(milestoneNumber);
await applicationService.Client.ExecuteAsync(updateReq);
}
catch (Exception e)
{
throw new Exception("Unable to to save milestone! Please try again.", e);
}
}
DismissCommand.ExecuteIfCan();
});
LoadCommand = ReactiveCommand.CreateAsyncTask(t =>
Milestones.SimpleCollectionLoad(
applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].Milestones.GetAll(),
t as bool?));
}
示例4: PullRequestsViewModel
public PullRequestsViewModel(IApplicationService applicationService)
{
PullRequests = new ReactiveList<PullRequestModel>();
GoToPullRequestCommand = ReactiveCommand.Create();
GoToPullRequestCommand.OfType<PullRequestModel>().Subscribe(pullRequest =>
{
var vm = CreateViewModel<PullRequestViewModel>();
vm.RepositoryOwner = RepositoryOwner;
vm.RepositoryName = RepositoryName;
vm.PullRequestId = pullRequest.Number;
vm.PullRequest = pullRequest;
vm.WhenAnyValue(x => x.PullRequest).Skip(1).Subscribe(x =>
{
var index = PullRequests.IndexOf(pullRequest);
if (index < 0) return;
PullRequests[index] = x;
PullRequests.Reset();
});
ShowViewModel(vm);
});
this.WhenAnyValue(x => x.SelectedFilter).Skip(1).Subscribe(_ => LoadCommand.ExecuteIfCan());
LoadCommand = ReactiveCommand.CreateAsyncTask(t =>
{
var state = SelectedFilter == 0 ? "open" : "closed";
var request = applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].PullRequests.GetAll(state: state);
return PullRequests.SimpleCollectionLoad(request, t as bool?);
});
}
示例5: BaseCommitsViewModel
protected BaseCommitsViewModel()
{
Title = "Commits";
var gotoCommitCommand = ReactiveCommand.Create();
gotoCommitCommand.OfType<CommitItemViewModel>().Subscribe(x =>
{
var vm = this.CreateViewModel<CommitViewModel>();
vm.RepositoryOwner = RepositoryOwner;
vm.RepositoryName = RepositoryName;
vm.Node = x.Commit.Sha;
NavigateTo(vm);
});
var commits = new ReactiveList<CommitItemViewModel>();
Commits = commits.CreateDerivedCollection(
x => x,
x => x.Description.ContainsKeyword(SearchKeyword) || x.Name.ContainsKeyword(SearchKeyword),
signalReset: this.WhenAnyValue(x => x.SearchKeyword));
LoadCommand = ReactiveCommand.CreateAsyncTask(t =>
commits.SimpleCollectionLoad(CreateRequest(),
x => new CommitItemViewModel(x, gotoCommitCommand.ExecuteIfCan),
x => LoadMoreCommand = x == null ? null : ReactiveCommand.CreateAsyncTask(_ => x())));
}
示例6: PullRequestFilesViewModel
public PullRequestFilesViewModel(IApplicationService applicationService)
{
var files = new ReactiveList<CommitModel.CommitFileModel>()
{
// GroupFunc = y =>
// {
// var filename = "/" + y.Filename;
// return filename.Substring(0, filename.LastIndexOf("/", StringComparison.Ordinal) + 1);
// }
};
Files = files.CreateDerivedCollection(x => x);
GoToSourceCommand = ReactiveCommand.Create();
GoToSourceCommand.OfType<CommitModel.CommitFileModel>().Subscribe(x =>
{
var vm = CreateViewModel<SourceViewModel>();
// vm.Name = x.Filename.Substring(x.Filename.LastIndexOf("/", StringComparison.Ordinal) + 1);
// vm.Path = x.Filename;
// vm.GitUrl = x.ContentsUrl;
// vm.ForceBinary = x.Patch == null;
ShowViewModel(vm);
});
LoadCommand = ReactiveCommand.CreateAsyncTask(t =>
files.SimpleCollectionLoad(
applicationService.Client.Users[Username].Repositories[Repository].PullRequests[PullRequestId]
.GetFiles(), t as bool?));
}
示例7: BaseEventsViewModel
protected BaseEventsViewModel(ISessionService applicationService)
{
ApplicationService = applicationService;
Title = "Events";
var events = new ReactiveList<EventModel>();
Events = events.CreateDerivedCollection(CreateEventTextBlocks);
ReportRepository = true;
LoadCommand = ReactiveCommand.CreateAsyncTask(t =>
events.SimpleCollectionLoad(CreateRequest(),
x => LoadMoreCommand = x == null ? null : ReactiveCommand.CreateAsyncTask(_ => x())));
}
示例8: BaseGistsViewModel
protected BaseGistsViewModel()
{
InternalGists = new ReactiveList<GistModel>();
Gists = InternalGists.CreateDerivedCollection(
x => CreateGistItemViewModel(x),
filter: x => x.Description.ContainsKeyword(SearchKeyword) || GetGistTitle(x).ContainsKeyword(SearchKeyword),
signalReset: this.WhenAnyValue(x => x.SearchKeyword));
LoadCommand = ReactiveCommand.CreateAsyncTask(async t =>
{
await InternalGists.SimpleCollectionLoad(CreateRequest(),
x => LoadMoreCommand = x == null ? null : ReactiveCommand.CreateAsyncTask(_ => x()));
});
}
示例9: PublicGistsViewModel
public PublicGistsViewModel(ISessionService sessionService)
{
Title = "Public Gists";
var gists = new ReactiveList<GistModel>();
Gists = gists.CreateDerivedCollection(x => CreateGistItemViewModel(x));
LoadCommand = ReactiveCommand.CreateAsyncTask(async t =>
{
var request = sessionService.Client.Gists.GetPublicGists();
await gists.SimpleCollectionLoad(request,
x => LoadMoreCommand = x == null ? null : ReactiveCommand.CreateAsyncTask(_ => x()));
});
}
示例10: IssueLabelsViewModel
public IssueLabelsViewModel(IApplicationService applicationService)
{
Labels = new ReactiveList<LabelModel>();
SelectedLabels = new ReactiveList<LabelModel>();
SelectLabelsCommand = ReactiveCommand.CreateAsyncTask(async t =>
{
var selectedLabels = t as IEnumerable<LabelModel>;
if (selectedLabels != null)
SelectedLabels.Reset(selectedLabels);
//If nothing has changed, dont do anything...
if (OriginalLabels != null && OriginalLabels.Count() == SelectedLabels.Count() &&
OriginalLabels.Intersect(SelectedLabels).Count() == SelectedLabels.Count())
{
DismissCommand.ExecuteIfCan();
return;
}
if (SaveOnSelect)
{
try
{
var labels = (SelectedLabels != null && SelectedLabels.Count > 0)
? SelectedLabels.Select(y => y.Name).ToArray() : null;
var updateReq =
applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].Issues[IssueId]
.UpdateLabels(labels);
await applicationService.Client.ExecuteAsync(updateReq);
}
catch (Exception e)
{
throw new Exception("Unable to save labels! Please try again.", e);
}
}
DismissCommand.ExecuteIfCan();
});
LoadCommand = ReactiveCommand.CreateAsyncTask(t =>
Labels.SimpleCollectionLoad(
applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].Labels.GetAll(),
t as bool?));
}
示例11: OrganizationsViewModel
public OrganizationsViewModel(IApplicationService applicationService)
{
var organizations = new ReactiveList<BasicUserModel>();
Organizations = organizations.CreateDerivedCollection(
x => new UserItemViewModel(x.Login, x.AvatarUrl, true, GoToOrganizationCommand.ExecuteIfCan),
x => x.Login.ContainsKeyword(SearchKeyword),
signalReset: this.WhenAnyValue(x => x.SearchKeyword));
GoToOrganizationCommand = ReactiveCommand.Create();
GoToOrganizationCommand.OfType<UserItemViewModel>().Subscribe(x =>
{
var vm = CreateViewModel<OrganizationViewModel>();
vm.Username = x.Name;
ShowViewModel(vm);
});
LoadCommand = ReactiveCommand.CreateAsyncTask(t =>
organizations.SimpleCollectionLoad(applicationService.Client.Users[Username].GetOrganizations(),
t as bool?));
}
示例12: CommitsViewModel
protected CommitsViewModel()
{
var commits = new ReactiveList<CommitModel>();
Commits = commits.CreateDerivedCollection(
CreateViewModel,
ContainsSearchKeyword,
signalReset: this.WhenAnyValue(x => x.SearchKeyword));
GoToChangesetCommand = ReactiveCommand.Create();
GoToChangesetCommand.OfType<CommitItemViewModel>().Subscribe(x =>
{
var vm = CreateViewModel<ChangesetViewModel>();
vm.RepositoryOwner = RepositoryOwner;
vm.RepositoryName = RepositoryName;
//vm.Node = x.Sha;
ShowViewModel(vm);
});
LoadCommand = ReactiveCommand.CreateAsyncTask(x => commits.SimpleCollectionLoad(GetRequest(), x as bool?));
}
示例13: PullRequestsViewModel
public PullRequestsViewModel(ISessionService applicationService)
{
Title = "Pull Requests";
var pullRequests = new ReactiveList<PullRequestModel>();
PullRequests = pullRequests.CreateDerivedCollection(x => {
var vm = new PullRequestItemViewModel(x);
vm.GoToCommand.Subscribe(_ => {
var prViewModel = this.CreateViewModel<PullRequestViewModel>();
prViewModel.Init(RepositoryOwner, RepositoryName, (int)x.Number);
NavigateTo(prViewModel);
prViewModel.WhenAnyValue(y => y.Issue.State)
.DistinctUntilChanged()
.Skip(1)
.Subscribe(y => LoadCommand.ExecuteIfCan());
});
return vm;
},
filter: x => x.Title.ContainsKeyword(SearchKeyword),
signalReset: this.WhenAnyValue(x => x.SearchKeyword));
LoadCommand = ReactiveCommand.CreateAsyncTask(t =>
{
var state = SelectedFilter == 0 ? "open" : "closed";
var request = applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].PullRequests.GetAll(state: state);
return pullRequests.SimpleCollectionLoad(request,
x => LoadMoreCommand = x == null ? null : ReactiveCommand.CreateAsyncTask(_ => x()));
});
this.WhenAnyValue(x => x.SelectedFilter).Skip(1).Subscribe(_ =>
{
pullRequests.Clear();
LoadCommand.ExecuteIfCan();
});
}
示例14: IssueAssignedToViewModel
public IssueAssignedToViewModel(IApplicationService applicationService)
{
_applicationService = applicationService;
Users = new ReactiveList<BasicUserModel>();
SelectUserCommand = ReactiveCommand.CreateAsyncTask(async t =>
{
var selectedUser = t as BasicUserModel;
if (selectedUser != null)
SelectedUser = selectedUser;
if (SaveOnSelect)
{
var assignee = SelectedUser != null ? SelectedUser.Login : null;
var updateReq = _applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].Issues[IssueId].UpdateAssignee(assignee);
await _applicationService.Client.ExecuteAsync(updateReq);
}
DismissCommand.ExecuteIfCan();
});
LoadCommand = ReactiveCommand.CreateAsyncTask(t =>
Users.SimpleCollectionLoad(applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].GetAssignees(), t as bool?));
}
示例15: GistViewModel
//.........这里部分代码省略.........
this.WhenAnyValue(x => x.Gist).Where(x => x != null && x.Files != null && x.Files.Count > 0)
.Select(x => x.Files.First().Key).Subscribe(x =>
Title = x);
ShareCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.Gist).Select(x => x != null));
ShareCommand.Subscribe(sender => actionMenuService.ShareUrl(sender, new Uri(Gist.HtmlUrl)));
this.WhenAnyValue(x => x.Gist.Owner.AvatarUrl)
.Select(x => new GitHubAvatar(x))
.ToProperty(this, x => x.Avatar, out _avatar);
ToggleStarCommand = ReactiveCommand.CreateAsyncTask(
this.WhenAnyValue(x => x.IsStarred).Select(x => x.HasValue),
async t =>
{
try
{
if (!IsStarred.HasValue) return;
var request = IsStarred.Value ? sessionService.Client.Gists[Id].Unstar() : sessionService.Client.Gists[Id].Star();
await sessionService.Client.ExecuteAsync(request);
IsStarred = !IsStarred.Value;
}
catch (Exception e)
{
throw new Exception("Unable to start gist. Please try again.", e);
}
});
ForkCommand = ReactiveCommand.CreateAsyncTask(async t => {
var gist = await sessionService.GitHubClient.Gist.Fork(Id);
var vm = this.CreateViewModel<GistViewModel>();
vm.Id = gist.Id;
vm.Gist = gist;
NavigateTo(vm);
});
ForkCommand.IsExecuting.Subscribe(x =>
{
if (x)
alertDialogFactory.Show("Forking...");
else
alertDialogFactory.Hide();
});
GoToEditCommand = ReactiveCommand.Create();
GoToEditCommand.Subscribe(_ =>
{
var vm = this.CreateViewModel<GistEditViewModel>();
vm.Gist = Gist;
vm.SaveCommand.Subscribe(x => Gist = x);
NavigateTo(vm);
});
GoToHtmlUrlCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.Gist).Select(x => x != null && !string.IsNullOrEmpty(x.HtmlUrl)));
GoToHtmlUrlCommand
.Select(_ => this.CreateViewModel<WebBrowserViewModel>())
.Select(x => x.Init(Gist.HtmlUrl))
.Subscribe(NavigateTo);
GoToFileSourceCommand = ReactiveCommand.Create();
GoToFileSourceCommand.OfType<GistFile>().Subscribe(x =>
{
var vm = this.CreateViewModel<GistFileViewModel>();
vm.Id = Id;
vm.GistFile = x;
vm.Filename = x.Filename;
NavigateTo(vm);
});
GoToOwnerCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.Gist).Select(x => x != null && x.Owner != null));
GoToOwnerCommand
.Select(_ => this.CreateViewModel<UserViewModel>())
.Select(x => x.Init(Gist.Owner.Login))
.Subscribe(NavigateTo);
AddCommentCommand = ReactiveCommand.Create().WithSubscription(_ =>
NavigateTo(new ComposerViewModel("Add Comment", async x => {
var request = sessionService.Client.Gists[Id].CreateGistComment(x);
Comments.Add((await sessionService.Client.ExecuteAsync(request)).Data);
}, alertDialogFactory)));
ShowMenuCommand = ReactiveCommand.CreateAsyncTask(
this.WhenAnyValue(x => x.Gist).Select(x => x != null),
sender => {
var menu = actionMenuService.Create();
if (Gist.Owner != null && string.Equals(sessionService.Account.Username, Gist.Owner.Login, StringComparison.OrdinalIgnoreCase))
menu.AddButton("Edit", GoToEditCommand);
else
menu.AddButton("Fork", ForkCommand);
menu.AddButton("Share", ShareCommand);
menu.AddButton("Show in GitHub", GoToHtmlUrlCommand);
return menu.Show(sender);
});
LoadCommand = ReactiveCommand.CreateAsyncTask(async _ => {
sessionService.GitHubClient.Gist.IsStarred(Id).ToBackground(x => IsStarred = x);
Comments.SimpleCollectionLoad(sessionService.Client.Gists[Id].GetComments());
Gist = await sessionService.GitHubClient.Gist.Get(Id);
});
}