Exemplo n.º 1
0
        private void LoadAvailableWidget()
        {
            var availableTypes = ReflectionHelper.Instance.GatherTypeChildrenTypesFromAssemblies(typeof(IDashboardWidget));

            foreach (var t in availableTypes.Where(it => it.IsAbstract == false))
            {
                var widget = Activator.CreateInstance(t);
                AvailableWidgets.Add(t);
            }
        }
Exemplo n.º 2
0
        public void RegisterAvailableWidgets()
        {
            var types         = Assembly.GetCallingAssembly().GetTypes();
            var widgetsAsType = from type in types
                                where typeof(IWidget).IsAssignableFrom(type) && !type.IsInterface
                                select type;

            foreach (var widgetAsType in widgetsAsType)
            {
                if (WidgetTypeIsAlreadyRegistered(widgetAsType))
                {
                    continue;
                }
                AvailableWidgets.Add(GetModelFromType(widgetAsType));
            }
        }
Exemplo n.º 3
0
 private bool WidgetTypeIsAlreadyRegistered(Type widgetType)
 {
     return(AvailableWidgets.Any(registeredWidget => registeredWidget.Type.Name == widgetType.Name));
 }