コード例 #1
0
ファイル: TerminalUtils.cs プロジェクト: saleyn/agni
        /// <summary>
        /// Parses command string into config node
        /// </summary>
        public static Configuration ParseCommand(string command, IEnvironmentVariableResolver resolver = null)
        {
            var cfg = LaconicConfiguration.CreateFromString(command);

            cfg.EnvironmentVarResolver = resolver;
            return(cfg);
        }
コード例 #2
0
ファイル: Configuration.cs プロジェクト: uzbekdev1/nfx
        /// <summary>
        /// Resolves variable name into its value
        /// </summary>
        public string ResolveEnvironmentVar(string name, IEnvironmentVariableResolver resolver = null)
        {
            string value;

            if (resolver != null && resolver.ResolveEnvironmentVariable(name, out value))
            {
                return(value);
            }

            resolver = m_EnvironmentVarResolver;
            if (resolver != null && resolver.ResolveEnvironmentVariable(name, out value))
            {
                return(value);
            }

            resolver = ProcesswideEnvironmentVarResolver;
            if (resolver != null && resolver.ResolveEnvironmentVariable(name, out value))
            {
                return(value);
            }

            resolver = OSEnvironmentVariableResolver.Instance;
            if (resolver != null && resolver.ResolveEnvironmentVariable(name, out value))
            {
                return(value);
            }
            return(string.Empty);
        }
コード例 #3
0
ファイル: MiscUtils.cs プロジェクト: mjaric/nfx
        /// <summary>
        ///  Evaluates variables in a context of optional variable resolver and macro runner
        /// </summary>
        public static string EvaluateVars(this string line, IEnvironmentVariableResolver envResolver = null, IMacroRunner macroRunner = null)
        {
            var config = new MemoryConfiguration();

            config.Create();
            config.EnvironmentVarResolver = envResolver;
            config.MacroRunner            = macroRunner;
            return(EvaluateVarsInConfigScope(line, config));
        }
コード例 #4
0
ファイル: Configuration.cs プロジェクト: dotnetchris/nfx
        /// <summary>
        /// Resolves variable name into its value
        /// </summary>
        public string ResolveEnvironmentVar(string name, IEnvironmentVariableResolver resolver = null)
        {
            if (resolver != null)
            {
                return(resolver.ResolveEnvironmentVariable(name));
            }

            if (m_EnvironmentVarResolver != null)
            {
                return(m_EnvironmentVarResolver.ResolveEnvironmentVariable(name));
            }

            var process = ProcesswideEnvironmentVarResolver;

            if (process != null)
            {
                return(process.ResolveEnvironmentVariable(name));
            }

            return(WindowsEnvironmentVariableResolver.Instance.ResolveEnvironmentVariable(name));
        }
コード例 #5
0
ファイル: MiscUtils.cs プロジェクト: mjaric/nfx
 /// <summary>
 ///  Evaluates variables in a context of optional configuration supplied as dictionary which is converted to attributes
 /// </summary>
 public static string EvaluateVarsInDictionaryScope(this string line, IDictionary <string, object> dict = null, IEnvironmentVariableResolver envResolver = null, IMacroRunner macroRunner = null)
 {
     if (dict == null)
     {
         return(line.EvaluateVarsInConfigScope(null));
     }
     else
     {
         var config = dict.ToConfigAttributes();
         config.EnvironmentVarResolver = envResolver;
         config.MacroRunner            = macroRunner;
         return(line.EvaluateVarsInConfigScope(config));
     }
 }
コード例 #6
0
ファイル: MiscUtils.cs プロジェクト: mjaric/nfx
        /// <summary>
        ///  Evaluates variables in a context of optional configuration supplied in XML format
        /// </summary>
        public static string EvaluateVarsInXMLConfigScope(this string line, string xmlScope = null, IEnvironmentVariableResolver envResolver = null, IMacroRunner macroRunner = null)
        {
            Configuration config = null;

            if (!string.IsNullOrWhiteSpace(xmlScope))
            {
                config = XMLConfiguration.CreateFromXML(xmlScope);
                config.EnvironmentVarResolver = envResolver;
                config.MacroRunner            = macroRunner;
            }
            return(line.EvaluateVarsInConfigScope(config));
        }