Exemplo n.º 1
0
            public async Task Initialize <TComponent, TComponentData>(TComponentData data, ProjectSettings settings)
                where TComponent : IComponent
            {
                var componentType = ComponentTypes
                                    .OfType <IComponentType <TComponent, TComponentData> >()
                                    .ToList();

                var newComponents = new List <IComponent>();

                foreach (var type in componentType)
                {
                    var component = await type.InitializeAt(this, data, settings);

                    if (component != null)
                    {
                        newComponents.Add(component);
                    }
                }

                _components = _components.AddRange(newComponents);

                if (newComponents.OfType <INeedConfiguration>().Any())
                {
                    await Configure(settings, false, false);

                    await settings.Save();
                }

                foreach (var restorableComponent in newComponents.OfType <IRestorableComponent>())
                {
                    await restorableComponent.Restore();
                }
            }