Пример #1
0
 public void Add(
     string moduleName,
     TE entity,
     string deploymentId)
 {
     _modules[moduleName] = new PathDeploymentEntry<TE>(deploymentId, entity);
 }
Пример #2
0
 public PathModuleEntry<TE> Copy() {
     var copy = new HashMap<String, PathDeploymentEntry<TE>>();
     foreach (var entry in _modules) {
         PathDeploymentEntry<TE> copyEntry = entry.Value.Copy();
         copy[entry.Key] = copyEntry;
     }
     return new PathModuleEntry<TE>(copy);
 }
Пример #3
0
        public void AddEntry(TK entityKey,
            String moduleName,
            PathDeploymentEntry<TE> entity)
        {
            CheckModuleNameParameter(moduleName);
            if (!_entities.TryGetValue(entityKey, out var existing)) {
                existing = new PathModuleEntry<TE>();
                _entities[entityKey] = existing;
            }
            else {
                var existingDeploymentId = existing.GetDeploymentId(moduleName);
                if (existingDeploymentId != null) {
                    throw new PathExceptionAlreadyRegistered(entityKey.ToString(), ObjectType, moduleName);
                }
            }

            existing.Add(moduleName, entity);
        }
Пример #4
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);
        }
Пример #5
0
 public void Add(
     string moduleName,
     PathDeploymentEntry<TE> entity)
 {
     _modules[moduleName] = entity;
 }