示例#1
0
        /// <summary>
        /// Calls the Stop method of the Plugin class.
        /// </summary>
        /// <param name="context">The PluginContext that is hosting this Plugin instance.</param>
        /// <param name="e">EventArgs that contain a PluginDescriptor with meta-data about the Plugin instance.</param>
        internal void OnStop(PluginContext context, PluginDescriptorEventArgs e)
        {
            try
            {
                Log.WriteLine("Stopping Plugin, Plugin: '{0}'.", e.Descriptor.PluginName);

                // inform the plugin that it should stop its services
                this.Stop(context, e);

                // fire the PluginStopped event of the PluginContext
                context.OnPluginStopped(e);
            }
            catch (Exception ex)
            {
                Log.WriteLine(ex);
            }
        }
示例#2
0
		/// <summary>
		/// Calls the Start method of the Plugin class.
        /// </summary>
        /// <param name="context">The PluginContext that is hosting this Plugin instance.</param>
        /// <param name="e">EventArgs that contain a PluginDescriptor with meta-data about the Plugin instance.</param>
		internal void OnStart(PluginContext context, PluginDescriptorEventArgs e)
		{			
            try
            {
                Log.WriteLine("Starting Plugin, Plugin: '{0}'.", e.Descriptor.PluginName);

                // inform the plugin that it should start its services
                this.Start(context, e);

				Application.DoEvents();

                // fire the PluginStarted event of the PluginContext
                context.OnPluginStarted(e);
            }
            catch(Exception ex)
            {
                Log.WriteLine(ex);
            }
		}
		public static void CreatePluginContext(Assembly assembly, string[] args)
		{            
			try
			{
				//Application.EnableVisualStyles();
                //Application.SetCompatibleTextRenderingDefault(true);

				// create a new plugin context
				using (PluginContext context = new PluginContext())
				{
					// run the application in this context
					context.Run(assembly, args);
				}
			}
			catch(Exception ex)
			{
				Log.WriteLine(ex);
				MessageBox.Show(null, string.Format("Additional Information: {0}", ex.Message) , "Critical Application Exception Encountered", MessageBoxButtons.OK, MessageBoxIcon.Error);
			}
			finally
			{
				LogFileManager.Shutdown();
			}
		}
 /// <summary>
 /// Initializes a new instance of the PluginContextEventArgs class.
 /// </summary>
 /// <param name="context">The plugin context that is the context of the event.</param>
 public PluginContextEventArgs(PluginContext context)
     : base()
 {
     _context = context;
 }
			/// <summary>
			/// Initializes a new instance of the PluginContextException class
			/// </summary>
			/// <param name="context">The PluginContext around which the exception is based</param>
			/// <param name="message"></param>
			protected PluginContextException(PluginContext context, string message) : base(message)
			{
				_context = context;
			}
        /// <summary>
        /// Asserts that there are no other created PluginContexts in the current application
        /// </summary>
        private void AssertThisIsTheOnlyCreatedContext()
		{
			// there can be only one per application
			if (_context != null)
			{
				throw new PluginContextAlreadyExistsException(_context);
			}
			
			// the first thing is to set the context so that it can be retrieved
			// anywhere in the application from here on using the PluginContext.Current property
			_context = this;
		}
			/// <summary>
			/// Initializes a new instance of the PluginContextAlreadyRunningException class
			/// </summary>
			/// <param name="context">The PluginContext that is already running</param>
			internal PluginContextAlreadyRunningException(PluginContext context) : 
				base(context, string.Format("A PluginContext is already running for the AppDomain '{0}'. Only one context can be run per application.", AppDomain.CurrentDomain.FriendlyName))
			{

			}
			/// <summary>
			/// Initializes a new instance of the PluginContextAlreadyExistsException class
			/// </summary>
			/// <param name="context">The PluginContext that already exists</param>
			internal PluginContextAlreadyExistsException(PluginContext context) :
				base(context, string.Format("A PluginContext already exists for the AppDomain '{0}'. Only one context can exist per application.", AppDomain.CurrentDomain.FriendlyName))
			{

			}
示例#9
0
 /// <summary>
 /// Initializes a new instance of the PluginContextException class
 /// </summary>
 /// <param name="context">The PluginContext around which the exception is based</param>
 /// <param name="message"></param>
 protected PluginContextException(PluginContext context, string message) : base(message)
 {
     _context = context;
 }
示例#10
0
 /// <summary>
 /// Initializes a new instance of the PluginContextAlreadyRunningException class
 /// </summary>
 /// <param name="context">The PluginContext that is already running</param>
 internal PluginContextAlreadyRunningException(PluginContext context) :
     base(context, string.Format("A PluginContext is already running for the AppDomain '{0}'. Only one context can be run per application.", AppDomain.CurrentDomain.FriendlyName))
 {
 }
示例#11
0
 /// <summary>
 /// Initializes a new instance of the PluginContextAlreadyExistsException class
 /// </summary>
 /// <param name="context">The PluginContext that already exists</param>
 internal PluginContextAlreadyExistsException(PluginContext context) :
     base(context, string.Format("A PluginContext already exists for the AppDomain '{0}'. Only one context can exist per application.", AppDomain.CurrentDomain.FriendlyName))
 {
 }
示例#12
0
		/// <summary>
		/// The abstract method that must be overriden by derived classes to stop plugin functionality
        /// </summary>
        /// <param name="context">The PluginContext that is hosting this Plugin instance.</param>
        /// <param name="e">EventArgs that contain a PluginDescriptor with meta-data about the Plugin instance.</param>
		protected abstract void Stop(PluginContext context, PluginDescriptorEventArgs e);
		/// <summary>
		/// Initializes a new instance of the PluginContextEventArgs class.
		/// </summary>
		/// <param name="context">The plugin context that is the context of the event.</param>
		public PluginContextEventArgs(PluginContext context)
			: base()
		{
			_context = context;
		}
示例#14
0
 /// <summary>
 /// The abstract method that must be overriden by derived classes to stop plugin functionality
 /// </summary>
 /// <param name="context">The PluginContext that is hosting this Plugin instance.</param>
 /// <param name="e">EventArgs that contain a PluginDescriptor with meta-data about the Plugin instance.</param>
 protected abstract void Stop(PluginContext context, PluginDescriptorEventArgs e);