Beispiel #1
0
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddMvc();
     services.AddCors();
     services.AddSingleton(Configuration);
     IoCConfiguration.Configure(services);
 }
Beispiel #2
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     IoCConfiguration.Configure();
     BundleConfig.RegisterBundles(BundleTable.Bundles);
 }
Beispiel #3
0
        public static void Main(string[] args)
        {
            var cb        = new ContainerBuilder();
            var container = IoCConfiguration.Configure(cb);
            var logger    = container.Resolve <ILogger>();

            var configuration = new ConfigurationBuilder()
                                .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                                .Build();

            StaticResources.ConnectionString = configuration.GetConnectionString("DefaultConnection");

            Console.WriteLine("Please enter a valid file name to be processed for Trade data :");
            var fileName = Console.ReadLine();

            if (string.IsNullOrWhiteSpace(fileName))
            {
                logger.Error("No file path provided.");
                Console.WriteLine("Please provide a file path next time.");
                Console.ReadKey();
                return;
            }

            if (!File.Exists(fileName))
            {
                logger.Error($"File {fileName} does not exist");

                Console.WriteLine("Next time, Please provide a file path which actually exists.");
                Console.ReadKey();
                return;
            }

            try
            {
                using (var fs = File.OpenRead(fileName))
                {
                    using (var scope = container.BeginLifetimeScope())
                    {
                        (scope.Resolve <ITradeProcessor>()).ProcessTrades(fs);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("Exception occurred : {ex}", ex);
            }
            finally
            {
                Console.WriteLine("Trade processor run finished. Thanks.");
                Console.ReadKey();
            }
        }
Beispiel #4
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc()
            .AddJsonOptions(opt =>
            {
                //var resolver = opt.SerializerSettings.ContractResolver;
                //if (resolver != null)
                //{
                //    var res = resolver as DefaultContractResolver;
                //    res.NamingStrategy = null;  // <<!-- this removes the camelcasing
                //}

                var jsonSettings                   = opt.SerializerSettings;
                jsonSettings.Formatting            = Formatting.Indented;
                jsonSettings.ContractResolver      = new CamelCasePropertyNamesContractResolver();
                jsonSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            });

            services.AddSingleton(Configuration);
            IoCConfiguration.Configure(services);
        }
Beispiel #5
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton(Configuration);
            IoCConfiguration.Configure(services);
            services.AddScoped <TodoValidator>();
            services.AddSwaggerGen();
            var pathToDoc = Configuration["Swagger:Path"];

            //localhost:59103/swagger/ui/index.html
            services.ConfigureSwaggerGen(options =>
            {
                options.SingleApiVersion(new Swashbuckle.Swagger.Model.Info
                {
                    Version        = "v1",
                    Title          = "TodoApp Api",
                    Description    = "",
                    TermsOfService = "none"
                });
                options.IncludeXmlComments(pathToDoc);
                options.DescribeAllEnumsAsStrings();
            });
            services.AddMvc();
        }
Beispiel #6
0
 public void ConfigureIoC(IServiceCollection services)
 {
     IoCConfiguration.Configure(services);
 }