Esempio n. 1
0
        /// <summary>
        /// Removes a component from the manager. If the component is a
        /// package, it is disabled for execution. All components are disposed upon removal.
        /// </summary>
        /// <param name="component">The component to remove.</param>
        public override void Remove(IComponent component)
        {
            if (component is GuidancePackage)
            {
                GuidancePackage package = (GuidancePackage)component;

                if (DisablingPackage != null)
                {
                    CancelPackageEventArgs args = new CancelPackageEventArgs(
                        package, false);
                    DisablingPackage(this, args);
                    if (args.Cancel)
                    {
                        return;
                    }
                }

                base.Remove(package);

                if (DisabledPackage != null)
                {
                    DisabledPackage(this, new PackageEventArgs(package));
                }

                package.Dispose();
            }
            else
            {
                base.Remove(component);
                component.Dispose();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Enables a package.
        /// </summary>
        /// <param name="configuration">
        /// Configuration to use for the new package.
        /// </param>
        /// <returns>
        /// Returns the loaded and enabled package.
        /// </returns>
        public GuidancePackage EnablePackage(Configuration.GuidancePackage configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }
            GuidancePackage package = new GuidancePackage(configuration);

            try
            {
                package.AfterRecipeExecution += new RecipeEventHandler(package_AfterRecipeExecution);
                Add(package);
            }
            catch
            {
                package.Dispose();
                throw;
            }
            return(package);
        }