Пример #1
0
    private new void Awake()
    {
        base.Awake();
        SetState(State.Menu);

        MapperConfiguration.Configure();
    }
Пример #2
0
        public static void Register(HttpConfiguration config)
        {
            //setting the json formatter to camelcasing
            var jsonFormatter = config.Formatters.JsonFormatter;

            jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
            //jsonFormatter.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;

            // Web API configuration and services

            var cors = new EnableCorsAttribute("*", "*", "*");

            config.EnableCors(cors);

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );
            MapperConfiguration.Configure();

            var container = new UnityContainer();

            AppDependancyRegistry.Register(container);
            config.DependencyResolver = new UnityResolver(container);
        }
Пример #3
0
        public void TestMethod1()
        {
            // Mapper映射
            MapperConfiguration.Configure();
            EQEventService service = new EQEventService();
            var            eqevent = service.GetById();

            Assert.AreEqual(eqevent.EQId, "20150109121037");
            //            public ActionResult Index()
            //{
            //    var xx = EQEventService.GetById();
            //    return Json(xx);
            //}
            //public ActionResult IndexSql()
            //{
            //    var xx = EQEventService.GetByIdSql();
            //    return Json(xx);
            //}
            //public ActionResult IndexInclude()
            //{
            //    var xx = EQEventService.IncludeEQEvent();
            //    return Json(xx);
            //}
            ////一对多最佳测试
            //public ActionResult Index1()
            //{
            //    var xx = EQEventService.GetEQEventTask();
            //    return View();
            //}
        }
Пример #4
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     GlobalConfiguration.Configure(WebApiConfig.Register);
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     MapperConfiguration.Configure();
 }
Пример #5
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     GlobalConfiguration.Configure(WebApiConfig.Register);
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     MapperConfiguration.Configure();
     AutofacWebapiConfig.Initialize(GlobalConfiguration.Configuration);
 }
Пример #6
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     MapperConfiguration.Configure();
     AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.NameIdentifier;
 }
        public override void RegisterArea(AddinAreaRegistrationContext context)
        {
            context.MapRoute(
                name: AreaName + "_default",
                url: AreaName + "/{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
                namespaces: new[] { "Kooboo.Commerce.Multilingual.Controllers", "Kooboo.Web.Mvc", "Kooboo.Web.Mvc.WebResourceLoader" }
                );

            Kooboo.Web.Mvc.WebResourceLoader.ConfigurationManager.RegisterSection(AreaName, AreaHelpers.CombineAreaFilePhysicalPath(AreaName, "WebResources.config"));

            MapperConfiguration.Configure();
            SqlceConfiguration.Configure();
        }
Пример #8
0
        public override void Configure(Container container)
        {
            //ASP.NET MVC integration
            ControllerBuilder.Current.SetControllerFactory(new FunqControllerFactory(container));
            SetConfig(CreateEndpointHostConfig());

            JsConfig.EmitCamelCaseNames = true;

            Plugins.Add(new ValidationFeature());
            container.RegisterValidators(typeof(AppHost).Assembly);

            Plugins.Add(new AuthFeature(() => new AuthUserSession(),
                                        new IAuthProvider[] { new CredentialsAuthProvider() }
                                        ));
            WebBootStrapper.ConfigureDependencies(container);
            ConfigureAuthorization(container);

            MapperConfiguration.Configure();
        }
Пример #9
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
            services.AddSingleton <DataContext>();

            services.AddSingleton <IUnitOfWork, UnitOfWork>();

            services.AddTransient <IAircraftService, AircraftService>();
            services.AddTransient <IAircraftTypesService, AircraftTypesService>();
            services.AddTransient <ICrewService, CrewService>();
            services.AddTransient <IDepartureService, DepartureService>();
            services.AddTransient <IFlightService, FlightService>();
            services.AddTransient <IPilotService, PilotService>();
            services.AddTransient <IStewardessService, StewardessService>();
            services.AddTransient <ITicketService, TicketService>();

            MapperConfiguration mapper = new MapperConfiguration();

            services.AddSingleton(_ => mapper.Configure().CreateMapper());
        }
Пример #10
0
        protected void Application_Start()
        {
            //全半角转换
            ModelBinders.Binders.Add(typeof(string), new TrimToDBCModelBinder());
            ModelBinders.Binders.Add(typeof(int), new TrimToDBCModelBinder());
            ModelBinders.Binders.Add(typeof(long), new TrimToDBCModelBinder());
            ModelBinders.Binders.Add(typeof(double), new TrimToDBCModelBinder());

            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            log4net.Config.XmlConfigurator.Configure();
            // Mapper映射
            MapperConfiguration.Configure();
            // 全局路由配置
            FilterConfig.RegisterFilters(GlobalFilters.Filters);

            // 开启作业调度
            startQuartz();
            //
            InitAutoFac();
        }
Пример #11
0
 public void Configuration(IAppBuilder app)
 {
     ConfigureAuth(app);
     MapperConfiguration.Configure();
 }
Пример #12
0
 public static void Init(ContainerBuilder containerBuilder)
 {
     MapperConfiguration.Configure();
     Register(containerBuilder);
 }
Пример #13
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <Context>(options =>
            {
                options.UseNpgsql(Configuration.GetConnectionString("WebApiConnection"));
            }
                                            );

            services.AddCors(c =>
            {
                c.AddDefaultPolicy(options => options.AllowAnyOrigin()
                                   .AllowAnyHeader()
                                   .AllowAnyMethod());
            });

            services.AddControllers().AddNewtonsoftJson(o =>
            {
                o.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
                o.SerializerSettings.Converters.Add(new StringEnumConverter());
            }
                                                        );

            services.ConfigureProblemDetailsModelState();

            ServicesConfiguration.ConfigureDependencies(services);
            RepositoriesConfiguration.ConfigureDependencies(services);

            services.AddSingleton(MapperConfiguration.Configure());
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();

            var tokenConfigurations = new TokenConfigurations();

            new ConfigureFromConfigurationOptions <TokenConfigurations>(Configuration.GetSection("TokenConfigurations"))
            .Configure(tokenConfigurations);
            services.AddSingleton(tokenConfigurations);

            var key = Encoding.ASCII.GetBytes(tokenConfigurations.Key);

            services.AddAuthentication(x =>
            {
                x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                x.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            }).AddJwtBearer(x =>
            {
                x.RequireHttpsMetadata      = false;
                x.SaveToken                 = true;
                x.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateIssuerSigningKey = true,
                    IssuerSigningKey         = new SymmetricSecurityKey(key),
                    ValidateIssuer           = false,
                    ValidateAudience         = false
                };
            });

            services.AddAuthorization(a =>
            {
                a.AddPolicy("Authorization", new AuthorizationPolicyBuilder()
                            .AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme‌​)
                            .RequireAuthenticatedUser().Build());
            });

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Version     = "v1",
                    Title       = "Api para gerenciamento de empréstimo de Jogos",
                    Description = "Gerenciar empréstimos dos jogos para os amigos"
                });

                c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
                {
                    Description = "Entre com 'Bearer', espaço e Token JWT",
                    Name        = "Authorization",
                    In          = ParameterLocation.Header,
                    Type        = SecuritySchemeType.ApiKey
                });

                c.AddSecurityRequirement(new OpenApiSecurityRequirement {
                    {
                        new OpenApiSecurityScheme {
                            Reference = new OpenApiReference {
                                Id   = "Bearer",
                                Type = ReferenceType.SecurityScheme
                            }
                        }, new List <string>()
                    }
                });
            });
        }
 public static void Init(Type type)
 {
     MapperConfiguration.Configure(type);
 }
Пример #15
0
 private static void RegisterServerConfiguration()
 {
     ConfigureAutofacConfiguration();
     ConfigureFluentValidation();
     MapperConfiguration.Configure();
 }
Пример #16
0
 static App()
 {
     Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(Settings.Default.Localization);
     DispatcherHelper.Initialize();
     MapperConfiguration.Configure();
 }
Пример #17
0
 public void Setup()
 {
     MapperConfiguration.Configure();
 }
Пример #18
0
        public void Copy_NotNull_SameTransactionDifferentId()
        {
            //given
            var user = new Stock {
                Name = "User1", IsUserStock = true
            };
            var external = new Stock {
                Name = "Ex"
            };
            var type = new TransactionType {
                Income = true, IsDefault = true
            };
            var tag = new Tag {
                Name = "tag"
            };
            var category = new Model.Category {
                Name = "cat"
            };
            var parent = new Transaction
            {
                Title = "Title",
                Notes = new TrulyObservableCollection <Note> {
                    new Note("Note")
                },
                BookDate      = DateTime.Today,
                UserStock     = user,
                ExternalStock = external,
                Type          = type
            };
            var storedFileInfo = new StoredFileInfo("file", parent.Id);

            parent.StoredFiles.Add(storedFileInfo);
            var source = new Position
            {
                Value    = new PaymentValue(10, 10, 0),
                Category = category,
                Title    = "pos",
                Tags     = new[] { tag },
                Parent   = parent
            };

            parent.Positions = new TrulyObservableCollection <Position>(new[] { source });
            MapperConfiguration.Configure();

            //when
            var result = Position.Copy(source);

            //then
            Assert.NotNull(result);
            Assert.NotEqual(source.Id, result.Id);
            Assert.Equal(source.Value.NetValue, result.Value.NetValue);
            Assert.Equal(source.Value.GrossValue, result.Value.GrossValue);
            Assert.Equal(source.Value.TaxPercentValue, result.Value.TaxPercentValue);
            Assert.Equal(source.Parent, result.Parent);
            Assert.Equal(source.BookDate, result.BookDate);
            Assert.Equal(source.Category, result.Category);
            Assert.Equal(source.Tags, result.Tags);
            Assert.Equal(source.Title, result.Title);

            //parent
            Assert.Equal(parent.Id, result.Parent.Id);
            Assert.Equal(parent.Title, result.Parent.Title);
            Assert.Equal(parent.Notes, result.Parent.Notes);
            Assert.Equal(parent.BookDate, result.Parent.BookDate);
            Assert.Equal(parent.UserStock, result.Parent.UserStock);
            Assert.Equal(parent.ExternalStock, result.Parent.ExternalStock);
            Assert.Equal(parent.IsPropertyChangedEnabled, result.Parent.IsPropertyChangedEnabled);
            Assert.Equal(parent.Type, result.Parent.Type);
            Assert.Equal(parent.Positions.Count, result.Parent.Positions.Count);
            Assert.True(result.Parent.IsValid);
        }
Пример #19
0
 private static void RegisterSystemConfiguration()
 {
     ConfigureAutofac();
     FluentValidationModelValidatorProvider.Configure();
     MapperConfiguration.Configure();
 }
Пример #20
0
        public void Copy_NotNull_SameTransactionDifferentId()
        {
            //given
            var user = new Stock {
                Name = "User1", IsUserStock = true
            };
            var external = new Stock {
                Name = "Ex"
            };
            var type = new TransactionType {
                Income = true, IsDefault = true
            };
            var position = new Position
            {
                Value    = new PaymentValue(10, 10, 0),
                Category = new Model.Category {
                    Name = "cat"
                },
                Title = "pos",
                Tags  = new [] { new Tag {
                                     Name = "tag"
                                 } }
            };
            var source = new Transaction
            {
                Title = "Title",
                Notes = new TrulyObservableCollection <Note> {
                    new Note("Note")
                },
                BookDate      = DateTime.Today,
                UserStock     = user,
                ExternalStock = external,
                Type          = type,
                Positions     = new TrulyObservableCollection <Position>(new[] { position })
            };
            var storedFileInfo = new StoredFileInfo("file", source.Id);

            source.StoredFiles.Add(storedFileInfo);

            var expected = new Transaction($"{source.Id}{DateTime.Now}".GenerateGuid())
            {
                Title = "Title",
                Notes = new TrulyObservableCollection <Note> {
                    new Note("Note")
                },
                BookDate      = DateTime.Today,
                UserStock     = user,
                ExternalStock = external,
                Type          = type,
                Positions     = new TrulyObservableCollection <Position>(new[] { position })
            };

            expected.StoredFiles.Add(storedFileInfo);
            MapperConfiguration.Configure();

            //when
            var result = Transaction.Copy(source);

            //then
            Assert.NotNull(result);
            Assert.NotEqual(source.Id, result.Id);
            Assert.Equal(expected.Title, result.Title);
            Assert.Equal(expected.Notes.Select(x => x.Value), result.Notes.Select(x => x.Value));
            Assert.Equal(expected.BookDate, result.BookDate);
            Assert.Equal(expected.UserStock, result.UserStock);
            Assert.Equal(expected.ExternalStock, result.ExternalStock);
            Assert.Equal(expected.IsPropertyChangedEnabled, result.IsPropertyChangedEnabled);
            Assert.Equal(expected.Type, result.Type);
            Assert.Equal(expected.Positions.Count, result.Positions.Count);
            Assert.True(result.IsValid);
        }