OptionConverter SubstituteVariables Method | Apache log4net™ SDK Documentation

Performs variable substitution in string value from the values of keys found in props.

Namespace: log4net.Util
Assembly: log4net (in log4net.dll) Version: 2.0.8.0-.NET 4.0
Syntax

C#
VB
C++
F#
Copy

    public static string SubstituteVariables(
    	string value,
    	IDictionary props
    )

    Public Shared Function SubstituteVariables (
    	value As String,
    	props As IDictionary
    ) As String

    public:
    static String^ SubstituteVariables(
    	String^ value,
    	IDictionary^ props
    )

    static member SubstituteVariables :
            value : string *
            props : IDictionary -> string

#### Parameters

value
  Type: System
  String
  The string on which variable substitution is performed.
props
  Type: System.Collections
  IDictionary
  The dictionary to use to lookup variables.

#### Return Value

Type: String
The result of the substitutions.
Remarks

The variable substitution delimiters are ${ and }.

For example, if props contains key=value, then the call

C#
Copy

    string s = OptionConverter.SubstituteVariables("Value of key is ${key}.");

will set the variable s to "Value of key is value.".

If no value could be found for the specified key, then substitution defaults to an empty string.

For example, if system properties contains no value for the key "nonExistentKey", then the call

C#
Copy

    string s = OptionConverter.SubstituteVariables("Value of nonExistentKey is [${nonExistentKey}]");

will set s to "Value of nonExistentKey is []".

An Exception is thrown if value contains a start delimiter "${" which is not balanced by a stop delimiter "}".

See Also

#### Reference

OptionConverter Class
log4net.Util Namespace