Esempio n. 1
0
 public PathRegistry(
     PathRegistryObjectType objectType,
     IDictionary<TK, PathModuleEntry<TE>> entities)
 {
     ObjectType = objectType;
     _entities = entities;
 }
Esempio n. 2
0
        public ISet<string> GetDependencies(
            string entityName,
            string moduleName,
            PathRegistryObjectType objectType)
        {
            var existing = _modules.Get(moduleName);
            if (existing == null) {
                throw new ArgumentException(
                    "Failed to find " + objectType.Name + " '" + entityName + "' under module '" + moduleName + "'");
            }

            return existing.Dependencies;
        }
Esempio n. 3
0
        public void AddDependency(
            string entityName,
            string moduleName,
            string deploymentIdDep,
            PathRegistryObjectType objectType)
        {
            var existing = _modules.Get(moduleName);
            if (existing == null) {
                throw new ArgumentException(
                    "Failed to find " + objectType.Name + " '" + entityName + "' under module '" + moduleName + "'");
            }

            existing.AddDependency(deploymentIdDep);
        }
Esempio n. 4
0
 public PathExceptionAlreadyRegistered(
     string name,
     PathRegistryObjectType objectType,
     string moduleName)
     : base(
         objectType.Prefix +
         " " +
         objectType.Name +
         " by name '" +
         name +
         "' has already been created for module '" +
         StringValue.UnnamedWhenNullOrEmpty(moduleName) +
         "'")
 {
 }
Esempio n. 5
0
        public Pair<TE, string> GetAnyModuleExpectSingle(
            string entityName,
            PathRegistryObjectType objectType,
            ICollection<string> moduleNames)
        {
            if (_modules.IsEmpty()) {
                return null;
            }

            if (moduleNames == null || moduleNames.IsEmpty()) {
                if (_modules.Count > 1) {
                    throw new PathExceptionAmbiguous(entityName, objectType);
                }

                var moduleName = _modules.Keys.First();
                var entry = _modules.Get(moduleName);
                if (entry == null) {
                    return null;
                }

                return new Pair<TE, string>(entry.Entity, moduleName);
            }

            if (_modules.Count == 1) {
                var entry = _modules.First();
                return new Pair<TE, string>(entry.Value.Entity, entry.Key);
            }

            var found = _modules
                .Where(e => moduleNames.Contains(e.Key))
                .Take(3)
                .ToList();

            switch (found.Count) {
                case 0:
                    return null;

                case 1:
                    var entry = found[0];
                    return new Pair<TE, string>(entry.Value.Entity, entry.Key);

                default:
                    throw new PathExceptionAmbiguous(entityName, objectType);
            }
        }
Esempio n. 6
0
        public Pair<TE, string> GetAnyModuleExpectSingle(
            string entityName,
            PathRegistryObjectType objectType,
            ICollection<string> moduleNames)
        {
            if (modules.IsEmpty()) {
                return null;
            }

            if (moduleNames == null || moduleNames.IsEmpty()) {
                if (modules.Count > 1) {
                    throw new PathExceptionAmbiguous(entityName, objectType);
                }

                var moduleName = modules.Keys.First();
                var entry = modules.Get(moduleName);
                if (entry == null) {
                    return null;
                }

                return new Pair<TE, string>(entry.Entity, moduleName);
            }

            PathDeploymentEntry<TE> found = null;
            string moduleNameFound = null;
            foreach (var moduleName in moduleNames) {
                var entry = modules.Get(moduleName);
                if (entry != null) {
                    if (found != null) {
                        throw new PathExceptionAmbiguous(entityName, objectType);
                    }

                    found = entry;
                    moduleNameFound = moduleName;
                }
            }

            return found == null ? null : new Pair<TE, string>(found.Entity, moduleNameFound);
        }
Esempio n. 7
0
 public PathRegistry(PathRegistryObjectType objectType)
 {
     ObjectType = objectType;
     _entities = new HashMap<TK, PathModuleEntry<TE>>();
 }