Exemplo n.º 1
0
        public static DataConfiguration Empty()
        {
            DataConfiguration configuration = new DataConfiguration();

            configuration.Queues = new List <QueueConfiguration>();
            return(configuration);
        }
        /// <summary>
        /// Loads configurations
        /// </summary>
        public DataConfiguration Load(string fullpath)
        {
            if (!File.Exists(fullpath))
            {
                var    c          = DataConfiguration.Empty();
                string serialized = Newtonsoft.Json.JsonConvert.SerializeObject(c);

                string dir = FindDirectoryIfFile(ConfigurationFactory.Builder.ConfigFile);
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }

                File.WriteAllText(ConfigurationFactory.Builder.ConfigFile, serialized);
                return(c);
            }

            string            json          = File.ReadAllText(fullpath);
            DataConfiguration configuration = Newtonsoft.Json.JsonConvert.DeserializeObject <DataConfiguration>(json);

            return(configuration);
        }