Exemplo n.º 1
0
        /// <summary>
        /// Configures the environment to load the plugin manager and verify we
        /// have access to the ImmediateCorrectionPlugin.
        /// </summary>
        private void SetupPlugin(
            out ProjectBlockCollection blocks,
            out BlockCommandSupervisor commands,
            out WordCounterProjectPlugin projectPlugin)
        {
            // Start getting us a simple plugin manager.
            var plugin        = new WordCounterPlugin();
            var pluginManager = new PluginManager(plugin);

            PluginManager.Instance = pluginManager;

            // Create a project and pull out the useful properties we'll use to
            // make changes.
            var project = new Project();

            blocks   = project.Blocks;
            commands = project.Commands;

            // Load in the immediate correction editor.
            if (!project.Plugins.Add("Word Counter"))
            {
                // We couldn't load it for some reason.
                throw new ApplicationException("Cannot load word counter plugin.");
            }

            // Pull out the controller for the correction and cast it (since we know
            // what type it is).
            ProjectPluginController pluginController = project.Plugins.Controllers[0];

            projectPlugin = (WordCounterProjectPlugin)pluginController.ProjectPlugin;

            // Set up logging for the controller.
            WordCounterProjectPlugin.Logger = Console.WriteLine;
        }
        /// <summary>
        /// Configures the environment to load the plugin manager and verify we
        /// have access to the ImmediateCorrectionPlugin.
        /// </summary>
        private void SetupPlugin(
			out ProjectBlockCollection blocks,
			out BlockCommandSupervisor commands,
			out WordCounterProjectPlugin projectPlugin)
        {
            // Start getting us a simple plugin manager.
            var plugin = new WordCounterPlugin();
            var pluginManager = new PluginManager(plugin);

            PluginManager.Instance = pluginManager;

            // Create a project and pull out the useful properties we'll use to
            // make changes.
            var project = new Project();

            blocks = project.Blocks;
            commands = project.Commands;

            // Load in the immediate correction editor.
            if (!project.Plugins.Add("Word Counter"))
            {
                // We couldn't load it for some reason.
                throw new ApplicationException("Cannot load word counter plugin.");
            }

            // Pull out the controller for the correction and cast it (since we know
            // what type it is).
            ProjectPluginController pluginController = project.Plugins.Controllers[0];
            projectPlugin = (WordCounterProjectPlugin) pluginController.ProjectPlugin;

            // Set up logging for the controller.
            WordCounterProjectPlugin.Logger = Console.WriteLine;
        }