コード例 #1
0
        public void TestOptionsWithBoolean()
        {
            const string args = "{ \"Mode\":\"Init\" }";

            var options = new Options(args);

            Assert.AreEqual("init", options.Mode);
        }
コード例 #2
0
 public static Process[] Create(string resource, ILogger logger, Options options = null, Dictionary<string, string> parameters = null) {
     return Create(
         new ConfigurationFactory(
             resource, 
             logger, 
             parameters
         ).Create(), 
         logger, 
         options
     );
 }
コード例 #3
0
 public TransformalizeRequest(
     ConfigurationPart part,
     Dictionary<string, string> query,
     string modifiedConfiguration,
     ILogger logger,
     TflRoot root = null) {
         Part = part;
         Configuration = modifiedConfiguration ?? part.Configuration;
         Query = query ?? new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
         Options = new Options { Mode = Query["mode"] };
         Root = root ?? new TflRoot(modifiedConfiguration ?? part.Configuration, Query, new CfgNetLogger(logger));
 }
コード例 #4
0
        private static Process[] Create(IEnumerable<TflProcess> tflProcesses, ILogger logger, Options options = null) {

            var processes = new List<Process>();
            options = options ?? new Options();

            foreach (var process in tflProcesses) {
                var kernal = process.Register(logger);
                process.Resolve(kernal);
                processes.Add(new ProcessReader(process, logger, options).Read());
            }

            return processes.ToArray();
        }
コード例 #5
0
        public static Process CreateSingle(string resource, ILogger logger, Options options = null, Dictionary<string, string> parameters = null) {
            var source = ConfigurationFactory.DetermineConfigurationSource(resource);
            logger.Info("Process Requested from {0}", source.ToString());

            return CreateSingle(
                new ConfigurationFactory(
                    resource, 
                    logger, 
                    CombineParameters(source, resource, parameters)
                ).Create()[0], 
                logger, 
                options
            );
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: modulexcite/Transformalize
        private static void Main(string[] args) {
            var processes = new List<Process>();

            if (args.Length == 0) {
                Console.WriteLine("Please provide the process(es) name, file, or address.");
                Console.WriteLine(@"Usage:");
                Console.WriteLine(@"   tfl fancy                      - looks in tfl.exe.config for fancy process.");
                Console.WriteLine(@"   tfl c:\fancy.xml               - looks for processes in c:\fancy.xml file.");
                Console.WriteLine(@"   tfl http://localhost/fancy.xml - makes web request for processes in http://localhost/fancy.xml.");
                return;
            }

            var resource = args[0];

            _options = new Options(CombineArguments(args));
            var listener = new ObservableEventListener();
            listener.EnableEvents(TflEventSource.Log, _options.LogLevel);
            var subscription = listener.LogToConsole(new LegacyLogFormatter());

            try {
                if (OptionsMayExist(args)) {
                    
                    if (_options.Valid()) {
                        if (_options.Mode == "rebuild") {
                            _options.Mode = "init";
                            processes.AddRange(ProcessFactory.Create(resource, new RunLogger(), _options));
                            _options.Mode = "first";
                            processes.AddRange(ProcessFactory.Create(resource, new RunLogger(), _options));
                        } else {
                            processes.AddRange(ProcessFactory.Create(resource, new RunLogger(), _options));
                        }
                    } else {
                        foreach (var problem in _options.Problems) {
                            Console.WriteLine(resource + " | " + problem);
                        }
                        Console.WriteLine(resource + " | Aborting process.");
                        Environment.Exit(1);
                    }
                } else {
                    processes.AddRange(ProcessFactory.Create(resource, new RunLogger()));
                }
            } catch (Exception e) {
                Console.WriteLine(e.Message);
                listener.DisableEvents(TflEventSource.Log);
                listener.Dispose();
                return;
            }

            foreach (var process in processes) {
                try {
                    process.ExecuteScaler();
                } catch (TransformalizeException e) {
                    Console.WriteLine(e.Message);
                    break;
                }
            }


            listener.DisableEvents(TflEventSource.Log);
            listener.Dispose();
            subscription.Dispose();
        }
コード例 #7
0
 public ProcessReader(TflProcess process, ILogger logger, Options options) {
     _configuration = process;
     _logger = logger;
     _options = options;
     _runner = GetRunner(DetermineMode());
 }
コード例 #8
0
 public static Process CreateSingle(TflProcess process, ILogger logger, Options options = null) {
     return Create(new List<TflProcess> { process }, logger, options)[0];
 }
コード例 #9
0
 /// <summary>
 /// Create process(es) from a configuration element.
 /// </summary>
 /// <param name="element">The Cfg-NET configuration element.</param>
 /// <param name="logger">An ILogger implementation.</param>
 /// <param name="options"></param>
 /// <returns></returns>
 public static Process[] Create(TflRoot element, ILogger logger, Options options = null) {
     return Create(element.Processes, logger, options);
 }