/// <summary> /// Конструктор для создания инстанса CompositeInstanceInMultiInstanceCategory /// </summary> /// <param name="parent">Родительская многоинстовая категория</param> /// <param name="instanceName">Имя инстанса</param> /// <param name="wrappedInstances">Оборачиваемые инстансы</param> public CompositeInstanceInMultiInstanceCategory(CompositeMultiInstanceCategory parent, string instanceName, IEnumerable <InstanceInMultiInstanceCategory> wrappedInstances) : base(parent, instanceName) { if (wrappedInstances == null) { throw new ArgumentNullException("wrappedInstances"); } _wrappedInstances = new List <InstanceInMultiInstanceCategory>(wrappedInstances); _counters = parent.Counters.ToDictionary(key => key.Key, val => val.Value.CreateCounter(_wrappedInstances.Select(o => o.GetCounter(val.Value.Name, val.Value.Type)))); }
/// <summary> /// Создание подкатегории c многими инстансами /// </summary> /// <param name="categoryName">Имя категории</param> /// <param name="categoryDescription">Описание категории</param> /// <returns>Созданная подкатегория</returns> public override MultiInstanceCategory CreateMultiInstanceSubCategory(string categoryName, string categoryDescription) { if (categoryName == null) { throw new ArgumentNullException("categoryName"); } if (categoryDescription == null) { throw new ArgumentNullException("categoryDescription"); } lock (_childCategories) { if (_childCategories.Any(o => o.Name == categoryName)) { throw new DuplicateCategoryNameException("Category with the same name is already registered. Name: " + categoryName); } var res = new CompositeMultiInstanceCategory(categoryName, categoryDescription, _wrappedCategories.Select(wc => wc.CreateMultiInstanceSubCategory(categoryName, categoryDescription))); _childCategories.Add(res); return(res); } }