Example #1
0
        public static void Main(string[] args)
        {
            Console.OutputEncoding = System.Text.Encoding.UTF8;
            var diSetup = new DependencyInjectionSetup().GetScope();

            Gui gui = new GuiAdapter();

            gui.InitializeGui();

            // Code to test if game states are changing

            //var flyweights = new FlyweightFactory();

            //var game = Game.Instance;
            //game.GetState().DoAction(game);
            //Console.WriteLine(game.GetState());

            //var startedState = flyweights.GetState(GameStates.Started);
            //startedState.DoAction(game);
            //Console.WriteLine(game.GetState());

            //var endedState = flyweights.GetState(GameStates.Ended);
            //endedState.DoAction(game);
            //Console.WriteLine(game.GetState());
        }
Example #2
0
        /// <summary>
        /// This method gets called by the runtime. Use this method to add services to the container.
        /// </summary>
        /// <param name="services"></param>
        public void ConfigureServices(IServiceCollection services)
        {
            DatabaseSetup.AddDatabaseSetup(services, Configuration);
            IdentitySetup.AddIdentitySetup(services, Configuration);
            AuthenticationJwtSetup.AddAuthenticationJwtSetup(services, Configuration);
            AutoMapperSetup.AddAutoMapperSetup(services);
            DependencyInjectionSetup.AddDependencyInjectionSetup(services);
            SwaggerSetup.AddSwaggerSetup(services);

            // Determinar que a api vai chamar uma determinada controller
            services.AddMvc(options =>
            {
                // configuração que obrigar que seja informado uma autenticação
                // garante que todas as requests sejam autenticadas
                var policy = new AuthorizationPolicyBuilder()
                             .RequireAuthenticatedUser()
                             .Build();

                options.Filters.Add(new AuthorizeFilter(policy));
            })
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
            // Configuração para não retorna referencia cicular no json
            .AddJsonOptions(options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore);

            services.AddCors();
        }
Example #3
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);
     AutoMapperSetup.AddAutoMapperSetup(services);
     SwaggerSetup.AddSwaggerSetup(services);
     DependencyInjectionSetup.AddDependencyInjectionSetup(services, Configuration);
     ApiSetup.AddApiSetup(services, Configuration);
 }
Example #4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            //habilitar o MVC
            services.AddControllersWithViews().AddRazorRuntimeCompilation();

            //configurando o entityframework
            EntityFrameworkSetup.AddEntityFramework(services, Configuration);

            //configurando a injeção de dependência
            DependencyInjectionSetup.AddDependencyInjection(services);
        }
        private IDependencyResolver InitializeDepedencyResolver()
        {
            var builder = new ContainerBuilder();

            builder.RegisterControllers(typeof(MvcApplication).Assembly);
            builder.RegisterModule <AutofacWebTypesModule>();
            DependencyInjectionSetup.RegisterDependencies(builder);
            var container = builder.Build();

            return(new AutofacDependencyResolver(container));
        }
Example #6
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            SwaggerSetup.ConfigureServices(services);

            CorsSetup.ConfigureServices(services);

            EntityFrameWorkSetup.ConfigurationServices(services, Configuration);

            DependencyInjectionSetup.ConfigureServices(services);

            JWTSetup.ConfigureServices(services, Configuration);

            AutoMapperSetup.ConfigureServices(services);
        }
Example #7
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            //Configuração do Swagger
            SwaggerSetup.ConfigureServices(services);

            //Configuração do CORS
            CorsSetup.ConfigureServices(services);

            //Configuração do EntityFramework
            EntityFrameworkSetup.ConfigureServices(services, Configuration);

            //Configuração de Injeção de Dependência
            DependencyInjectionSetup.ConfigureServices(services);

            //Configuração do AutoMapper
            AutoMapperSetup.ConfigureServices(services);
        }