52 lines
950 B
C#
52 lines
950 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Newtonsoft.Json;
|
|
using UnidecodeSharpFork;
|
|
|
|
namespace LibSearchBox
|
|
{
|
|
public class DocumentMeta
|
|
{
|
|
public string Title { get; set; }
|
|
public List<string> Tags { get; private set; } = new List<string>();
|
|
|
|
[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();
|
|
}
|
|
}
|
|
|
|
public DocumentMeta(string inTitle, IEnumerable<string> inTags)
|
|
{
|
|
Title = inTitle;
|
|
if (inTags != null)
|
|
Tags.AddRange(inTags);
|
|
}
|
|
|
|
public void ReplaceTags(IEnumerable<string> newTags)
|
|
{
|
|
Tags.Clear();
|
|
Tags.AddRange(newTags);
|
|
}
|
|
|
|
|
|
#region Overrides
|
|
|
|
public override string ToString()
|
|
{
|
|
return $"[DocumentMeta Title={Title}, Tags={string.Join(",", Tags)}]";
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|