Exemplo n.º 1
0
        private void AddDescriptor(DomainDescriptor descriptor)
        {
            var viewModel = descriptor.Host == null?this.CreateInstance(this.authentication, descriptor, this.Owner) : descriptor.Host as DomainTreeItemBase;

            viewModel.Parent = this;
            descriptor.Host  = viewModel;
        }
Exemplo n.º 2
0
 private void RemoveDescriptor(DomainDescriptor descriptor)
 {
     foreach (var item in this.Items.ToArray())
     {
         if (item is DomainTreeItemBase viewModel && viewModel.Descriptor == descriptor)
         {
             this.Items.Remove(viewModel);
         }
     }
 }
Exemplo n.º 3
0
        public DomainCategoryDescriptor(Authentication authentication, IDomainCategory category, DescriptorTypes descriptorTypes, object owner)
            : base(authentication, category, descriptorTypes)
        {
            this.category = category;
            this.owner    = owner ?? this;
            this.category.Dispatcher.VerifyAccess();
            this.categoryName = category.Name;
            this.categoryPath = category.Path;

            this.domainsReadonly    = new ReadOnlyObservableCollection <DomainDescriptor>(this.domains);
            this.categoriesReadonly = new ReadOnlyObservableCollection <DomainCategoryDescriptor>(this.categories);

            if (this.descriptorTypes.HasFlag(DescriptorTypes.IsSubscriptable) == true)
            {
                this.category.Renamed += Category_Renamed;
            }

            if (this.descriptorTypes.HasFlag(DescriptorTypes.IsRecursive) == true)
            {
                if (this.descriptorTypes.HasFlag(DescriptorTypes.IsSubscriptable) == true)
                {
                    this.category.Domains.CollectionChanged    += Domains_CollectionChanged;
                    this.category.Categories.CollectionChanged += Categories_CollectionChanged;
                }

                foreach (var item in this.category.Categories)
                {
                    var descriptor = new DomainCategoryDescriptor(this.authentication, item, this.descriptorTypes, this.owner);
                    item.ExtendedProperties[this.owner] = descriptor;
                    this.categories.Add(descriptor);
                }

                foreach (var item in this.category.Domains)
                {
                    var descriptor = new DomainDescriptor(this.authentication, item, this.descriptorTypes, this.owner);
                    item.ExtendedProperties[this.owner] = descriptor;
                    this.domains.Add(descriptor);
                }
            }

            if (this.category.GetService(typeof(IDataBase)) is IDataBase dataBase)
            {
                this.isActivated = dataBase.IsLoaded;
                if (this.descriptorTypes.HasFlag(DescriptorTypes.IsSubscriptable) == true)
                {
                    dataBase.Loaded   += DataBase_Loaded;
                    dataBase.Unloaded += DataBase_Unloaded;
                }
            }
        }
Exemplo n.º 4
0
        public DomainUserListBase(Authentication authentication, IDomain domain, bool IsSubscriptable, object owner)
        {
            this.authentication  = authentication;
            this.descriptor      = new DomainDescriptor(authentication, domain, IsSubscriptable == true ? DescriptorTypes.All : DescriptorTypes.IsRecursive, owner);
            this.IsSubscriptable = IsSubscriptable;
            this.owner           = owner;
            this.usersReadOnly   = new ReadOnlyObservableCollection <DomainUserListItemBase>(this.users);
            domain.ExtendedProperties[this.owner] = this;

            foreach (var item in this.descriptor.Users)
            {
                this.AddDescriptor(item);
            }

            if (this.descriptor.Users is INotifyCollectionChanged users)
            {
                users.CollectionChanged += Users_CollectionChanged;
            }
        }
Exemplo n.º 5
0
 protected virtual DomainTreeItemBase CreateInstance(Authentication authentication, DomainDescriptor descriptor, object owner)
 {
     return(new DomainTreeItemBase(authentication, descriptor, owner));
 }
Exemplo n.º 6
0
        private void Domains_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
            {
                var descriptorList = new List <DomainDescriptor>(e.NewItems.Count);
                foreach (IDomain item in e.NewItems)
                {
                    if (item.ExtendedProperties.ContainsKey(this.owner) == true)
                    {
                        var descriptor = item.ExtendedProperties[this.owner] as DomainDescriptor;
                        descriptorList.Add(descriptor);
                    }
                    else
                    {
                        var descriptor = new DomainDescriptor(this.authentication, item, this.descriptorTypes, this.owner);
                        item.ExtendedProperties[this.owner] = descriptor;
                        descriptorList.Add(descriptor);
                    }
                }
                this.Dispatcher.InvokeAsync(() =>
                    {
                        foreach (var item in descriptorList)
                        {
                            this.domains.Add(item);
                        }
                    });
            }
            break;

            case NotifyCollectionChangedAction.Remove:
            {
                var descriptorList = new List <DomainDescriptor>(e.OldItems.Count);
                foreach (IDomain item in e.OldItems)
                {
                    var descriptor = item.ExtendedProperties[this.owner] as DomainDescriptor;
                    descriptorList.Add(descriptor);
                }
                this.Dispatcher.InvokeAsync(() =>
                    {
                        foreach (var item in descriptorList)
                        {
                            this.domains.Remove(item);
                        }
                    });
            }
            break;

            case NotifyCollectionChangedAction.Move:
            {
            }
            break;

            case NotifyCollectionChangedAction.Reset:
            {
                this.Dispatcher.InvokeAsync(() =>
                    {
                        this.categories.Clear();
                        this.domains.Clear();
                    });
            }
            break;
            }
        }