static int Initialize(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 1);
        MapConfig obj = (MapConfig)LuaScriptMgr.GetNetObjectSelf(L, 1, "MapConfig");

        obj.Initialize();
        return(0);
    }
Exemple #2
0
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;

            MapConfig.Initialize(initializer =>
            {
                CentralLendingApi.Services.Mappers.InitMapperConfiguration.Init(initializer);
            });
        }
Exemple #3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler(
                    options =>
                {
                    options.Run(
                        async httpcontext =>
                    {
                        httpcontext.Response.ContentType = "text/html";
                        var err = $"<h2>Bank application is experiencing issues. Please log a support ticket with the Global IT Service Desk</h2>";
                        await httpcontext.Response.WriteAsync(err).ConfigureAwait(false);
                    });
                });
            }

            app.UseStaticFiles();

            app.UseIdentity();

            // Add external authentication middleware below. To configure them please see http://go.microsoft.com/fwlink/?LinkID=532715

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            MapConfig.Initialize();

            var context = app.ApplicationServices.GetRequiredService <ApplicationDbContext>();

            DbInitializer.Initialize(context);

            CreateUserRoles(app.ApplicationServices).Wait();
        }
Exemple #4
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider services, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddEventLog();

            if (env.IsDevelopment())
            {
                app.UseBrowserLink();
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                //app.UseExceptionHandler("/Home/Error");

                app.UseExceptionHandler(
                    options =>
                {
                    options.Run(
                        async context =>
                    {
                        context.Response.ContentType = "text/html";
                        var err = $"<h2>Bank application is experiencing issues. Please log a support ticket with the Global IT Service Desk</h2>";
                        await context.Response.WriteAsync(err).ConfigureAwait(false);
                    });
                });
            }

            app.UseStaticFiles();

            app.UseAuthentication();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            MapConfig.Initialize();

            CreateUserRoles(services).Wait();
        }
 public static void InitHMapper()
 {
     MapConfig.Initialize(initializer =>
     {
         initializer.Map <Business.VerySimpleClass, DTO.VerySimpleClass>();
         initializer.Map <Business.SimpleClass, DTO.SimpleClass>()
         .WithMember(x => x.Key, api => api.LinkTo(x => x.Id))
         .WithMember(x => x.Date_Plus_2, api => api.LinkTo(x => x.Date.AddDays(2)))
         .WithMember(nameof(DTO.SimpleClass.StringToBeIgnored), api => api.Ignore())
         .WithMember(x => x.VerySimpleClass2String, api => api.LinkTo(x => x.VerySimpleClass2.MyString));
         initializer.Map <Business.SimpleClass, DTO.SimpleClass2>()
         .WithMember(x => x.Key, api => api.LinkTo(nameof(Business.SimpleClass.Id)));
         initializer.Map <Business.SimpleSet, DTO.SimpleSet>();
         initializer.Map <Business.MultipleSets, DTO.MultipleSets>();
         initializer.Map <Business.DictionarySet, DTO.DictionarySet>();
         initializer.Map <Business.SimpleGeneric <TGen1>, DTO.SimpleGeneric <TGen1> >();
         initializer.Map <Business.MappedObjectGeneric <TGen1>, DTO.MappedObjectGeneric <TGen1> >();
         initializer.Map <Business.MultipleGenerics <TGen2, TGen1>, DTO.MultipleGenerics <TGen1, TGen2> >();
         initializer.Map <Business.PolymorphicSubClass, DTO.PolymorphicSubClass>();
         initializer.Map <Business.PolymorphicBaseClass, DTO.PolymorphicBaseClass>();
         initializer.Map <Business.SetOfPolymorphic, DTO.SetOfPolymorphic>();
         initializer.Map <Business.SetOfGenericPolymorph, DTO.SetOfGenericPolymorph>();
     });
 }
 public RepositoryTestBase()
 {
     MapConfig.Initialize();
     this.Context          = BankContextSeedExtensions.GetInMemoryDbContext();
     this.BranchRepository = new BranchRepository(this.Context);
 }
Exemple #7
0
        public static void Init()
        {
            MapConfig.Initialize(initializer =>
            {
                initializer.Map <Business.VerySimpleClass, DTO.VerySimpleClass>();
                initializer.Map <Business.SimpleClass, DTO.SimpleClass>()
                .WithMember(x => x.Key, api => api.LinkTo(x => x.Id))
                .WithMember(x => x.Date_Plus_2, api => api.LinkTo(x => x.Date.AddDays(2)))
                .WithMember(nameof(DTO.SimpleClass.StringToBeIgnored), api => api.Ignore())
                .WithMember(x => x.VerySimpleClass2String, api => api.LinkTo(x => x.VerySimpleClass2.MyString));
                initializer.Map <Business.SimpleClass, DTO.SimpleClass2>()
                .WithMember(x => x.Key, api => api.LinkTo(nameof(Business.SimpleClass.Id)));
                initializer.Map <int[], DTO.ClassWithComplexFuncMappings>()
                .WithMember(x => x.VerySimpleClasses, api => api.LinkTo(arr => arr.Select(item => new Business.VerySimpleClass()
                {
                    MyInt = item, MyString = item.ToString()
                }).ToArray()))
                .WithMember(x => x.VerySimpleClass, api => api.LinkTo(arr => new DTO.VerySimpleClass()
                {
                    MyInt = 77, MyString = "test"
                }))
                .WithMember(x => x.ADate, api => api.LinkTo(arr => ((DTO.SimpleClass)null).Date))
                .WithMember(x => x.AStruct, api => api.LinkTo(arr => ((DTO.ClassWithStructAndEnum)null).AStruct))
                .WithMember(x => x.AString, api => api.LinkTo(arr => (DTO.ClassWithComplexFuncMappings.AFunction().FirstOrDefault(x => x.MyInt == 5).MyString)))
                .WithMember(x => x.AnotherString, api => api.LinkTo(arr => ((DTO.ClassWithStructAndEnum)null).AStruct.Field1))
                .WithMember(x => x.AnInt, api => api.LinkTo(arr => (DTO.ClassWithComplexFuncMappings.AFunction().FirstOrDefault(x => x.MyInt == 5).MyInt)))
                .WithMember(x => x.AnInt2, api => api.LinkTo(arr => ((DTO.SimpleClass)null).GetHashCode()));
                initializer.Map <Business.SimpleSet, DTO.SimpleSet>();
                initializer.Map <Business.MultipleSets, DTO.MultipleSets>();
                initializer.Map <Business.DictionarySet, DTO.DictionarySet>();
                initializer.Map <Business.DictionarySetCircular, DTO.DictionarySetCircular>()
                .EnableItemsCache();
                initializer.Map <Business.ClassWithNullableTypes, DTO.ClassWithNullableTypes>();
                initializer.Map <Business.SimpleGeneric <TGen1>, DTO.SimpleGeneric <TGen1> >();
                initializer.Map <Business.SimpleGeneric2 <TGen1>, DTO.SimpleGeneric2 <TGen1> >()
                .WithMember(x => x.AnotherGenericProperty, api => api.LinkTo(x => x.GenericProperty))
                .WithMember(x => x.ToBeIngored, api => api.Ignore());
                initializer.Map <Business.MappedObjectGeneric <TGen1>, DTO.MappedObjectGeneric <TGen1> >();
                initializer.Map <Business.MultipleGenerics <TGen2, TGen1>, DTO.MultipleGenerics <TGen1, TGen2> >();


                initializer.Map <Business.PolymorphicSubSubClass, DTO.PolymorphicSubSubClass>();
                initializer.Map <Business.PolymorphicSubClass, DTO.PolymorphicSubClass>()
                .WithMember(x => x.AString, api => api.LinkTo(x => x.AString.ToUpper()));
                initializer.Map <Business.PolymorphicBaseClass, DTO.PolymorphicBaseClass>();
                initializer.Map <Business.IInterfaceForFuncMappingPolymorph, DTO.FuncMappingPolymorphSub>()
                .WithMember(x => x.FromInterface, api => api.LinkTo(x => x.IntFromInterface));
                initializer.Map <Business.FuncMappingPolymorph, DTO.FuncMappingPolymorph>()
                .WithMember(x => x.AString, api => api.LinkTo(x => x.MyString.ToUpper()));
                initializer.Map <Business.FuncMappingPolymorphSub, DTO.FuncMappingPolymorphSub>()
                .WithMember(x => x.ADate, api => api.LinkTo(x => x.ADate.AddDays(1)));
                initializer.Map <Business.SetOfPolymorphic, DTO.SetOfPolymorphic>();
                initializer.Map <Business.SetOfGenericPolymorph, DTO.SetOfGenericPolymorph>();
                initializer.Map <Business.AutoReferencedClass, DTO.AutoReferencedClass>()
                .EnableItemsCache();
                initializer.Map <Business.ContainerOfManuallyMappedClass, DTO.ContainerOfManuallyMappedClass>()
                .WithMember(x => x.Tuple, api => api.LinkTo(x => x.Content));
                initializer.ManualMap((Business.ContainerOfManuallyMappedClass.ManuallyMappedClass x) => Tuple.Create(x.Id, x.Title));
                initializer.Map <Business.ClassWithStructAndEnum.MyStruct, DTO.ClassWithStructAndEnum.MyStruct>()
                .WithMember(x => x.AnotherField2, api => api.LinkTo(x => x.Field2));
                initializer.Map <Business.ClassWithStructAndEnum.MyEnum1, DTO.ClassWithStructAndEnum.MyEnum1>();
                initializer.ManualMap((Business.ClassWithStructAndEnum.MyEnum2 val) => DTO.ClassWithStructAndEnum.Convert(val));
                initializer.Map <Business.ClassWithStructAndEnum, DTO.ClassWithStructAndEnum>();
                initializer.Map <Business.ClassWithBeforeAndAfterMap, DTO.ClassWithBeforeAndAfterMap>()
                .BeforeMap((source, target) => { source.Name = "beforeMap"; })
                .AfterMap((source, target) => { source.Name = "afterMap"; });
                initializer.Map <Business.ClassWithBeforeAndAfterMapSub, DTO.ClassWithBeforeAndAfterMapSub>()
                .WithMember(x => x.AnInt, api => api.Ignore())
                .BeforeMap((source, target) => { source.StringFromSub = "beforeMap"; })
                .AfterMap((source, target) => { source.StringFromSub = "afterMap"; });
                initializer.Map <Business.ClassForInclusions, DTO.ClassForInclusions>()
                .WithMember(x => x.AString, api => api.LinkTo(x => x.AString, RetrievalMode.RetrievedWhenSpecified))
                .WithMember(x => x.ADate, api => api.LinkTo(x => DateTime.Today, RetrievalMode.RetrievedWhenSpecified));
                initializer.Map <Business.ClassWithSetOfUnmappedClass, DTO.ClassWithSetOfUnmappedClass>();
                initializer.Map <Business.ClassWithSimpleTypes, DTO.ClassWithSimpleTypes>();

                initializer.Map <Business.ClassWithPropUsingMapper.Section, DTO.ClassWithPropUsingMapper.Section>()
                .EnableItemsCache();
                initializer.Map <Business.ClassWithPropUsingMapper, DTO.ClassWithPropUsingMapper>()
                .EnableItemsCache();
                initializer.Map <Business.ClassWithLazy, DTO.ClassWithLazy>()
                .EnableItemsCache()
                .WithMember(x => x.SimpleClass, api => api.LinkTo(x => x.LazySimpleClass.Value));
                initializer.ManualMap <object, DTO.ClassWithAsyncCallToMapper>(x => new DTO.ClassWithAsyncCallToMapper())
                .EnableItemsCache();
                initializer.Map <Business.ClassWithException, DTO.ClassWithException>();
            });
        }