public PathRegistry( PathRegistryObjectType objectType, IDictionary<TK, PathModuleEntry<TE>> entities) { ObjectType = objectType; _entities = entities; }
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; }
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); }
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) + "'") { }
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); } }
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); }
public PathRegistry(PathRegistryObjectType objectType) { ObjectType = objectType; _entities = new HashMap<TK, PathModuleEntry<TE>>(); }