Ejemplo n.º 1
0
        /// <summary>
        /// Loads the bootstrapper application assembly and creates an instance of the IBootstrapperApplication.
        /// </summary>
        /// <param name="pEngine">IBootstrapperEngine provided for the bootstrapper application.</param>
        /// <param name="command">Command line for the bootstrapper application.</param>
        /// <returns>Bootstrapper application via <see cref="IBootstrapperApplication"/> interface.</returns>
        /// <exception cref="MissingAttributeException">The bootstrapper application assembly
        /// does not define the <see cref="BootstrapperApplicationFactoryAttribute"/>.</exception>
        public IBootstrapperApplication Create(IBootstrapperEngine pEngine, ref Command command)
        {
            // Get the wix.boostrapper section group to get the name of the bootstrapper application assembly to host.
            var section = ConfigurationManager.GetSection("wix.bootstrapper/host") as HostSection;

            if (null == section)
            {
                throw new MissingAttributeException(); // TODO: throw a more specific exception than this.
            }

            // Load the BA's IBootstrapperApplicationFactory.
            var baFactoryType = BootstrapperApplicationFactory.GetBAFactoryTypeFromAssembly(section.AssemblyName);
            var baFactory     = (IBootstrapperApplicationFactory)Activator.CreateInstance(baFactoryType);

            if (null == baFactory)
            {
                throw new InvalidBootstrapperApplicationFactoryException();
            }

            var ba = baFactory.Create(pEngine, ref command);

            return(ba);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads the bootstrapper application assembly and creates an instance of the IBootstrapperApplication.
        /// </summary>
        /// <param name="pEngine">IBootstrapperEngine provided for the bootstrapper application.</param>
        /// <param name="command">Command line for the bootstrapper application.</param>
        /// <returns>Bootstrapper application via <see cref="IBootstrapperApplication"/> interface.</returns>
        /// <exception cref="MissingAttributeException">The bootstrapper application assembly
        /// does not define the <see cref="BootstrapperApplicationAttribute"/>.</exception>
        public IBootstrapperApplication Create(IBootstrapperEngine pEngine, ref Command command)
        {
            // Get the wix.boostrapper section group to get the name of the bootstrapper application assembly to host.
            HostSection section = ConfigurationManager.GetSection("wix.bootstrapper/host") as HostSection;

            if (null == section)
            {
                throw new MissingAttributeException(); // TODO: throw a more specific exception than this.
            }

            // Load the BA and make sure it extends BootstrapperApplication.
            Type baType = BootstrapperApplicationFactory.GetBootstrapperApplicationTypeFromAssembly(section.AssemblyName);
            BootstrapperApplication ba = Activator.CreateInstance(baType) as BootstrapperApplication;

            if (null == ba)
            {
                throw new InvalidBootstrapperApplicationException();
            }

            ba.Engine     = new Engine(pEngine);
            ba.BAManifest = new BootstrapperApplicationData();
            ba.Command    = command;
            return(ba);
        }