Source/NFX/Environment/Configuration.cs
/// <summary>
/// Loads the contents of the supplied file name in an appropriate configuration provider implementation for the supplied extension format
/// </summary>
Loads the contents of the supplied file name in an appropriate configuration provider implementation for the supplied extension format
Loads the contents of the supplied file name in an appropriate configuration provider implementation for the supplied extension format
public static Configuration ProviderLoadFromFile(string fileName)
        {
            var ext = Path.GetExtension(fileName).ToLower();
            if (ext.StartsWith(".")) ext=ext.Remove(0, 1);
            if (NFX.CodeAnalysis.Laconfig.LaconfigLanguage.Instance.FileExtensions.Any(e => string.Equals(e, ext, StringComparison.InvariantCultureIgnoreCase) ))
              return new LaconicConfiguration(fileName);
            if (NFX.CodeAnalysis.XML.XMLLanguage.Instance.FileExtensions.Any(e => string.Equals(e, ext, StringComparison.InvariantCultureIgnoreCase) ))
              return new XMLConfiguration(fileName);
            if (NFX.CodeAnalysis.JSON.JSONLanguage.Instance.FileExtensions.Any(e => string.Equals(e, ext, StringComparison.InvariantCultureIgnoreCase) ))
              return new JSONConfiguration(fileName);
            throw new ConfigException(StringConsts.CONFIG_NO_PROVIDER_LOAD_FILE_ERROR + fileName);
        }
public static Configuration ProviderLoadFromFile ( string fileName ) { var ext = Path . GetExtension ( fileName ) . ToLower ( ) ; if ( ext . StartsWith ( " " ) ) ext = ext . Remove ( 0 , 1 ) ; if ( NFX . CodeAnalysis . Laconfig . LaconfigLanguage . Instance . FileExtensions . Any ( e => string . Equals ( e , ext , StringComparison . InvariantCultureIgnoreCase ) ) ) return new LaconicConfiguration ( fileName ) ; if ( NFX . CodeAnalysis . XML . XMLLanguage . Instance . FileExtensions . Any ( e => string . Equals ( e , ext , StringComparison . InvariantCultureIgnoreCase ) ) ) return new XMLConfiguration ( fileName ) ; if ( NFX . CodeAnalysis . JSON . JSONLanguage . Instance . FileExtensions . Any ( e => string . Equals ( e , ext , StringComparison . InvariantCultureIgnoreCase ) ) ) return new JSONConfiguration ( fileName ) ; throw new ConfigException ( StringConsts . CONFIG_NO_PROVIDER_LOAD_FILE_ERROR + fileName ) ; }
Loads the contents of the supplied file name in an appropriate configuration provider implementation for the supplied extension format
Loads the contents of the supplied file name in an appropriate configuration provider implementation for the supplied extension format
//since C# does not support first-class types, these if statements below must handle what AllSupportedFormat returns //in future Aum conversion replace with Dictionary<format, configType> lookup
fileName
string