Exemplo n.º 1
0
        /// <summary>
        /// Runs all items within this bootstrapper.
        /// </summary>
        internal async Task RunAsync(SeeingSharpApplication app)
        {
            foreach (IBootstrapperItem actItem in m_items)
            {
                //Update current item property
                this.CurrentItem = actItem;

                //Execute the item
                await actItem.Execute(app)
                .ConfigureAwait(false);

                //Raise item executed event
                ItemExecuted.Raise(this, new BootstrapperItemArgs(actItem));
            }

            this.CurrentItem = null;
            this.Booted      = true;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes the SeeingSharpApplication object.
        /// </summary>
        /// <param name="mainAssembly">The main assembly of the application.</param>
        /// <param name="otherAssemblies">All other assemblies which should be search during TypeQuery.</param>
        /// <param name="startupArguments">All arguments passed to this application.</param>
        public static async Task InitializeAsync(Assembly mainAssembly, IEnumerable <Assembly> otherAssemblies, string[] startupArguments)
        {
            if (s_current != null)
            {
                throw new SeeingSharpException("RKApplication is already initialized!");
            }

            if (otherAssemblies == null)
            {
                otherAssemblies = new List <Assembly>();
            }

            // Ensure that the SeeingSharp assembly is contained in otherAssemblies list
            Assembly        thisAssembly        = typeof(SeeingSharpApplication).GetTypeInfo().Assembly;
            List <Assembly> otherAssembliesList = new List <Assembly>(otherAssemblies);

            if ((!otherAssembliesList.Contains(thisAssembly)) &&
                (mainAssembly != thisAssembly))
            {
                otherAssembliesList.Add(thisAssembly);
            }

            // Do all initializations
            SeeingSharpApplication newApplication = new SeeingSharpApplication();

            newApplication.m_mainAssembly     = mainAssembly;
            newApplication.m_otherAssemblies  = otherAssembliesList;
            newApplication.m_startupArguments = startupArguments;
            newApplication.m_translator       = new SeeingSharpTranslator();
            newApplication.m_assemblyQuery    = new TypeQueryHandler();
            newApplication.m_assemblyQuery.QueryTypes(newApplication.AppAssemblies);

            // Apply created instance
            s_current = newApplication;

            // Perform bootstrapping
            newApplication.m_bootstrapper = new Bootstrapper();
            newApplication.m_bootstrapper.LoadBootstrapperItems();
            await newApplication.m_bootstrapper.RunAsync(newApplication)
            .ConfigureAwait(false);
        }