public void VisitSelectedPartitions( ContextPartitionSelector contextPartitionSelector, ContextPartitionVisitor visitor) { var nestingLevel = Factory.FactoryContext.NestingLevel; if (contextPartitionSelector is ContextPartitionSelectorFiltered) { var filter = (ContextPartitionSelectorFiltered)contextPartitionSelector; var identifier = new ContextPartitionIdentifierCategory(); foreach (var entry in _handleCategories) { identifier.ContextPartitionId = entry.Value.ContextPartitionOrPathId; var categoryName = _factory.CategorySpec.Items[entry.Key].Name; identifier.Label = categoryName; if (filter.Filter(identifier)) { visitor.Visit(nestingLevel, PathId, _factory.Binding, entry.Key, this, entry.Value); } } return; } if (contextPartitionSelector is ContextPartitionSelectorCategory) { var category = (ContextPartitionSelectorCategory)contextPartitionSelector; if (category.Labels == null || category.Labels.IsEmpty()) { return; } foreach (var entry in _handleCategories) { String categoryName = _factory.CategorySpec.Items[entry.Key].Name; if (category.Labels.Contains(categoryName)) { visitor.Visit(nestingLevel, PathId, _factory.Binding, entry.Key, this, entry.Value); } } return; } if (contextPartitionSelector is ContextPartitionSelectorById) { var byId = (ContextPartitionSelectorById)contextPartitionSelector; foreach (var entry in _handleCategories) { var cpid = entry.Value.ContextPartitionOrPathId; if (byId.ContextPartitionIds.Contains(cpid)) { visitor.Visit(nestingLevel, PathId, _factory.Binding, entry.Key, this, entry.Value); } } return; } if (contextPartitionSelector is ContextPartitionSelectorAll) { foreach (var entry in _handleCategories) { var categoryName = _factory.CategorySpec.Items[entry.Key].Name; visitor.Visit(nestingLevel, PathId, _factory.Binding, entry.Key, this, entry.Value); } return; } throw ContextControllerSelectorUtil.GetInvalidSelector( new Type[] { typeof(ContextPartitionSelectorCategory) }, contextPartitionSelector); }
public override void VisitSelectedPartitions( IntSeqKey path, ContextPartitionSelector contextPartitionSelector, ContextPartitionVisitor visitor, ContextPartitionSelector[] selectorPerLevel) { if (contextPartitionSelector is ContextPartitionSelectorCategory) { var category = (ContextPartitionSelectorCategory) contextPartitionSelector; if (category.Labels == null || category.Labels.IsEmpty()) { return; } var ids = CategorySvc.MgmtGetSubpathOrCPIds(path); if (ids != null) { var count = -1; foreach (ContextControllerDetailCategoryItem categoryItem in factory.CategorySpec.Items) { count++; var subpathOrCPID = ids[count]; if (category.Labels.Contains(categoryItem.Name)) { realization.ContextPartitionRecursiveVisit( path, subpathOrCPID, this, visitor, selectorPerLevel); } } } return; } if (contextPartitionSelector is ContextPartitionSelectorFiltered) { var filter = (ContextPartitionSelectorFiltered) contextPartitionSelector; var ids = CategorySvc.MgmtGetSubpathOrCPIds(path); if (ids != null) { var count = -1; foreach (ContextControllerDetailCategoryItem categoryItem in factory.CategorySpec.Items) { var identifierCategory = new ContextPartitionIdentifierCategory(categoryItem.Name); count++; if (factory.FactoryEnv.IsLeaf) { identifierCategory.ContextPartitionId = ids[count]; } if (filter.Filter(identifierCategory)) { realization.ContextPartitionRecursiveVisit( path, ids[count], this, visitor, selectorPerLevel); } } } return; } if (contextPartitionSelector is ContextPartitionSelectorAll) { var ids = CategorySvc.MgmtGetSubpathOrCPIds(path); if (ids != null) { foreach (var id in ids) { realization.ContextPartitionRecursiveVisit(path, id, this, visitor, selectorPerLevel); } } return; } if (contextPartitionSelector is ContextPartitionSelectorById) { var byId = (ContextPartitionSelectorById) contextPartitionSelector; var ids = CategorySvc.MgmtGetSubpathOrCPIds(path); foreach (var id in ids) { if (byId.ContextPartitionIds.Contains(id)) { realization.ContextPartitionRecursiveVisit(path, id, this, visitor, selectorPerLevel); } } } throw ContextControllerSelectorUtil.GetInvalidSelector( new[] {typeof(ContextPartitionSelectorCategory)}, contextPartitionSelector); }