SearchBox/SearchBox/DocumentMeta.cs

52 lines
950 B
C#
Raw Permalink Normal View History

2018-09-11 13:27:25 +00:00
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using UnidecodeSharpFork;
2018-09-11 13:27:25 +00:00
namespace LibSearchBox
{
public class DocumentMeta
{
public string Title { get; set; }
2018-09-11 13:47:24 +00:00
public List<string> Tags { get; private set; } = new List<string>();
2018-09-11 13:27:25 +00:00
[JsonIgnore]
public string SearchableTitle {
get {
return Title.ToLower().Unidecode();
}
}
[JsonIgnore]
public IEnumerable<string> SearchableTags {
get {
foreach (string nextTag in Tags)
yield return nextTag.ToLower().Unidecode();
}
}
2018-09-11 13:27:25 +00:00
public DocumentMeta(string inTitle, IEnumerable<string> inTags)
{
Title = inTitle;
2018-09-11 13:47:24 +00:00
if (inTags != null)
Tags.AddRange(inTags);
2018-09-11 13:27:25 +00:00
}
public void ReplaceTags(IEnumerable<string> newTags)
{
Tags.Clear();
Tags.AddRange(newTags);
}
2018-09-11 13:47:24 +00:00
#region Overrides
public override string ToString()
{
return $"[DocumentMeta Title={Title}, Tags={string.Join(",", Tags)}]";
}
#endregion
2018-09-11 13:27:25 +00:00
}
}