Esempio n. 1
0
        /// <summary>
        /// Generate message box HTML and set to data collector
        /// </summary>
        /// <param name="text">Text of a message box</param>
        /// <param name="status">Status of a message box</param>
        /// <param name="title">Title of a message box</param>
        public void Show(string?text, MessageBoxStatus status = MessageBoxStatus.Error, string?title = null)
        {
            if (string.IsNullOrEmpty(text))
            {
                throw new ArgumentNullException(nameof(text));
            }

            var templateFile = MessageBoxTemplatesPath;

            switch (status)
            {
            case MessageBoxStatus.Information:
                templateFile += "InfoMessageBox.tpl";
                break;

            case MessageBoxStatus.Error:
                templateFile += "ErrorMessageBox.tpl";
                break;

            case MessageBoxStatus.Ok:
                templateFile += "OkMessageBox.tpl";
                break;
            }

            var tpl = _templateFactory.Load(templateFile);

            tpl.Set("Message", text);
            tpl.Set("Title", string.IsNullOrEmpty(title) ? _stringTable.GetItem("FormTitleMessageBox") : title);

            _dataCollector.Add(tpl.Get());
            _dataCollector.AddTitle(string.IsNullOrEmpty(title) ? _stringTable.GetItem("FormTitleMessageBox") : title);
        }
Esempio n. 2
0
        /// <summary>
        /// Builds a web page
        /// </summary>
        /// <param name="resolver">The DI container resolver.</param>
        /// <returns></returns>
        public string Build(IDIResolver resolver)
        {
            resolver.Resolve <IStringTableItemsSetter>().Set();
            resolver.Resolve <IContextVariablesSetter>().SetVariables(resolver);

            var tpl = _templateFactory.Load(resolver.Resolve <IEnvironment>().MasterTemplateFileName);

            foreach (var item in _dataCollector.Items.Keys)
            {
                tpl.Set(item, _dataCollector.Items[item]);
            }

            return(tpl.Get());
        }