Ejemplo n.º 1
0
 public Processor(
     IKeyValueRepository repository,
     ImagingOptions options)
 {
     _repository = repository;
     _options    = options;
 }
Ejemplo n.º 2
0
        public static void Main(string[] args)
        {
            try
            {
                var options = new ImagingOptions();

                Container = IocConfig.RegisterDependencies(options);
                LogConfig.RegisterLogs();

                if (CommandLine.Parser.Default.ParseArguments(args, options))
                {
                    Log.Error("Invalid parameters");

                    // Values are available here
                    if (options.Verbose)
                    {
                        Log.Information($"Queue Name: {options.QueueName}");
                        Log.Information($"Usage: {Environment.NewLine}{options.GetUsage()}");
                    }

                    return;
                }

                Log.Information($"Starting Imaging Worker with options {args}");

                Log.Information("Creating bus");
                BusControl = Container.Resolve <IBusControl>();

                Log.Information("Starting bus");
                BusHandle = BusControl.Start();

                Console.WriteLine("Press any key to exit");
                Console.ReadLine();
            }
            catch (Exception ex1)
            {
                Log.Fatal(ex1, "Imaging Worker Error");
                Console.ReadLine();
            }
            finally
            {
                if (BusHandle != null)
                {
                    try
                    {
                        Log.Information("Stopping bus");
                        BusHandle.Stop();
                    }
                    catch (Exception ex2)
                    {
                        Log.Warning(ex2, "Error while stopping bus");
                    }
                }
            }
        }
Ejemplo n.º 3
0
        internal static IContainer RegisterDependencies(ImagingOptions options)
        {
            var builder = new ContainerBuilder();

            builder.RegisterModule(new BusModule(Assembly.GetExecutingAssembly()));

            builder.RegisterType <RedisKeyValueStore>().As <IKeyValueStore>().SingleInstance();
            builder.RegisterType <RedisKeyValueRepository>().As <IKeyValueRepository>().SingleInstance();
            builder.RegisterType <Processor>().As <IProcessor>();
            builder.RegisterInstance(options);

            return(builder.Build());
        }