/// <summary> /// Gets the environment of the given id. /// </summary> /// <param name="id">The environment id.</param> /// <returns>The environment of the given id.</returns> public EnvironmentProfile GetById(int id) { EnvironmentProfile profile = TryGetById(id); if (profile != null) { return(profile); } throw new KeyNotFoundException(string.Format("Environment profile of id {0} was not found", id)); }
/// <summary> /// Selects the environment profile defined by Id. /// </summary> /// <param name="id">The id of the environment profile to be selected.</param> public void Select(int id) { ValidateProfiles(); EnvironmentProfile profile = _environmentProfileCollection.GetById(id); if (profile != null) { profile.UpdateLastTimeUsed(); SelectedEnvironment = profile; } }
/// <summary> /// Deletes the environment profile with the given id. /// </summary> /// <param name="id">The id of the environment profile to be deleted.</param> public void Delete(int id) { ValidateProfiles(); EnvironmentProfile profile = _environmentProfileCollection.GetById(id); if (profile != null) { if (profile == SelectedEnvironment) { SelectedEnvironment = null; } _environmentProfileCollection.Remove(id); } }
/// <summary> /// Modify the meshes of the environment profile defined by Id. /// </summary> /// <param name="id">The id of the environment profile to be modified.</param> /// <param name="meshes">The new meshes of the environment profile.</param> public void SetMeshes(int id, List <string> meshes) { if (meshes == null) { throw new ArgumentNullException("meshes"); } ValidateProfiles(); EnvironmentProfile profile = _environmentProfileCollection.GetById(id); if (profile != null) { profile.Meshes = meshes; } }
/// <summary> /// Modify the mapName of the environment profile with the given Id. /// </summary> /// <param name="id">The id of the environment profile to be modified.</param> /// <param name="mapName">The new map name of the environment profile.</param> public void SetMapName(int id, string mapName) { if (string.IsNullOrEmpty(mapName)) { throw new ArgumentNullException("mapName"); } ValidateProfiles(); EnvironmentProfile profile = _environmentProfileCollection.GetById(id); if (profile != null) { profile.MapName = mapName; } }
public IEnvironmentProfile ForceCreation(string name) { if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException("name"); } ValidateProfiles(); ValidateName(name); EnvironmentProfile newEnvironment = new EnvironmentProfile(GetNewId(), name); _environmentProfileCollection.Add(newEnvironment); SelectedEnvironment = newEnvironment; return(newEnvironment); }
/// <summary> /// Renames the environment profile with the given id. /// </summary> /// <param name="id">The id of the environment profile to be renamed.</param> /// <param name="newName">The new name of the environment profile.</param> public void Rename(int id, string newName) { if (string.IsNullOrEmpty(newName)) { throw new ArgumentNullException("newName"); } ValidateIsNotDefault(newName); ValidateProfiles(); EnvironmentProfile profile = _environmentProfileCollection.GetById(id); if (profile != null && newName != profile.Name) { ValidateName(newName); profile.Name = newName; } }
/// <summary> /// Adds an environment profile. /// </summary> /// <param name="environmentProfile">The environment profile to be added.</param> public void Add(EnvironmentProfile environmentProfile) { _collection.Add(environmentProfile.Id, environmentProfile); }