示例#1
0
            /// <summary>
            /// Initializes a new instance of the <see cref="AppModule"/> class.
            /// </summary>
            /// <param name="app">The underlying application.</param>
            private AppModule(CompositeApp app)
            {
                this.app = app;

                IEnumerable <ComposablePartDefinition> parts = app.Parts;

                if (parts == null)
                {
                    throw Error.ReturnsNull(nameof(Parts));
                }

                catalog = new AppCatalog(parts);
            }
示例#2
0
            /// <summary>
            /// Starts the specified composite application.
            /// </summary>
            /// <param name="app">The application to start.</param>
            internal static void Run(CompositeApp app)
            {
                List <Task <Module> > tasks = new List <Task <Module> >();

                foreach (ModuleContext context in app.modules)
                {
                    tasks.Add(Task.Run(() => context.Module));
                }

                AppModule module = new AppModule(app);

                module.Initialize();

                XContainer.Activate(module);

                while (tasks.Count > 0)
                {
                    int index = Task.WaitAny(tasks.ToArray());

                    XContainer.Activate(tasks[index].Result);

                    tasks.RemoveAt(index);
                }
            }