public FixedMapImpl(MapImpl source)
 {
     _map = new MapImpl();
     foreach (KeyAndValueImpl KV in source)
     {
         _map.Insert(KV.Key, KV.Value);
     }
 }
Exemple #2
0
        public IRuntimeContextInstance EnvironmentVariables()
        {
            var varsMap = new MapImpl();
            var allVars = System.Environment.GetEnvironmentVariables();

            foreach (DictionaryEntry item in allVars)
            {
                varsMap.Insert(
                    ValueFactory.Create((string)item.Key),
                    ValueFactory.Create((string)item.Value));
            }

            return(varsMap);
        }
Exemple #3
0
        public MapImpl EnvironmentVariables()
        {
            SystemLogger.Write("WARNING! Deprecated method: 'SystemInfo.EnvironmentVariables' is deprecated, use 'EnvironmentVariables' from global context");
            var varsMap = new MapImpl();
            var allVars = System.Environment.GetEnvironmentVariables();

            foreach (DictionaryEntry item in allVars)
            {
                varsMap.Insert(
                    ValueFactory.Create((string)item.Key),
                    ValueFactory.Create((string)item.Value));
            }

            return(varsMap);
        }
Exemple #4
0
        public MapImpl EnvironmentVariables(EnvironmentVariableTargetEnum target = EnvironmentVariableTargetEnum.Process)
        {
            EnvironmentVariableTarget targetParam = GetSystemEnvVariableTarget(target);
            var varsMap = new MapImpl();
            var allVars = System.Environment.GetEnvironmentVariables(targetParam);

            foreach (DictionaryEntry item in allVars)
            {
                varsMap.Insert(
                    ValueFactory.Create((string)item.Key),
                    ValueFactory.Create((string)item.Value));
            }

            return(varsMap);
        }
 public ProcessContext CreateProcess(string cmdLine, string currentDir = null, bool redirectOutput = false, bool redirectInput = false, IValue encoding = null, MapImpl env = null)
 {
     return(ProcessContext.Create(cmdLine, currentDir, redirectOutput, redirectInput, encoding, env));
 }
Exemple #6
0
        public static IRuntimeContextInstance Constructor(IValue source)
        {
            MapImpl RawSource = source.GetRawValue() as MapImpl;

            return(new FixedMapImpl(RawSource));
        }
Exemple #7
0
        public static ProcessContext Create(string cmdLine, string currentDir = null, bool redirectOutput = false, bool redirectInput = false, IValue encoding = null, MapImpl env = null)
        {
            var sInfo = PrepareProcessStartupInfo(cmdLine, currentDir);

            sInfo.UseShellExecute = false;
            if (redirectInput)
            {
                sInfo.RedirectStandardInput = true;
            }

            if (redirectOutput)
            {
                sInfo.RedirectStandardOutput = true;
                sInfo.RedirectStandardError  = true;
            }

            if (encoding != null)
            {
                var enc = TextEncodingEnum.GetEncoding(encoding);

                sInfo.StandardOutputEncoding = enc;
                sInfo.StandardErrorEncoding  = enc;
            }

            if (env != null)
            {
                var source = env.Select(x => new
                {
                    Key   = x.Key.AsString(),
                    Value = x.Value.AsString()
                }).Where(x => !string.IsNullOrWhiteSpace(x.Key));

                foreach (var kv in source)
                {
                    sInfo.EnvironmentVariables[kv.Key] = kv.Value;
                }
            }

            var p = new System.Diagnostics.Process();

            p.StartInfo = sInfo;

            return(new ProcessContext(p, encoding));
        }
Exemple #8
0
        public static ProcessContext Create(string cmdLine, string currentDir = null, bool redirectOutput = false, bool redirectInput = false, IValue encoding = null, MapImpl env = null)
        {
            var sInfo = PrepareProcessStartupInfo(cmdLine, currentDir);

            sInfo.UseShellExecute = false;
            if (redirectInput)
            {
                sInfo.RedirectStandardInput = true;
            }

            if (redirectOutput)
            {
                sInfo.RedirectStandardOutput = true;
                sInfo.RedirectStandardError  = true;
            }

            if (encoding != null)
            {
                var enc = TextEncodingEnum.GetEncoding(encoding);

                sInfo.StandardOutputEncoding = enc;
                sInfo.StandardErrorEncoding  = enc;
            }

            if (env != null)
            {
                foreach (var kv in env)
                {
                    sInfo.EnvironmentVariables.Remove(kv.Key.AsString());
                    sInfo.EnvironmentVariables[kv.Key.AsString()] = kv.Value.AsString();
                }
            }

            var p = new System.Diagnostics.Process();

            p.StartInfo = sInfo;

            return(new ProcessContext(p, encoding));
        }