Skip to content

Commit

Permalink
(GH-439) Environment adapter GetEnvironmentVariables
Browse files Browse the repository at this point in the history
Add both GetEnvironmentVariables methods to the adapter.
  • Loading branch information
ferventcoder committed Jun 5, 2016
1 parent c3ae267 commit 7f37556
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/chocolatey/infrastructure/adapters/Environment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
namespace chocolatey.infrastructure.adapters
{
using System;
using System.Collections;

public sealed class Environment : IEnvironment
{
Expand Down Expand Up @@ -44,6 +45,16 @@ public string GetEnvironmentVariable(string variable)
return System.Environment.GetEnvironmentVariable(variable);
}

public IDictionary GetEnvironmentVariables()
{
return System.Environment.GetEnvironmentVariables();
}

public IDictionary GetEnvironmentVariables(EnvironmentVariableTarget target)
{
return System.Environment.GetEnvironmentVariables(target);
}

public void SetEnvironmentVariable(string variable, string value)
{
System.Environment.SetEnvironmentVariable(variable, value);
Expand Down
38 changes: 38 additions & 0 deletions src/chocolatey/infrastructure/adapters/IEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
namespace chocolatey.infrastructure.adapters
{
using System;
using System.Collections;

// ReSharper disable InconsistentNaming

Expand Down Expand Up @@ -70,6 +71,43 @@ public interface IEnvironment
/// <returns></returns>
string GetEnvironmentVariable(string variable);

/// <summary>
/// Retrieves all environment variable names and their values from the current process.
///
/// </summary>
///
/// <returns>
/// An <see cref="T:System.Collections.IDictionary"/> that contains all environment variable names and their values; otherwise, an empty dictionary if no environment variables are found.
///
/// </returns>
/// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission to perform this operation.
/// </exception><exception cref="T:System.OutOfMemoryException">The buffer is out of memory.
/// </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>
IDictionary GetEnvironmentVariables();

/// <summary>
/// Gets the environment variables for a particular target.
/// </summary>
/// <param name="target">The target.</param>
/// <returns></returns>
///

/// <summary>
/// Retrieves all environment variable names and their values from the current process, or from the Windows operating system registry key for the current user or local machine.
///
/// </summary>
///
/// <returns>
/// An <see cref="T:System.Collections.IDictionary"/> object that contains all environment variable names and their values from the source specified by the <paramref name="target"/> parameter; otherwise, an empty dictionary if no environment variables are found.
///
/// </returns>
/// <param name="target">One of the <see cref="T:System.EnvironmentVariableTarget"/> values.
/// </param><exception cref="T:System.Security.SecurityException">The caller does not have the required permission to perform this operation for the specified value of <paramref name="target"/>.
/// </exception><exception cref="T:System.NotSupportedException">This method cannot be used on Windows 95 or Windows 98 platforms.
/// </exception><exception cref="T:System.ArgumentException"><paramref name="target"/> contains an illegal value.
/// </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"/><IPermission class="System.Security.Permissions.RegistryPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true"/><IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode"/></PermissionSet>
IDictionary GetEnvironmentVariables(EnvironmentVariableTarget target);

/// <summary>
/// Creates, modifies, or deletes an environment variable stored in the current process.
/// </summary>
Expand Down

0 comments on commit 7f37556

Please sign in to comment.