// /** // * File: ManagedContainerBase.cs // * Author: haraldwolff // * // * This file and it's content is copyrighted by the Author and / or copyright holder. // * Any use wihtout proper permission is illegal and may lead to legal actions. // * // * // **/ using System; using System.Collections.Generic; namespace ln.manage { public abstract class ManagedContainerBase : IManagedContainer { IManagedContainer parent; Dictionary containers = new Dictionary(); public ManagedContainerBase(IManagedContainer parent,String name) { Name = name; this.parent = parent; if (parent is ManagedContainerBase managedContainerBase) { managedContainerBase.AddContainer(this); } } public string Name { get; } public IManagedContainer Parent => parent; public IEnumerable Children => containers.Values; public abstract IEnumerable PropertyDescriptors { get; } public abstract string IdentityPropertyName { get; } public abstract IManagedObject CreateManagedObject(); public abstract bool DisposeManagedObject(object identity); public abstract IManagedObject GetManagedObject(object identity); public abstract IManagedObject[] GetManagedObjects(); public void AddContainer(IManagedContainer container) => containers.Add(container.Name, container); } }