Source/NFX/Environment/Configuration.cs
/// <summary>
/// Loads the contents of the supplied file name without format extension trying to match any of the supported format extensions.
/// When match is found the file is loaded via an appropriate configuration provider
/// </summary>
/// <example>
/// Given "c:\conf\users" as an input:
///   if "c:\conf\users.xml" exists then it will be opened as XMLConfiguration
///   if "c:\conf\users.laconf" exists then it will be opened as LaconicConfiguration
///   if "c:\conf\users.json" exists then it will be opened as JSONConfiguration
///   and so on... for the rest of supported formats
/// </example>
Loads the contents of the supplied file name without format extension trying to match any of the supported format extensions.
When match is found the file is loaded via an appropriate configuration provider
Loads the contents of the supplied file name without format extension trying to match any of the supported format extensions . When match is found the file is loaded via an appropriate configuration provider
public static Configuration ProviderLoadFromAnySupportedFormatFile(string fileName)
        {
            if (fileName.IsNotNullOrWhiteSpace())
            {
              if (fileName.EndsWith(".")) fileName=fileName.Remove(fileName.Length-1);
              foreach(var fmt in AllSupportedFormats)
              {
                var fn =  "{0}.{1}".Args(fileName, fmt);
                if (File.Exists(fn)) return ProviderLoadFromFile(fn);
              }
            }
            throw new ConfigException(StringConsts.CONFIG_NO_PROVIDER_LOAD_FILE_ERROR + fileName);
        }
public static Configuration ProviderLoadFromAnySupportedFormatFile ( string fileName ) { if ( fileName . IsNotNullOrWhiteSpace ( ) ) { if ( fileName . EndsWith ( " " ) ) fileName = fileName . Remove ( fileName . Length - 1 ) ; foreach ( var fmt in AllSupportedFormats ) { var fn = " " . Args ( fileName , fmt ) ; if ( File . Exists ( fn ) ) return ProviderLoadFromFile ( fn ) ; } } throw new ConfigException ( StringConsts . CONFIG_NO_PROVIDER_LOAD_FILE_ERROR + fileName ) ; }
Loads the contents of the supplied file name without format extension trying to match any of the supported format extensions.
Loads the contents of the supplied file name without format extension trying to match any of the supported format extensions .
fileName
string
example
Given "c:\conf\users" as an input:
if "c:\conf\users.xml" exists then it will be opened as XMLConfiguration
if "c:\conf\users.laconf" exists then it will be opened as LaconicConfiguration
if "c:\conf\users.json" exists then it will be opened as JSONConfiguration
and so on... for the rest of supported formats
Given " c : \ conf \ users " as an input : if " c : \ conf \ users . xml " exists then it will be opened as XMLConfiguration if " c : \ conf \ users . laconf " exists then it will be opened as LaconicConfiguration if " c : \ conf \ users . json " exists then it will be opened as JSONConfiguration and so on ... for the rest of supported formats