Exemplo n.º 1
0
        private bool Run(string configuration, string path, IOutput output)
        {
            List <ConfigurationSet>  configurations = this.Deserialize(configuration);
            ConfigurationEnvironment environment    = new ConfigurationEnvironment(path, output.ToString());

            configurations.SelectMany(x => x.Readers)
            .Concat(configurations.SelectMany(x => x.Writers))
            .ForEach(x => x.Environment = environment);
            return(this.Run(configurations, output));
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            ConfigurationEnvironment environment = ConfigurationManager.NewEnvironment(@"C:\users\tomas\Desktop\cfgConfigTests\env1", "AppSettings")
                                                   .WithConfiguration <KeyValuePairConfiguration>("languages", configure => configure.Encrypt().Build()).Build();

            KeyValuePairConfiguration config = environment.GetKeyValueConfiguration("languages");



            Console.ReadLine();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Returns a <see cref="ConfigurationEnvironment"/> by its name
        /// </summary>
        /// <param name="name">The name of the configuration environment to get</param>
        public static ConfigurationEnvironment GetEnvironment(string name)
        {
            Validator.Validate(name);

            // Try to get an environment
            ConfigurationEnvironment environment = Environments.FirstOrDefault(x => x.Name == name);

            // Environment not found
            if (environment == null)
            {
                throw new InvalidOperationException($"Environment with name '{name}' not found.");
            }

            return(environment);
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            Console.Title = "sqlcon";
            Console.WriteLine($"SQL Console [Version {Helper.ApplicationVerison}]");
            Console.WriteLine($"Copyright (c) 2014-{DateTime.Today.Year} Datconn. All rights reserved.");
            Console.WriteLine();

            Constant.MAX_CPU_REG_NUM     = 2 * 1024;
            Constant.MAX_STRING_SIZE     = 24 * 1024 * 1024;
            Constant.MAX_SRC_COL         = 24 * 1024 * 1024;
            Constant.MAX_INSTRUCTION_NUM = 1 * 1024 * 1024;
            var cfg = ConfigurationEnvironment.PrepareConfiguration(false);


            //Register database connection providers
            Sys.Data.SqlServerCe.Main.RegisterConnectionProvider();
            Sys.Data.Sqlite.Main.RegisterConnectionProvider();


            int i = 0;

            while (i < args.Length)
            {
                switch (args[i++])
                {
                case "/cfg":
                    if (i < args.Length && !args[i].StartsWith("/"))
                    {
                        cfg.Personal = args[i++];
                        goto L1;
                    }
                    else
                    {
                        cout.WriteLine("/cfg configuration file missing");
                        return;
                    }

                case "/h":
                case "/?":
                    sqlcon.Main.ShowHelp();
                    return;
                }
            }

L1:


            Configuration = new ApplicationConfiguration();
            try
            {
                if (!Configuration.Initialize(cfg))
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                cout.WriteLine("error on configuration file {0}, {1}:", cfg.Personal, ex.Message);
                return;
            }

#if DEBUG
            var site = new Main(Configuration);
            site.Run(args);
#else
            try
            {
                var site = new Main(Configuration);
                site.Run(args);
            }
            catch (Exception ex)
            {
                cerr.WriteLine(ex.Message);
                //stdio.ShowError(ex.StackTrace);
                cerr.WriteLine("fatal error, hit any key to exit");
                cin.ReadKey();
            }
#endif
        }