コード例 #1
0
        public SelectVideoViewModel()
        {
            var grouping = PropertySelector <VideoInfoViewModel> .Start(z => z.Source.GroupIndex).ToString();

            Debug.Assert(grouping == "Source.GroupIndex");
            this.Items.View.GroupDescriptions?.Add(new PropertyGroupDescription(grouping));

            this.Items.View.CustomSort = Comparer <VideoInfoViewModel> .Create((x, y) =>
                                                                               x.Source.GroupIndex.CompareTo(y.Source.GroupIndex));
        }
コード例 #2
0
 protected override IEnumerable <FilterDefinition <VideoRoleCollection> > BuildFilters(VideoRoleCollection.QueryParameter parameter)
 {
     if (parameter.ActorId != null)
     {
         yield return(Builders <VideoRoleCollection> .Filter.Or(
                          Builders <VideoRoleCollection> .Filter.Eq(PropertySelector <VideoRoleCollection> .Start(z => z)
                                                                    .SelectMany(z => z.MajorRoles).Select(z => z.Id).ToString(), parameter.ActorId),
                          Builders <VideoRoleCollection> .Filter.Eq(PropertySelector <VideoRoleCollection> .Start(z => z)
                                                                    .SelectMany(z => z.MinorRoles).Select(z => z.Id).ToString(), parameter.ActorId)));
     }
 }
コード例 #3
0
        public void Initialize()
        {
            var index = new IndexKeysDefinitionBuilder <Thing>().Ascending(
                PropertySelector <Thing> .Start(z => z)
                .SelectMany(z => z.Words)
                .Select(z => z.Text)
                .ToString());

            this.Collection.Indexes.CreateOne(index, new CreateIndexOptions
            {
                Version    = 1,
                Background = true
            });
        }
コード例 #4
0
        public async Task LoadAsync()
        {
            var value = this.searchText;

            if (string.IsNullOrWhiteSpace(value))
            {
                this.Searched = false;
                this.Things.Clear();
                this.Words.Collection.Clear();
            }
            else
            {
                this.Searched = true;
                var builder = new FilterDefinitionBuilder <Thing>();
                FilterDefinition <Thing> filter;
                switch (this.SearchModes.Selected.Value.Value)
                {
                case SearchMode.Normal:
                    filter = builder.Regex(
                        PropertySelector <Thing> .Start().SelectMany(z => z.Words).Select(z => z.Text).ToString(),
                        new Regex(Regex.Escape(value), RegexOptions.IgnoreCase));
                    break;

                case SearchMode.WholeWord:
                    filter = builder.Eq(PropertySelector <Thing> .Start().SelectMany(z => z.Words).Select(z => z.Text).ToString(), value);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                string category = null;
                if (this.ExistsCategorys.Selected != string.Empty)
                {
                    category = this.ExistsCategorys.Selected;
                    filter   = filter & builder.AnyEq(z => z.Categorys, this.ExistsCategorys.Selected);
                }
                filter = builder.Eq(z => z.Id, value) | filter;
                var queryResult = await App.Current.ThingSetAccessor.FindAsync(filter, 20);

                this.HasNext = queryResult.HasNext;
                var sortedItems = await queryResult.Items
                                  .OrderBy(z => z.Words.Any(x => x.Text == value)? -1 : 1)
                                  .ThenBy(z => z.Words.Any(x => x.Text.Equals(value, StringComparison.OrdinalIgnoreCase)) ? -1 : 1)
                                  .ToArrayAsync();

                this.Things.Reset(sortedItems.Select(z => new ThingViewModel(z, category)));
                this.Words.Collection.Reset(this.Things.SelectMany(z => z.Words));
            }
            this.RefreshProperties();
        }