Beispiel #1
0
 public Location(List <string> _input)
 {
     Suggestion = new CompletionField()
     {
         Input = _input
     };
 }
        public Package(List <FeedPackage> feeds)
        {
            var latestVersion = feeds.Last();

            this.Id            = latestVersion.Id;
            this.Copyright     = latestVersion.Copyright;
            this.IconUrl       = latestVersion.IconUrl;
            this.Summary       = latestVersion.Summary;
            this.DownloadCount = latestVersion.DownloadCount;
            this.Tags          = latestVersion.Tags?
                                 .Split(new [] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                                 .Select(t => t.ToLowerInvariant())  //could use a normalizer in the mapping
                                 .ToArray() ?? Array.Empty <string>();
            this.Authors = latestVersion.Authors.Split('|').Select(author => new PackageAuthor {
                Name = author
            }).ToList();
            this.Versions            = feeds.Select(f => new PackageVersion(f)).ToList();
            this.AllVersionsUnlisted = feeds.All(f => f.Published < SpecialUnlistedDate);

            this.Suggest = new CompletionField
            {
                Input = new List <string>(latestVersion.Id.Split('.'))
                {
                    latestVersion.Id
                },
                Weight = latestVersion.DownloadCount
            };
        }
Beispiel #3
0
 public CustomControl(string groupTitle, string controlId, string controlClass, string controlTitle, string partId, string partProse)
 {
     this.GroupTitle   = groupTitle;
     this.ControlId    = controlId;
     this.ControlClass = controlClass;
     this.ControlTitle = controlTitle;
     this.PartId       = partId;
     this.PartProse    = partProse;
     this.Suggest      = new CompletionField
     {
         Input = new[] { partProse }
     };
 }
Beispiel #4
0
            public void UpdateCache(IServiceProvider services)
            {
                // auto-set content ids
                if (Contents != null)
                {
                    foreach (var content in Contents)
                    {
                        content.Id ??= Snowflake.New;
                    }
                }

                var tags = new Dictionary <BookTag, string[]>
                {
                    [BookTag.Tag]        = TagsGeneral,
                    [BookTag.Artist]     = TagsArtist,
                    [BookTag.Parody]     = TagsParody,
                    [BookTag.Character]  = TagsCharacter,
                    [BookTag.Convention] = TagsConvention,
                    [BookTag.Series]     = TagsSeries,
                    [BookTag.Circle]     = TagsCircle,
                    [BookTag.Metadata]   = TagsMetadata
                };

                PageCount   = Contents?.ToArray(c => c.PageCount);
                NoteCount   = Contents?.ToArray(c => c.Notes?.Values.Sum(x => x?.Length ?? 0) ?? 0);
                TagCount    = tags.Values.Sum(x => x?.Length ?? 0);
                Language    = Contents?.ToArray(c => c.Language);
                Sources     = Contents?.ToArray(c => c.Source);
                SourceIds   = Contents?.ToArray(c => c.SourceId);
                RefreshTime = Contents?.ToArray(c => c.RefreshTime);
                IsAvailable = Contents?.ToArray(c => c.IsAvailable);

                Suggest = new CompletionField
                {
                    Input = SuggestionFormatter.Format(new Dictionary <int, string[]>
                    {
                        [-1] = new[] { PrimaryName },
                        [-2] = new[] { EnglishName }
                    }.Chain(d =>
                    {
                        foreach (var(key, value) in tags)
                        {
                            d[(int)key] = value;
                        }
                    }))
                };
            }
 public Post()
 {
     Tags = new List <string>();
     //Categories = new List<string>();
     Suggest = new CompletionField();
 }