DLaB.EarlyBoundGenerator.Settings.EarlyBoundGeneratorConfig.Load C# (CSharp) Method

Load() public static method

public static Load ( string filePath ) : EarlyBoundGeneratorConfig
filePath string
return EarlyBoundGeneratorConfig
        public static EarlyBoundGeneratorConfig Load(string filePath)
        {
            try
            {
                filePath = Path.Combine(filePath, "DLaB.EarlyBoundGenerator.Settings.xml");
                if (!File.Exists(filePath))
                {
                    var config = GetDefault();
                    config._filePath = filePath;
                    return config;
                }

                var serializer = new XmlSerializer(typeof (POCO.Config));
                POCO.Config poco;
                using (var fs = new FileStream(filePath, FileMode.Open))
                {
                    poco = (POCO.Config) serializer.Deserialize(fs);
                    fs.Close();
                }
                var settings = new EarlyBoundGeneratorConfig(poco, filePath);
                return settings;
            }
            catch (Exception ex)
            {
                throw new Exception("An error occured attempting to load Xml configuration: " + filePath, ex);
            }
        }