Ejemplo n.º 1
0
        /// <summary>
        /// Creates an instance of the Type described by the PluginDescriptor and asserts that it derives from Plugin.
        /// </summary>
        /// <param name="descriptor">The PluginDescriptor that contains the Type to create.</param>
        private static void CreatePluginInstance(PluginDescriptor descriptor)
        {
            try
            {
                TypeHelper.AssertTypeIsSubclassOfBaseType(descriptor.PluginType, typeof(Plugin));

                CairoLogger.Instance.Debug(string.Format("Creating Plugin: '{0}'.", descriptor.PluginName));

                var plugin = (Plugin)TypeHelper.CreateInstanceOfType(descriptor.PluginType, Type.EmptyTypes, new object[] { });

                descriptor.AttachPluginInstance(plugin);
            }
            catch (Exception ex)
            {
                CairoLogger.Instance.Debug(ex.Message, ex);
            }
        }