Beispiel #1
0
        public ConsoleData ToDto(IConsole cons)
        {
            if (cons == null)
            {
                throw new ArgumentNullException(nameof(cons));
            }
            if (cons.Handle == null)
            {
                throw new ArgumentNullException(nameof(cons.Handle));
            }

            var dto = new ConsoleData()
            {
                Handle  = cons.Handle,
                Width   = cons.Width,
                Height  = cons.Height,
                Version = cons.Version,

                UpdateUrl   = string.Format(urlTemplate, cons.Handle),
                HtmlContent = DefaultRenderer(cons)
            };

            if (cons is IConsoleWithProps consProps)
            {
                if (consProps.TryGetProp("IsActive", out var active))
                {
                    dto.IsActive = bool.Parse(active);
                }

                if (consProps.TryGetProp("DoneUrl", out var done))
                {
                    dto.DoneUrl = done;
                }
                if (consProps.TryGetProp("BackUrl", out var back))
                {
                    dto.BackUrl = back;
                }
                if (consProps.TryGetProp("CancelUrl", out var cancel))
                {
                    dto.CancelUrl = cancel;
                }

                dto.Props = new Dictionary <string, string>()
                {
                    { "title", consProps.Title }
                };

                dto.Title = consProps.Title;
            }

            return(dto);
        }
Beispiel #2
0
 public ConsoleDataModel(IConsole console, ConsoleData data)
 {
     Console = console;
     Data    = data;
 }