/// <summary> /// Gets the <see cref="EnvironmentViewModel"/> with the specified name. /// </summary> /// <param name="name">The name of the <see cref="EnvironmentViewModel"/> to retrieve.</param> /// <returns>If a match is found, returns it. Otherwise, returns null.</returns> public EnvironmentViewModel GetEnvironmentByName(string name) { var environment = _repository.GetEnvironmentByName(name); if (environment == null) { return(null); } return(new EnvironmentConverter().To(environment)); }
/// <summary> /// Removes the environment variables added by Chami from a dictionary. /// </summary> /// <param name="environmentVariables">A dictionary containing all environment variables.</param> /// <param name="repository">An <see cref="EnvironmentRepository"/> with which to query the datastore.</param> /// <returns>The input environmentVariables parameter without the variables added by Chami.</returns> private static IDictionary RemoveCurrentChamiVariables(IDictionary environmentVariables, EnvironmentRepository repository) { var currentEnvironmentName = environmentVariables["_CHAMI_ENV"]; if (currentEnvironmentName != null) { var currentEnvironment = repository.GetEnvironmentByName(currentEnvironmentName.ToString()); if (currentEnvironment != null) { foreach (var variable in currentEnvironment.EnvironmentVariables) { var variableName = variable.Name; environmentVariables.Remove(variableName); } } } environmentVariables.Remove("_CHAMI_ENV"); return(environmentVariables); }