public static SortedEnvironmentVariableListBuilder CreateFromContext( int capacity, ReadOnlyMemory <KeyValuePair <string, string> > contextEnvVars) { var value = new SortedEnvironmentVariableListBuilder(capacity); contextEnvVars.CopyTo(value._array.AsMemory()); value._count = contextEnvVars.Length; return(value); }
public static SortedEnvironmentVariableListBuilder CreateFromProcess( int capacity, IDictionary processEnvVars) { // NOTE: On Windows, the environment block may contain names that differ only in cases // (due to broken programs generating such entries, for example, Cygwin). // Preserve such names by not removing duplicates in order to: // // - match the behavior of CreateProcess with lpEnvironment == null // - match the `extraEnvVars.Count == 0` case // // At the same time, try not to introduce new instances of such broken entries // by removing future duplicates. var value = new SortedEnvironmentVariableListBuilder(capacity); EnvironmentVariableListUtil.ToSortedKeyValuePairs(processEnvVars, value._array); value._count += processEnvVars.Count; return(value); }