Exemple #1
0
        // TODO: Rethink creation process
        public IStateInfo Create(IFilePlugin entryPoint, IPluginManager pluginManager)
        {
            // 1. Create new state of the plugin
            var createdPlugin = entryPoint.CreatePluginState(pluginManager);

            // 2. Create empty file state
            if (!TryCreateState(createdPlugin))
            {
                // TODO: Handle errors
                return(null);
            }

            return(null);
        }
Exemple #2
0
        /// <summary>
        /// Try to create a new plugin state.
        /// </summary>
        /// <param name="plugin">The plugin from which to create a new state.</param>
        /// <param name="pluginManager">The plugin manager to pass to the state creation.</param>
        /// <param name="pluginState">The created state.</param>
        /// <returns>If the creation was successful.</returns>
        private LoadResult TryCreateState(IFilePlugin plugin, IPluginManager pluginManager, out IPluginState pluginState)
        {
            pluginState = null;

            try
            {
                pluginState = plugin.CreatePluginState(pluginManager);
            }
            catch (Exception e)
            {
                return(new LoadResult(e));
            }

            return(new LoadResult(true));
        }
Exemple #3
0
        /// <summary>
        /// Try to create a new plugin state.
        /// </summary>
        /// <param name="plugin">The plugin from which to create a new state.</param>
        /// <param name="pluginManager">The plugin manager to pass to the state creation.</param>
        /// <param name="pluginState">The created state.</param>
        /// <param name="loadInfo">The load info for this loading operation.</param>
        /// <returns>If the creation was successful.</returns>
        private LoadResult TryCreateState(IFilePlugin plugin, IPluginManager pluginManager, LoadInfo loadInfo, out IPluginState pluginState)
        {
            pluginState = null;

            try
            {
                pluginState = plugin.CreatePluginState(pluginManager);
            }
            catch (Exception e)
            {
                loadInfo.Logger?.Fatal(e, "The plugin state for '{0}' could not be initialized.", plugin.PluginId);
                return(new LoadResult(e));
            }

            return(new LoadResult(true));
        }