Automatr.AutomatrConfig.Load C# (CSharp) Method

Load() public static method

public static Load ( string path ) : AutomatrConfig
path string
return AutomatrConfig
        public static AutomatrConfig Load(string path)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(AutomatrConfig));

            AutomatrConfig result = null;
            try
            {
                using (StreamReader reader = new StreamReader(path))
                {
                    result = (AutomatrConfig)serializer.Deserialize(reader);
                }
                AutomatrLog.Log("Loaded config " + path, AutomatrLog.LogLevel.Verbose);
            }
            catch
            {
                result = new AutomatrConfig();
            }

            return result;
        }

Usage Example

Example #1
0
        public static void Main(string[] args)
        {
            Options = new AutomatrOptions();
            Parser parser = new Parser(new Action <ParserSettings>((ParserSettings p) => { p.CaseSensitive = false; p.IgnoreUnknownArguments = false; p.MutuallyExclusive = true; }));
            bool   parse  = parser.ParseArguments(args, Options);

            if (Options.Version)
            {
                AutomatrLog.Log("Automatr " + Version, AutomatrLog.LogLevel.Info);
                return;
            }

            AutomatrConfig config   = AutomatrConfig.Load(Options.ConfigPath);
            Automatr       automatr = new Automatr(config);

            automatr.Run();
        }