Example #1
0
File: Editor.cs Project: psla/nini
        /// <summary>
        /// Loads a sourc from file.
        /// </summary>
        private IConfigSource LoadSource(string path)
        {
            IConfigSource result    = null;
            string        extension = null;

            if (IsArg("set-type"))
            {
                extension = "." + GetArg("set-type").ToLower();
            }
            else
            {
                FileInfo info = new FileInfo(path);
                extension = info.Extension;
            }

            switch (extension)
            {
            case ".ini":
                result = new IniConfigSource(path);
                break;

            case ".config":
                result = new DotNetConfigSource(path);
                break;

            case ".xml":
                result = new XmlConfigSource(path);
                break;

            default:
                ThrowError("Unknown config file type");
                break;
            }
            if (verbose)
            {
                PrintLine("Loaded config: " + result.GetType().Name);
            }

            return(result);
        }