Пример #1
0
 public LayoutsController(IOptionsSnapshot <LayoutsConfig> layoutsConfigAccessor, IHubContext <ChatHub> hubContext, Layouts layouts)
 {
     _layouts       = layouts;
     _hubContext    = hubContext;
     _layoutsConfig = layoutsConfigAccessor.Value;
     _layoutDict    = _layouts.ToDictionary(l => l.LayoutId);
 }
Пример #2
0
        public Layouts ReadConfig(LayoutsConfig config)
        {
            var layouts = new Layouts();

            foreach (var layoutConfig in config)
            {
                var layout = new Layout
                {
                    LayoutId = layoutConfig.LayoutId,
                    Title    = layoutConfig.Title
                };

                foreach (var itemConfig in layoutConfig.Items)
                {
                    var layoutItem = new LayoutItem
                    {
                        Icon        = itemConfig.Icon,
                        IconRunning = itemConfig.IconRunning,
                        Text        = itemConfig.Text
                    };

                    var actionType = Assembly.GetExecutingAssembly().GetType(itemConfig.Action);
                    var action     = (InterfaceAction)Activator.CreateInstance(actionType, itemConfig.Arguments);
                    layoutItem.Action = action;

                    layout.Items.Add(layoutItem);
                }

                layouts.Add(layout);
            }
            return(layouts);
        }