Example #1
0
        /// <summary>
        /// Read configuration from xml data file.
        /// </summary>
        /// <param name="filename">name of the configuration file</param>
        private void ReadXmlDatafile(string filename)
        {
            ProjectSetupKitConfiguration settings = null;

            try
            {
                var x      = new XmlSerializer(typeof(ProjectSetupKitConfiguration));
                var reader = new StreamReader(filename);
                settings = (ProjectSetupKitConfiguration)x.Deserialize(reader);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Caught exception when trying to read xml: {0}\n{1}", ex.Message, ex.StackTrace);
            }

            if (settings == null)
            {
                return;
            }

            m_inputModels = settings.Projects.Where(p => Directory.Exists(p.TemplateDirectory)).ToDictionary(p => p.Name, p => new InputModel(p));
            var defaultProject = settings.Projects.FirstOrDefault(s => s.IsDefault);

            m_activeProject = defaultProject != null ? defaultProject.Name : settings.Projects.First().Name;
        }
        public static ProjectSetupKitConfiguration LoadOrDefaultSettings(string filename)
        {
            ProjectSetupKitConfiguration settings = null;

            try
            {
                var x      = new XmlSerializer(typeof(ProjectSetupKitConfiguration));
                var reader = new StreamReader(filename);
                settings = (ProjectSetupKitConfiguration)x.Deserialize(reader);
            }
            catch (Exception ex)
            {
                //Logger.Error(ex, $"Caught exception when trying to read xml: {ex.Message}");
            }

            if (settings == null)
            {
                settings = new ProjectSetupKitConfiguration(DefaultSettings);
                settings.StoreToFile(filename);
            }

            return(settings);
        }
 public ProjectSetupKitConfiguration(ProjectSetupKitConfiguration orig)
 {
     Projects = orig.Projects.Select(p => new Project(p)).ToList();
 }