// internal as well as protected it can be exercised by unit tests. protected internal string AddLogicalLocation(LogicalLocation logicalLocation, string delimiter) { if (logicalLocation == null) { throw new ArgumentNullException(nameof(logicalLocation)); } int disambiguator = 0; string logicalLocationKey = logicalLocation.ParentKey == null ? logicalLocation.Name : logicalLocation.ParentKey + delimiter + logicalLocation.Name; string generatedKey = logicalLocationKey; while (LogicalLocationsDictionary.ContainsKey(generatedKey) && !logicalLocation.ValueEquals(LogicalLocationsDictionary[generatedKey])) { generatedKey = logicalLocationKey + "-" + disambiguator.ToString(CultureInfo.InvariantCulture); ++disambiguator; } if (!LogicalLocationsDictionary.ContainsKey(generatedKey)) { LogicalLocationsDictionary.Add(generatedKey, logicalLocation); } return generatedKey; }
// internal as well as protected it can be exercised by unit tests. protected internal string AddLogicalLocation(LogicalLocation logicalLocation, string delimiter) { if (logicalLocation == null) { throw new ArgumentNullException(nameof(logicalLocation)); } int disambiguator = 0; string logicalLocationKey = logicalLocation.ParentKey == null ? logicalLocation.Name : logicalLocation.ParentKey + delimiter + logicalLocation.Name; string generatedKey = logicalLocationKey; while (LogicalLocationsDictionary.ContainsKey(generatedKey) && !logicalLocation.ValueEquals(LogicalLocationsDictionary[generatedKey])) { generatedKey = logicalLocationKey + "-" + disambiguator.ToString(CultureInfo.InvariantCulture); ++disambiguator; } if (!LogicalLocationsDictionary.ContainsKey(generatedKey)) { LogicalLocationsDictionary.Add(generatedKey, logicalLocation); } return(generatedKey); }
// internal as well as protected it can be exercised by unit tests. protected internal string AddLogicalLocation(LogicalLocation logicalLocation, string delimiter) { if (logicalLocation == null) { throw new ArgumentNullException(nameof(logicalLocation)); } int disambiguator = 0; string fullyQualifiedLogicalName = logicalLocation.ParentKey == null ? logicalLocation.Name : logicalLocation.ParentKey + delimiter + logicalLocation.Name; string generatedKey = fullyQualifiedLogicalName; logicalLocation.Name = GetLogicalLocationName(logicalLocation.ParentKey, fullyQualifiedLogicalName, delimiter); logicalLocation.FullyQualifiedName = fullyQualifiedLogicalName; while (LogicalLocationsDictionary.ContainsKey(generatedKey)) { LogicalLocation logLoc = LogicalLocationsDictionary[generatedKey].DeepClone(); logLoc.Name = GetLogicalLocationName(logLoc.ParentKey, fullyQualifiedLogicalName, delimiter); logLoc.FullyQualifiedName = fullyQualifiedLogicalName; if (logicalLocation.ValueEquals(logLoc)) { break; } generatedKey = fullyQualifiedLogicalName + "-" + disambiguator.ToString(CultureInfo.InvariantCulture); ++disambiguator; } if (disambiguator == 0) { logicalLocation.FullyQualifiedName = null; } if (logicalLocation.Name == generatedKey) { logicalLocation.Name = null; } if (!LogicalLocationsDictionary.ContainsKey(generatedKey)) { LogicalLocationsDictionary.Add(generatedKey, logicalLocation); } return(generatedKey); }