public ExtensionDataContractResolver(ExtensionManager extensionManager)
 {
     this.extensionManager = extensionManager;
 }
Exemplo n.º 2
0
        private void Initialize(CommandRunner commandRunner, ExtensionManager extensionManager)
        {
            var commandProvider = new ProgramSettingsCommandProvider(this, extensionManager.CommandCompositionContainer);
            var defaultRegistry = new ProgramFeatureRegistry(DefaultCommands, commandProvider);
            var pluginContext = new ProgramPluginContext(commandRunner, defaultRegistry, commandProvider);

            this.commandProvider = commandProvider;
            this.pluginContext = pluginContext;

            Plugins.Initialize(pluginContext, extensionManager.CommandCompositionContainer);
        }
Exemplo n.º 3
0
        private void Load()
        {
            var commandRunner = new CommandRunner();

            Log.Info("Loading extension manager");
            this.extensionManager = new ExtensionManager(Directory.CreateDirectory(Path.Combine(Directory.GetCurrentDirectory(), "Extensions")));

            Log.Info("Loading application settings");
            this.applicationSettings = new ApplicationSettings(new ProgramSettingsDataSerializer(this.extensionManager));

            ProgramSettingsData settingsData = null;

            try {
                settingsData = this.applicationSettings.LoadSettingsData();
            } catch (SerializationException e) {
                Log.Warn("Loading settings failed", e);

                if (this.guiMode) {
                    MessageBox.Show(
                        "An error occurred loading your NoCap settings.  Settings will be restored to their defaults.",
                        "Error loading settings",
                        MessageBoxButton.OK,
                        MessageBoxImage.Exclamation
                    );
                }
            }

            bool loadCommandDefaults = false;

            if (settingsData == null) {
                Log.Debug("Application settings not found; using defaults");

                settingsData = new ProgramSettingsData();

                loadCommandDefaults = true;
            }

            this.settings = ProgramSettings.Create(settingsData, commandRunner, this.extensionManager);

            var featureRegistry = this.settings.FeatureRegistry;

            // TODO Move elsewhere
            featureRegistry.Register(CommandFeatures.ImageUploader, "Image uploader");
            featureRegistry.Register(CommandFeatures.UrlShortener,  "Url shortener" );
            featureRegistry.Register(CommandFeatures.FileUploader,  "File uploader" );
            featureRegistry.Register(CommandFeatures.TextUploader,  "Text uploader" );

            if (loadCommandDefaults) {
                this.settings.LoadCommandDefaults();
            }
        }
Exemplo n.º 4
0
        public static ProgramSettings Create(ProgramSettingsData settingsData, CommandRunner commandRunner, ExtensionManager extensionManager)
        {
            var settings = new ProgramSettings(settingsData);
            settings.Initialize(commandRunner, extensionManager);

            return settings;
        }