예제 #1
0
 public static IFacetsGraph DefaultFacetsGraph(IFacetContext testContext)
 {
     using (var registry = new RepositoryRegistry(testContext)) {
         var g = DefaultFacetsGraph(registry);
         return(g);
     }
 }
예제 #2
0
        public override TransactionResult ExecutionBody()
        {
            IRepository <Customer> repository = RepositoryRegistry.GetRepository <Customer>();

            GetCustomerByCivilStatusQuery.Criteria criteriaByStatus = Input;
            IUnitOfWork uow = CreateUnitOfWork();

            ((List <Customer>)repository.Matching(criteriaByStatus)).ForEach(customer =>
            {
                customer.Name = "Test is now single";

                uow.RegisterDirty(customer);
            });

            TransactionResult result = new TransactionResult
            {
                SuccessfullyAlteredCustomers = new List <Customer>()
            };

            uow.Commit(
                (domainObject, action, info) =>
            {
                result.SuccessfullyAlteredCustomers.Add((Customer)domainObject);
            },
                null);

            return(result);
        }
        public static void Configure()
        {
            Container = new Container();

            Container.Register(() => HttpContext.Current.GetOwinContext());
            Container.RegisterPerWebRequest(() => Container.GetInstance <IOwinContext>().Authentication);
            Container.RegisterPerWebRequest(() => AppUserManager.Create(new IdentityFactoryOptions <AppUserManager>(), Container.GetInstance <IOwinContext>()));
            Container.RegisterPerWebRequest(AppDbContext.Create);
            Container.RegisterPerWebRequest <DbContext>(() => Container.GetInstance <AppDbContext>());

            RepositoryRegistry.InsertIn(Container);
        }
예제 #4
0
        private IContainer ConfigureDIContainerWithRepositoryRegistry()
        {
            var mockSession               = new Mock <ISession>();
            var mockSessionProvider       = new Mock <ISessionProvider>();
            var mockKeywordsSearchService = new Mock <IKeywordsSearchService>();

            RepositoryRegistry target = new RepositoryRegistry();

            IContainer container = new Container(x =>
            {
                x.For <ISession>().Use(mockSession.Object);
                x.For <ISessionProvider>().Use(mockSessionProvider.Object);
                x.For <IKeywordsSearchService>().Use(mockKeywordsSearchService.Object);
                x.AddRegistry(target);
            });

            return(container);
        }
예제 #5
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            //init config
            SiteConfig.Instance.Init(Configuration);
            services.AddEntityFrameworkNpgsql();


            #region PGSQL Setting
            //services.AddEntityFrameworkNpgsql();
            var connStr = Configuration["ConnectionString"];
            services.AddDbContext <ApiDbContext>(options => options.UseNpgsql(connStr));
            services.Configure <AppConfig>(Configuration);
            RepositoryRegistry.Registry(services);
            Console.WriteLine("数据库链接参数:{0}", connStr);
            #endregion


            services.AddMvc()
            .AddJsonOptions(opts =>
            {
                // Force Camel Case to JSON
                opts.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
                //ignore Entity framework Navigation property back reference problem. Blog >> Posts. Post >> Blog. Blog.post.blog will been ignored.
                opts.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
            });

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Swashbuckle.AspNetCore.Swagger.Info {
                    Title = "Damaozhu API", Version = "v1"
                });
                string dirPath = System.IO.Path.GetDirectoryName(typeof(Startup).Assembly.CodeBase);
                string xmlPath = Path.Combine(AppContext.BaseDirectory, "ApiServer.xml");
                if (System.IO.File.Exists(xmlPath))
                {
                    c.IncludeXmlComments(xmlPath);
                }
                else
                {
                    Console.WriteLine("xml file for swagger api doc is missing. publish version need copy it manually, check path " + xmlPath);
                }
            });
        }
예제 #6
0
        static void Main()
        {
            DialogResult result;

            var registry = new RepositoryRegistry();

            registry.Configure();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            using (var loginForm = new LoginUI())
                result = loginForm.ShowDialog();

            if (result == DialogResult.OK)
            {
                Application.Run(new MainUI());
            }

            //Application.Run(new MainUI());
        }
예제 #7
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="dbContext">Database context.</param>
 /// <param name="repositoryRegistry">Repository registry.</param>
 public Transaction(DbContext dbContext, RepositoryRegistry repositoryRegistry) : base(repositoryRegistry)
 {
     this.dbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext));
 }
예제 #8
0
 public static void IncludeLogicRegistry(IServiceCollection services)
 {
     RepositoryRegistry.IncludeRepositoryRegistry(services);
     services.AddScoped <IHotelProcessor, HotelProcessor>();
 }