public static void AsignTranslatedAppendix(this AppendixHelpEntity appendix, CultureInfoEntity fromCulture) { var fromAppendix = Database.Query <AppendixHelpEntity>().SingleEx(n => n.UniqueName == appendix.UniqueName && n.Culture == fromCulture); HashSet <string> toTranslate = new HashSet <string>(); if (!appendix.Title.HasText() && fromAppendix.Title.HasText()) { toTranslate.Add(fromAppendix.Title); } if (!appendix.Description.HasText() && fromAppendix.Description.HasText()) { toTranslate.Add(fromAppendix.Description); } Dictionary <string, string> dic = Translate(toTranslate, fromAppendix.Culture.Name, appendix.Culture.Name); if (!appendix.Title.HasText() && fromAppendix.Title.HasText()) { appendix.Title = dic.GetOrThrow(fromAppendix.Title); } if (!appendix.Description.HasText() && fromAppendix.Description.HasText()) { appendix.Description = dic.GetOrThrow(fromAppendix.Description); } appendix.Execute(AppendixHelpOperation.Save); }
public AppendixHelp(CultureInfo culture, AppendixHelpEntity entity) { Culture = culture; UniqueName = entity.UniqueName; Title = entity.Title; Description = entity.Description; Entity = entity; }
public static XDocument ToXDocument(AppendixHelpEntity entity) { return(new XDocument( new XDeclaration("1.0", "utf-8", "yes"), new XElement(_Appendix, new XAttribute(_Name, entity.UniqueName), new XAttribute(_Culture, entity.Culture.Name), new XAttribute(_Title, entity.Title), entity.Description.HasText() ? new XElement(_Description, entity.Description) : null ! ) )); }
public static SearchResult?Search(this AppendixHelpEntity entity, Regex regex) { { Match m = regex.Match(entity.Title.RemoveDiacritics()); if (m.Success) { return(new SearchResult(TypeSearchResult.Appendix, entity.Title, entity.Description.Try(d => d.Etc(etcLength)).DefaultText(entity.Title), m, entity.UniqueName)); } } if (entity.Description.HasText()) { Match m = regex.Match(entity.Description.RemoveDiacritics()); if (m.Success) { return(new SearchResult(TypeSearchResult.Appendix, entity.Title, entity.Description.Extract(m), m, entity.UniqueName, isDescription: true)); } } return(null); }