예제 #1
0
        /// <summary>
        /// Creates from HTML asynchronous.
        /// </summary>
        /// <param name="html">The HTML.</param>
        /// <returns></returns>
        public async Task <string> CreateFromHtmlAsync(string html, ConfigTOML Toml)
        {
            _config.Toml = Toml;
            var dictionary = _htmlParser.ToConverted(html);
            var contents   = _builder.ToTOML(dictionary, ValueScheme.Quoted);

            return(await Task.FromResult(contents));
        }
예제 #2
0
        /// <summary>
        /// Creates from HTML asynchronous.
        /// </summary>
        /// <param name="htmlFile">The HTML file.</param>
        /// <param name="values">The values.</param>
        /// <returns></returns>
        public async Task <string> CreateFromHtmlAsync(IFormFile htmlFile, IEnumerable <ModuleReadModel> values)
        {
            var module = new { module = values };
            var model  = new ConfigReadModel {
                Module = JsonConvert.SerializeObject(module), Block = "{}", Version = "{}"
            };
            var Toml = new ConfigTOML
            {
                BaseToml = await _service.CreateConfigTomlAsync(model, true),
                ViewToml = string.Empty
            };

            var html = FileReaderExtensions.ReadAsString(htmlFile);

            return(await _service.CreateFromHtmlAsync(html, Toml));
        }