Exemplo n.º 1
0
 public async ValueTask InitializeComponent(ILifetimeScope scope, Type type)
 {
     if (!type.IsAssignableTo <IViewComponent>())
     {
         throw new InvalidCastException();
     }
     ComponentScopes.Add(type, scope);
     await WindowManager.BeginUIThreadScope(async() =>
     {
         var instance = scope.Resolve(type) as IViewComponent;
         await instance.Initialize(ComponentScopes[type]);
         Instance.Add(type, instance);
         this.Add(instance);
     });
 }
Exemplo n.º 2
0
        public async ValueTask UninitializeComponent(ILifetimeScope scope, Type type)
        {
            if (!type.IsAssignableTo <IViewComponent>())
            {
                throw new InvalidCastException();
            }
            var instance = scope.Resolve(type) as IViewComponent;

            foreach (var category in ComponentCategories[type])
            {
                CategoryComponents[category].Remove(type);
            }
            ComponentScopes.Remove(type);
            Instance.Remove(type);
            await WindowManager.BeginUIThreadScope(async() =>
            {
                await instance.Uninitialize(scope);
                this.Remove(instance);
            });
        }