Exemple #1
0
        public void ConfigureServices(IServiceCollection services)
        {
            _config = new CoreHierarchyServiceConfiguration();
            Configuration.Bind("CoreHierarchyServiceConfiguration", _config);
            services.AddSingleton(_config);

            services.ConfigureSwagger(_config);

            services.AddControllers();
        }
Exemple #2
0
        public static void BuildSwagger(this IApplicationBuilder app, ICoreHierarchyServiceConfiguration config)
        {
            app.UseSwagger();
            var asm = Assembly.GetExecutingAssembly();

            app.UseSwaggerUI(c =>
            {
                c.DocumentTitle = asm.GetCustomAttributes(typeof(AssemblyProductAttribute), false)
                                  .OfType <AssemblyProductAttribute>().FirstOrDefault()?.Product;
                c.SwaggerEndpoint($"/swagger/{config.SoftwareName}/swagger.json", config.SoftwareName);
                c.RoutePrefix = string.Empty;
            });
        }
        public Worker(ILogger <Worker> logger, CoreHierarchyServiceConfiguration config)
        {
            //_logger = logger;

            _config = config;


            Logging.InitializeLogging(_config);

            Log.Information("Sample Log output!");

            // We dont need the environment switch anymore!
            // when debugging this will automatically run in console mode, but when deployed will run as service! Cool
        }
Exemple #4
0
        // TODO - Placeholder as i know i will need to extend the service collection!
        //public static void ConfigureDependencies(this IServiceCollection services)
        //{
        //    services.AddTransient<UserCqrs or something>();
        //}

        public static void ConfigureSwagger(this IServiceCollection services, ICoreHierarchyServiceConfiguration config)
        {
            var asm = Assembly.GetExecutingAssembly();

            services.AddSwaggerGen(c =>
            {
                c.EnableAnnotations();
                c.SwaggerDoc(config.SoftwareName, new OpenApiInfo
                {
                    // TODO - Use reflection here to get the appropriate types.. i may do away with this...
                    Description = asm.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false).OfType <AssemblyDescriptionAttribute>().FirstOrDefault()?.Description,
                    Title       = asm.GetCustomAttributes(typeof(AssemblyProductAttribute), false).OfType <AssemblyProductAttribute>().FirstOrDefault()?.Product,
                    Version     = asm.GetName().Version.ToString()
                });
                c.DescribeAllEnumsAsStrings();
            });
        }