private String PreflightCheck(MatchingDefinition definition, List <ScopeItem> scopeItems, bool dryRun) { string errorMessage = null; int placeholderIndex = 0; foreach (Placeholder placeholder in definition.Placeholders) { string value = definition.GetPlaceholderValue(placeholderIndex); if (placeholder.IsAlias) { // trying to create 'value' - check it doesn't already exist ScopeItem existingItem = FindScopeItemByName(scopeItems, value); if (existingItem != null) { errorMessage = $"Already exists: {value}"; } else if (!dryRun) { scopeItems.Add(new ScopeItem(value, placeholder.TypeName)); } } placeholderIndex++; } return(errorMessage); }
private ScopeItem FindScopeItemByName(List <ScopeItem> items, string name) { ScopeItem result = null; foreach (ScopeItem test in items) { if (test.Name.Equals(name)) { result = test; } } return(result); }