Exemple #1
0
        /// <summary>
        ///     The register types.
        /// </summary>
        /// <param name="options"></param>
        /// <returns>
        ///     The <see cref="ContainerBuilder" />.
        /// </returns>
        public static ContainerBuilder RegisterTypes(IDscManagerOptions options)
        {
            var containerBuilder = new ContainerBuilder();

            containerBuilder.RegisterType <EnvironmentProperties>().AsImplementedInterfaces().SingleInstance();

            var allAssemblies = AppDomain.CurrentDomain.GetAssemblies();

            // Register API infrastructure
            containerBuilder.Register(c => new HttpConfiguration()).AsSelf().AsImplementedInterfaces().SingleInstance();
            containerBuilder.RegisterApiControllers(
                allAssemblies.Where(a => a.FullName.StartsWith("Ticketmaster.")).ToArray());

            var assemblies = allAssemblies.Where(a => a.FullName.StartsWith("Ticketmaster."));

            foreach (var assembly in assemblies)
            {
                foreach (var viewModel in assembly.GetTypes().Where(t => typeof(IViewModel).IsAssignableFrom(t)))
                {
                    containerBuilder.RegisterType(viewModel).AsSelf().AsImplementedInterfaces().InstancePerDependency();
                }
            }

            containerBuilder.Register(c => new ViewModelFactory(c.Resolve <IComponentContext>()))
            .AsSelf()
            .AsImplementedInterfaces()
            .SingleInstance();

            containerBuilder.Register(c => new DscManagerContext("DscManager")).AsSelf();
            containerBuilder.RegisterType <DscManagerContextInitializer>().AsSelf().AsImplementedInterfaces();
            containerBuilder.RegisterType <DataInitializer>().AsSelf().AsImplementedInterfaces();

            // Services
            containerBuilder.RegisterType <DatabaseLogger>().AsImplementedInterfaces().SingleInstance();
            containerBuilder.RegisterType <ConsoleLogger>().AsImplementedInterfaces();
            containerBuilder.RegisterType <DscEventManager>().AsImplementedInterfaces().SingleInstance();
            containerBuilder.RegisterType <DscLogging>().AsImplementedInterfaces();
            containerBuilder.RegisterType <ExceptionLogger>().AsImplementedInterfaces();
            if (options.UseSlackLogging)
            {
                containerBuilder.RegisterType <SlackLogger>().AsImplementedInterfaces();
            }
            containerBuilder.Register(
                c =>
                new SlackIntegrationService(
                    new SlackIntegrationOptions
            {
                ProxyUri            = "http://squid.sys.tash1.syseng.tmcs:3128",
                UseProxy            = true,
                SlackDefaultChannel = "#archtics-dsc-pov",
                SlackDefaultName    = "DscManager",
                SlackDestinationUri =
                    "https://hooks.slack.com/services/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"
            })).AsImplementedInterfaces();

            return(containerBuilder);
        }
Exemple #2
0
 public DataInitializer(
     DscManagerContext dscContext,
     DeploymentServerContext deploymentContext,
     NodeRepositoryContext nodeContext,
     ReportingEndpointContext reportingContext,
     IDscManagerOptions options)
 {
     this.DscContext        = dscContext;
     this.DeploymentContext = deploymentContext;
     this.NodeContext       = nodeContext;
     this.ReportingContext  = reportingContext;
     this.Options           = options;
 }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DatabaseLogger"/> class.
 /// </summary>
 /// <param name="eventManager">
 /// The event manager.
 /// </param>
 /// <param name="context">
 /// The context.
 /// </param>
 /// <param name="container">
 /// The container.
 /// </param>
 /// <param name="options">
 /// The options.
 /// </param>
 /// <param name="logging">
 /// The logging.
 /// </param>
 public DatabaseLogger(
     IDscEventManager eventManager,
     DscManagerContext context,
     ILifetimeScope container,
     IDscManagerOptions options,
     IDscManagerLogging logging)
     : base(eventManager)
 {
     this.Context           = context;
     this.LoggingRepository = context.Set <LoggingEntity>();
     this.Container         = container;
     this.Options           = options;
     this.Logging           = logging;
 }
Exemple #4
0
 /// <summary>
 /// The get dsc manager options.
 /// </summary>
 /// <returns>
 /// The <see cref="IDscManagerOptions"/>.
 /// </returns>
 public static IDscManagerOptions GetDscManagerOptions()
 {
     return(Options
            ?? (Options = DscManagerOptions.ReadFromFile(AppDomain.CurrentDomain.BaseDirectory + @"\config.json")));
 }