Example #1
0
        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));
        }
Example #2
0
        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));
        }
Example #3
0
        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));
        }
Example #4
0
        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);
        }