Esempio n. 1
0
        public SettingsWindow(ISettings settings, ISettingManager mananger, IPluginManager pluginManager, IDependencyInjector container, IEnvironment environment)
        {
            _settings                  = settings;
            _mananger                  = mananger;
            _pluginManager             = pluginManager;
            _container                 = container;
            _environment               = environment;
            _mananger.PropertyChanged += _mananger_PropertyChanged;

            SaveCommand   = new SaveSettingsCommand(_settings);
            CancelCommand = new CancelSettingsCommand(this, _settings);

            DataContext = this;
            InitializeComponent();

            SettingsTree.SelectedItemChanged += SettingsTree_SelectedItemChanged;

            foreach (var rootSetting in _pluginManager.BuiltInPlugins.Where(x => x.SettingEditWindow != null && !x.IsHidden()))
            {
                var builtinPlugin = new TreeViewItem
                {
                    Header     = rootSetting.Title,
                    IsSelected = SettingsTree.Items.IsEmpty,
                    Tag        = _container.Resolve(rootSetting.SettingEditWindow)
                };

                SettingsTree.Items.Add(builtinPlugin);
            }

            var pluginsTree = new TreeViewItem
            {
                Header = "Plugins",
                Tag    = _container.Resolve(typeof(PluginManagerSettingWindow))
            };

            foreach (var customSettings in _pluginManager.ActivePlugins.Where(x => x.SettingEditWindow != null))
            {
                pluginsTree.Items.Add(new TreeViewItem
                {
                    Header = customSettings.Title,
                    Tag    = _container.Resolve(customSettings.SettingEditWindow)
                });
            }

            SettingsTree.Items.Add(pluginsTree);

            var aboutPage = new TreeViewItem {
                Header = "About"
            };

            SettingsTree.Items.Add(aboutPage);

            UpdateNotificationMessage();

            Loaded           += Settings_Loaded;
            IsVisibleChanged += SettingsWindow_IsVisibleChanged;
        }
Esempio n. 2
0
 public object ResolveSettingWindow(IThemeMeta theme)
 {
     if (theme.SettingEditWindow == null)
     {
         return(theme.SettingEditWindow);
     }
     return(_container.Resolve(theme.SettingEditWindow));
 }
Esempio n. 3
0
 public object ResolveSettingWindow(IPluginMeta plugin)
 {
     if (plugin.SettingEditWindow == null)
     {
         return(plugin.SettingEditWindow);
     }
     return(_container.Resolve(plugin.SettingEditWindow));
 }
Esempio n. 4
0
        public override object Get(IDependencyInjector injector)
        {
            if (_alreadyInvoke)
                throw new CyclicDependencyException(FactoryStack);

            FactoryStack.Push(this);
            _alreadyInvoke = true;

            var parameters = new object[_constructorData.Count];
            for (int i = 0; i < parameters.Length; i++)
            {
                ParameterData data = _constructorData.ParametersData[i];
                parameters[i] = injector.Resolve(data.Type, data.InjectableAttribute, data.ServiceKey);
            }

            object instance = _constructorData.ConstructorInfo.Invoke(parameters);

            foreach (FieldData field in _fieldsData)
            {
                object value;
                injector.TryResolve(out value, field.Type, field.InjectableAttribute, field.ServiceKey);
                field.FieldInfo.SetValue(instance, value);
            }

            foreach (PropertyData property in _propertiesData)
            {
                object value;
                injector.TryResolve(out value, property.Type, property.InjectableAttribute, property.ServiceKey);
                property.PropertyInfo.SetValue(instance, value);
            }

            _alreadyInvoke = false;
            FactoryStack.Pop();

            return instance;
        }
 public static T Resolve <T>(this IDependencyInjector dependencyInjector) => (T)dependencyInjector?.Resolve(typeof(T).GetTypeInfo());
 private IDependencyInjector GetChildInjector(IDependencyInjector dependencyInjector)
 => dependencyInjector.Resolve <ChildDependencyInjector>() ?? dependencyInjector;
Esempio n. 7
0
 public void Execute(object parameter)
 {
     _settings.Owner = (Window)_container.Resolve(typeof(IApplication));
     _settings.WindowStartupLocation = WindowStartupLocation.CenterOwner;
     _settings.ShowDialog();
 }
Esempio n. 8
0
        private IEnumerable <IPlugin> RegisterPlugins(IDependencyInjector container)
        {
            foreach (var plugin in Plugins.Union(BuiltInPlugins).Where(x => x.Plugin != null))
            {
                container.Register(plugin.Plugin, true);
            }

            return(ActivePlugins.Union(BuiltInPlugins).Where(x => x.Plugin != null).Select(plugin => (IPlugin)container.Resolve(plugin.Plugin)).ToList());
        }