Skip to content

Commit

Permalink
(GH-420) Environment adapter
Browse files Browse the repository at this point in the history
Add SetEnvironmentVariable
  • Loading branch information
ferventcoder committed Sep 30, 2015
1 parent 9ecb7b1 commit 51d1800
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/chocolatey/infrastructure/adapters/Environment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,10 @@ public string NewLine
{
get { return System.Environment.NewLine; }
}

public void SetEnvironmentVariable(string variable, string value)
{
System.Environment.SetEnvironmentVariable(variable, value);
}
}
}
32 changes: 31 additions & 1 deletion src/chocolatey/infrastructure/adapters/IEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,37 @@ public interface IEnvironment
/// </returns>
/// <filterpriority>1</filterpriority>
string NewLine { get; }

/// <summary>
/// Creates, modifies, or deletes an environment variable stored in the current process.
/// </summary>
/// <param name="variable">
/// The name of an environment variable.
/// </param>
/// <param name="value">
/// A value to assign to <paramref name="variable" />.
/// </param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="variable" /> is null.
/// </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="variable" /> contains a zero-length string, an initial hexadecimal zero character (0x00), or an equal sign ("=").
/// -or-
/// The length of <paramref name="variable" /> or <paramref name="value" /> is greater than or equal to 32,767 characters.
/// -or-
/// An error occurred during the execution of this operation.
/// </exception>
/// <exception cref="T:System.Security.SecurityException">
/// The caller does not have the required permission to perform this operation.
/// </exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission
/// class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
/// version="1" Unrestricted="true" />
/// </PermissionSet>
void SetEnvironmentVariable(string variable, string value);
}

// ReSharper restore InconsistentNaming
}
}

0 comments on commit 51d1800

Please sign in to comment.