public static async Task <NamespaceBundleConfigurations> Run(IManageNamespaceManagerLifeCycle manageNamespaceManagerLifeCycle, NamespaceConfigurations namespaceConfigurations, string bundlePrefix)
        {
            var namespaceBundleConfigurations = new NamespaceBundleConfigurations();

            foreach (var namespaceConfiguration in namespaceConfigurations)
            {
                var namespaceManager = manageNamespaceManagerLifeCycle.Get(namespaceConfiguration.Alias);
                var namespaceManagerThatCanQueryAndFilterTopics = namespaceManager as NamespaceManagerAdapter;

                // if user has provided an implementation of INamespaceManager, skip the checks all together
                if (namespaceManagerThatCanQueryAndFilterTopics == null)
                {
                    break;
                }

                var numberOfTopics = 1;
                if (await namespaceManagerThatCanQueryAndFilterTopics.CanManageEntities().ConfigureAwait(false))
                {
                    var filter      = $"startswith(path, '{bundlePrefix}') eq true";
                    var foundTopics = await namespaceManagerThatCanQueryAndFilterTopics.GetTopics(filter).ConfigureAwait(false);

                    numberOfTopics = foundTopics.Count();
                }
                namespaceBundleConfigurations.Add(namespaceConfiguration.Alias, numberOfTopics);
            }

            return(namespaceBundleConfigurations);
        }
        public static async Task <NamespaceBundleConfigurations> Run(IManageNamespaceManagerLifeCycleInternal manageNamespaceManagerLifeCycle, NamespaceConfigurations namespaceConfigurations, string bundlePrefix)
        {
            var namespaceBundleConfigurations = new NamespaceBundleConfigurations();
            var topicInBundleNameRegex        = new Regex($@"^{bundlePrefix}\d+$", RegexOptions.CultureInvariant);

            foreach (var namespaceConfiguration in namespaceConfigurations)
            {
                var namespaceManager = manageNamespaceManagerLifeCycle.Get(namespaceConfiguration.Alias);

                var numberOfTopics = 1;
                if (await namespaceManager.CanManageEntities().ConfigureAwait(false))
                {
                    var filter      = $"startswith(path, '{bundlePrefix}') eq true";
                    var foundTopics = await namespaceManager.GetTopics(filter).ConfigureAwait(false);

                    numberOfTopics = foundTopics.Count(topic => topicInBundleNameRegex.IsMatch(topic.Path));
                }
                namespaceBundleConfigurations.Add(namespaceConfiguration.Alias, numberOfTopics);
            }

            return(namespaceBundleConfigurations);
        }
Example #3
0
 public void SetUp()
 {
     namespaceBundleConfigurations = new NamespaceBundleConfigurations();
 }