private async Task <JObject> GetEmptyTemplate() { // Load the template from the resource file // Start/URI are not used in the file currently var template = await TemplateUtility.LoadTemplate("AutoComplete", _context.OperationStart, _context.Source.BaseURI); return(JObject.Parse(template)); }
private async Task <JObject> CreatePage(Dictionary <string, JObject> data) { var page = JObject.Parse(await TemplateUtility.LoadTemplate("Search", _context.OperationStart, _context.Source.BaseURI)); page["totalHits"] = data.Count; page["data"] = new JArray(data.OrderBy(e => e.Key, StringComparer.OrdinalIgnoreCase).Select(e => e.Value)); return(JsonLDTokenComparer.Format(page, recurse: false)); }
public static XDocument GetBadge(PackageIdentity package, bool includePre) { var color = includePre ? COLOR_PRE : COLOR_STABLE; var templateString = TemplateUtility.GetBadgeTemplate(); var s = templateString.Replace(COLOR_TOKEN, color) .Replace(LABEL_TOKEN, LABEL) .Replace(VERSION_TOKEN, package.Version.ToNormalizedString()); return(XDocument.Parse(s)); }
private JObject CreatePage(List <JObject> data) { var page = JObject.Parse(TemplateUtility.LoadTemplate("Search", _context.OperationStart, _context.Source.BaseURI)); page["totalHits"] = data.Count; var dataArray = new JArray(); page["data"] = dataArray; foreach (var entry in data.OrderBy(e => e.GetId(), StringComparer.OrdinalIgnoreCase)) { dataArray.Add(entry); } return(JsonLDTokenComparer.Format(page)); }
private static async Task <bool> CreateFromTemplate( ISleetFileSystem source, ILogger log, DateTimeOffset now, string templatePath, string sourcePath, CancellationToken token) { var remoteFile = source.Get(sourcePath); if (!await remoteFile.Exists(log, token)) { var json = TemplateUtility.LoadTemplate(templatePath, now, source.BaseURI); await remoteFile.Write(JObject.Parse(json), log, token); return(true); } return(false); }
public static async Task <JObject> GetContextAsync(string name) { var json = await LoadJsonAsync(TemplateUtility.GetResource($"context{name}.json")); return((JObject)json["@context"]); }
public static JObject GetContext(string name) { var json = LoadJson(TemplateUtility.GetResource($"context{name}.json")); return((JObject)json["@context"]); }