public SynchronizationServiceProc() { this.ServiceName = "TinyLibraryCQRS Synchronization Service"; this.EventLog.Log = "Application"; this.CanShutdown = true; this.CanStop = true; AppConfigSource configSource = new AppConfigSource(); IApp application = AppRuntime.Create(configSource); application.Initialize += (s, e) => { UnityContainer c = e.ObjectContainer.GetWrappedContainer <UnityContainer>(); IMessageDispatcher eventDispatcher = MessageDispatcher.CreateAndRegister(configSource, typeof(MessageDispatcher)); c.RegisterInstance <IMessageDispatcher>(eventDispatcher); }; application.Start(); messageDispatcher = AppRuntime.Instance.CurrentApplication.ObjectContainer.GetService <IMessageDispatcher>(); timer.Interval = this.Interval; timer.Elapsed += new ElapsedEventHandler(timer_Elapsed); worker.WorkerSupportsCancellation = true; worker.WorkerReportsProgress = false; worker.DoWork += new DoWorkEventHandler(worker_DoWork); }
public TestInit(string ddd) { if (ddd == "") { } IConfigSource configSource = new DefaultConfig(); configSource.Config.Application.AppProvider = "CommonFrameWork.Application.DefaultApp,CommonFrameWork"; configSource.Config.Application.ObjectContainer = "CommonFrameWork.Extensions.Autofac.AutofacObjectContainer,CommonFrameWork.Extensions.Autofac"; //configSource.Config.Application.SerializationProvider = "CommonFrameWork.Extensions.NewTonSoft.NewTonSoftSerializer,CommonFrameWork.Extensions.NewTonSoft"; configSource.Config.Application.Assemblies = Utils.GetAllAssemblies("Project.Domain.ModuleManager"); configSource.Config.Application.LogProvider = "CommonFrameWork.Extensions.Log4Net.Log4NetLoggerFactory,CommonFrameWork.Extensions.Log4Net"; var application = AppRuntime.Create(configSource).UseMassTransit(); //application.Starting += Add; //application.Started += Add2; //application.Stopping += Add3; application.Start(); }
/// <summary> /// Creates the <see cref="IApp"/> instance. /// </summary> /// <param name="configurator">The instance of <see cref="IObjectContainerConfigurator"/> to be extended.</param> /// <returns>The <see cref="IApp"/> instance.</returns> public static IApp Create(this IObjectContainerConfigurator configurator) { var configSource = configurator.Configure(); var appInstance = AppRuntime.Create(configSource); return(appInstance); }
public void InitializeInterceptorsTests_MockSingleInterceptorTest() { Helper.ClearApp(AppRuntime.Instance); bool a = false; bool b = false; MockInterceptorA.InterceptOccur += (s, e) => { a = true; }; MockInterceptorB.InterceptOccur += (s, e) => { b = true; }; RegularConfigSource configSource = (RegularConfigSource)Helper.ConfigSource_GeneralInterception; configSource.AddInterceptor("a", typeof(MockInterceptorA)); configSource.AddInterceptor("b", typeof(MockInterceptorB)); configSource.AddInterceptorRef(typeof(MessageDispatcher), typeof(MessageDispatcher).GetMethod("Clear", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance), "a"); IApp app = AppRuntime.Create(configSource); app.Initialize += (s, e) => { UnityContainer c = e.ObjectContainer.GetWrappedContainer <UnityContainer>(); c.RegisterType <IMessageDispatcher, MessageDispatcher>(); }; app.Start(); IMessageDispatcher dispatcher = app.ObjectContainer.GetService <IMessageDispatcher>(); dispatcher.Clear(); Assert.IsTrue(a); Assert.IsFalse(b); }
public void SnapshotDomainRepositoryTests_SaveAggregateRootButFailPublishToMSMQTest() { IConfigSource configSource = Helper.ConfigSource_Repositories_SnapshotDomainRepository_SaveButFailPubToMSMQ; IApp application = AppRuntime.Create(configSource); application.Initialize += new System.EventHandler <AppInitEventArgs>(Helper.AppInit_Repositories_SnapshotDomainRepository_SaveButFailPubToMSMQ); application.Start(); SourcedCustomer customer = new SourcedCustomer(); Guid id = customer.ID; customer.ChangeName("Qingyang", "Chen"); IDomainRepository domainRepository = null; try { using (domainRepository = application.ObjectContainer.GetService <IDomainRepository>()) { domainRepository.Save <SourcedCustomer>(customer); domainRepository.Commit(); } } catch { } int cnt = Helper.ReadRecordCountFromSQLExpressCQRSTestDB(Helper.CQRSTestDB_Table_Snapshots); Assert.AreEqual <int>(0, cnt); }
public void SnapshotDomainRepositoryTests_SaveAggregateRootAndPublishToDirectBusTest() { IConfigSource configSource = Helper.ConfigSource_Repositories_SnapshotDomainRepository_DirectBus; IApp application = AppRuntime.Create(configSource); application.Initialize += new System.EventHandler <AppInitEventArgs>(Helper.AppInit_Repositories_SnapshotDomainRepository_DirectBus); application.Start(); SourcedCustomer customer = new SourcedCustomer(); Guid id = customer.ID; customer.ChangeName("Qingyang", "Chen"); using (IDomainRepository domainRepository = application.ObjectContainer.GetService <IDomainRepository>()) { domainRepository.Save <SourcedCustomer>(customer); domainRepository.Commit(); } int cnt = Helper.ReadRecordCountFromSQLExpressCQRSTestDB(Helper.CQRSTestDB_Table_Snapshots); Assert.AreEqual <int>(1, cnt); using (IDomainRepository domainRepository = application.ObjectContainer.GetService <IDomainRepository>()) { SourcedCustomer sourcedCustomer = null; sourcedCustomer = domainRepository.Get <SourcedCustomer>(id); Assert.AreEqual <string>("Qingyang", sourcedCustomer.FirstName); Assert.AreEqual <string>("Chen", sourcedCustomer.LastName); } }
public static void MyClassInitialize(TestContext testContext) { IConfigSource configSource = Helper.ConfigSource_Generators; application = AppRuntime.Create(configSource); application.Start(); }
public void EventSourcedDomainRepositoryTests_SaveAggregateRootTest() { IConfigSource configSource = Helper.ConfigSource_Repositories_EventSourcedDomainRepositoryWithMSMQBusButWithoutSnapshotProvider; IApp app = AppRuntime.Create(configSource); app.Initialize += Helper.AppInit_Repositories_EventSourcedDomainRepositoryWithMSMQBusButWithoutSnapshotProvider; app.Start(); SourcedCustomer customer = new SourcedCustomer(); customer.ChangeName("sunny", "chen"); Assert.AreEqual <long>(2, customer.Version); using (IDomainRepository domainRepository = app.ObjectContainer.GetService <IDomainRepository>()) { domainRepository.Save <SourcedCustomer>(customer); domainRepository.Commit(); } Assert.AreEqual <long>(2, customer.Version); int recordCnt = Helper.ReadRecordCountFromSQLExpressCQRSTestDB(Helper.CQRSTestDB_Table_DomainEvents); Assert.AreEqual <int>(2, recordCnt); int msgCnt = Helper.GetMessageQueueCount(Helper.EventBus_MessageQueue); Assert.AreEqual <int>(2, msgCnt); }
public void EventSourcedDomainRepositoryTests_SaveAndLoadAggregateRootTest() { IConfigSource configSource = Helper.ConfigSource_Repositories_EventSourcedDomainRepositoryWithMSMQBusButWithoutSnapshotProvider; IApp app = AppRuntime.Create(configSource); app.Initialize += Helper.AppInit_Repositories_EventSourcedDomainRepositoryWithMSMQBusButWithoutSnapshotProvider; app.Start(); SourcedCustomer customer = new SourcedCustomer(); customer.ChangeName("sunny", "chen"); customer.ChangeEmail("*****@*****.**"); Assert.AreEqual <long>(3, customer.Version); using (IDomainRepository domainRepository = app.ObjectContainer.GetService <IDomainRepository>()) { domainRepository.Save <SourcedCustomer>(customer); domainRepository.Commit(); } Assert.AreEqual <long>(3, customer.Version); using (IDomainRepository domainRepository2 = app.ObjectContainer.GetService <IDomainRepository>()) { SourcedCustomer cust = domainRepository2.Get <SourcedCustomer>(customer.ID); Assert.AreEqual <long>(3, cust.Version); Assert.AreEqual <string>("sunny", cust.FirstName); Assert.AreEqual <string>("chen", cust.LastName); Assert.AreEqual <string>("*****@*****.**", cust.Email); } }
public static void MyClassInitialize(TestContext testContext) { IConfigSource configSource = Helper.ConfigSource_EventStore_SqlExpress; application = AppRuntime.Create(configSource); application.Initialize += new System.EventHandler <AppInitEventArgs>(Helper.AppInit_EventStore_SqlExpress); application.Start(); }
protected void Application_Start(object sender, EventArgs e) { IConfigSource configSource = new AppConfigSource(); App application = AppRuntime.Create(configSource); application.AppInitEvent += new App.AppInitHandle(application_AppInitEvent); application.Start(); }
public static void StartApp() { IConfigSource configSource = new AppConfigSource(); App application = AppRuntime.Create(configSource); application.AppInitEvent += new App.AppInitHandle(application_AppInitEvent); application.Start(); }
public static void MyClassInitialize(TestContext testContext) { IConfigSource configSource = Helper.ConfigSource_Repositories_RegularEventPublisherDomainRepository_MSMQ; application = AppRuntime.Create(configSource); application.Initialize += new EventHandler <AppInitEventArgs>(Helper.AppInit_Repositories_RegularEventPublisherDomainRepository_MSMQ); application.Start(); }
public static void MyClassInitialize(TestContext testContext) { IConfigSource configSource = Helper.ConfigSource_ExceptionHandling; application = AppRuntime.Create(configSource); application.Initialize += Helper.AppInit_ExceptionHandling_InvalidStorage; application.Start(); }
public static void MyClassInitialize(TestContext testContext) { IConfigSource configSource = Helper.ConfigSource_AggregateRootVersion; application = AppRuntime.Create(configSource); application.Initialize += new System.EventHandler <AppInitEventArgs>(Helper.AppInit_Repositories_EventSourcedDomainRepositoryWithDirectEventBusButWithoutSnapshotProvider); application.Start(); }
public void GetContainerFromFile() { AppRuntime.Create(ConfigHelper.GetAppConfigSource()).Start(); var context = ServiceLocator.Instance.GetService <IRepositoryContext>(); Assert.IsNotNull(context); }
public static void MyClassInitialize(TestContext testContext) { IConfigSource configSource = Helper.ConfigSource_MessageDispatcher; application = AppRuntime.Create(configSource); application.Initialize += Helper.AppInit_MessageDispatcher; application.Start(); }
protected void Application_Start(object sender, EventArgs e) { IConfigSource appConfigSource = new AppConfigSource(); IApp application = AppRuntime.Create(appConfigSource); application.Initialize += new EventHandler <AppInitEventArgs>(application_Initialize); application.Start(); }
public static void MyClassInitialize(TestContext testContext) { IConfigSource configSource = Helper.ConfigSource_Repositories_NHibernateRepository; application = AppRuntime.Create(configSource); application.Initialize += new EventHandler <AppInitEventArgs>(Helper.AppInit_Repositories_NHibernateRepository); application.Start(); }
public static void StartBDDD(TestContext context) { ManualConfigSource configSource = ConfigHelper.GetManualConfigSource(); application = AppRuntime.Create(configSource); application.AppInitEvent += application_AppInitEvent; application.Start(); }
public static void MyClassInitialize(TestContext testContext) { IConfigSource configSource = Helper.ConfigSource_Buses_EventSourcedDomainRepositoryWithDirectCommandBusButWithoutSnapshotProvider; application = AppRuntime.Create(configSource); application.Initialize += new EventHandler <AppInitEventArgs>(Helper.AppInit_Buses_EventSourcedDomainRepositoryWithDirectCommandBusButWithoutSnapshotProvider); application.Start(); }
public void EventSourcedDomainRepositoryTests_UpdateSnapshotTest() { IConfigSource configSource = Helper.ConfigSource_Repositories_EventSourcedDomainRepositoryWithMSMQBusAndSnapshotProvider; IApp app = AppRuntime.Create(configSource); app.Initialize += Helper.AppInit_Repositories_EventSourcedDomainRepositoryWithMSMQBusAndSnapshotProvider; app.Start(); SourcedCustomer customer = new SourcedCustomer(); for (int i = 0; i < 4; i++) { customer.ChangeEmail("acqy" + i.ToString() + "@163.com"); } Assert.AreEqual <long>(5, customer.Version); // first to produce 5 events using (IDomainRepository domainRepository = app.ObjectContainer.GetService <IDomainRepository>()) { domainRepository.Save <SourcedCustomer>(customer); domainRepository.Commit(); } // produce another 5 events to trigger snapshot creation for (int i = 0; i < 5; i++) { customer.ChangeName("qingyang" + i.ToString(), "chen"); } using (IDomainRepository domainRepository = app.ObjectContainer.GetService <IDomainRepository>()) { domainRepository.Save <SourcedCustomer>(customer); domainRepository.Commit(); } int snapshotCnt = Helper.ReadRecordCountFromSQLExpressCQRSTestDB(Helper.CQRSTestDB_Table_Snapshots); Assert.AreEqual <int>(1, snapshotCnt); DataTable dt = Helper.ReadRecordsFromSQLExpressCQRSTestDB(Helper.CQRSTestDB_Table_Snapshots); DataRow dr = dt.Rows[0]; Assert.AreEqual <string>(typeof(SourcedCustomer).AssemblyQualifiedName, dr["AggregateRootType"].ToString()); Assert.AreEqual <Guid>(customer.ID, (Guid)(dr["AggregateRootID"])); Assert.AreEqual <long>(10, Convert.ToInt64(dr["Version"])); // produce another 6 events, the snapshot should be updated... for (int i = 0; i < 6; i++) { customer.ChangeName("qingyang", "chen" + i.ToString()); } using (IDomainRepository domainRepository = app.ObjectContainer.GetService <IDomainRepository>()) { domainRepository.Save <SourcedCustomer>(customer); domainRepository.Commit(); } snapshotCnt = Helper.ReadRecordCountFromSQLExpressCQRSTestDB(Helper.CQRSTestDB_Table_Snapshots); Assert.AreEqual <int>(1, snapshotCnt); dt = Helper.ReadRecordsFromSQLExpressCQRSTestDB(Helper.CQRSTestDB_Table_Snapshots); dr = dt.Rows[0]; Assert.AreEqual <string>(typeof(SourcedCustomer).AssemblyQualifiedName, dr["AggregateRootType"].ToString()); Assert.AreEqual <Guid>(customer.ID, (Guid)(dr["AggregateRootID"])); Assert.AreEqual <long>(16, Convert.ToInt64(dr["Version"])); }
public static void MyClassInitialize(TestContext testContext) { Database.SetInitializer <EFTestContext>(new DropCreateDatabaseIfModelChanges <EFTestContext>()); IConfigSource configSource = Helper.ConfigSource_EFRepository; application = AppRuntime.Create(configSource); application.Initialize += new EventHandler <AppInitEventArgs>(Helper.AppInit_EFRepository); application.Start(); }
protected static void InitAppRuntime() { ManualConfigSource configSource = new ManualConfigSource { ObjectContainer = typeof(UnityObjectContainer) }; application = AppRuntime.Create(configSource); application.AppInitEvent += application_AppInitEvent; application.Start(); }
public void AddInterceptor() { ManualConfigSource configSource = ConfigHelper.GetManualConfigSource(); configSource.AddInterceptor("ExceptionHandler", typeof(ExceptionHandlerInterceptor)); App app = AppRuntime.Create(configSource); app.Start(); Assert.AreEqual(1, app.Interceptors.Count()); }
public void InitializeInterceptorsTests_InitAppTest() { RegularConfigSource configSource = (RegularConfigSource)Helper.ConfigSource_GeneralInterception; configSource.AddInterceptor("exception", typeof(ExceptionHandlingInterceptor)); configSource.AddInterceptor("logging", typeof(LoggingInterceptor)); IApp app = AppRuntime.Create(configSource); Assert.IsNotNull(app.Interceptors); Assert.AreEqual <int>(2, app.Interceptors.Count()); Assert.IsInstanceOfType(app.Interceptors.First(), typeof(ExceptionHandlingInterceptor)); Assert.IsInstanceOfType(app.Interceptors.Last(), typeof(LoggingInterceptor)); }
static void Main(string[] args) { // new SessionFactoryProvider().GetSessionFactory(); IConfigSource configSource = new DefaultConfig(); configSource.Config.Application.AppProvider = "CommonFrameWork.Application.DefaultApp,CommonFrameWork"; configSource.Config.Application.ObjectContainer = "CommonFrameWork.Extensions.Autofac.AutofacObjectContainer,CommonFrameWork.Extensions.Autofac"; //configSource.Config.Application.SerializationProvider = "CommonFrameWork.Extensions.NewTonSoft.NewTonSoftSerializer,CommonFrameWork.Extensions.NewTonSoft"; var list = new List <Assembly>(); list.AddRange(Utils.GetAllAssemblies("Project.Domain.Core.Nhibernate")); list.AddRange(Utils.GetAllAssemblies("Project.Domain.Core")); list.AddRange(Utils.GetAllAssemblies("CommonFrameWork.Extensions.NHibernate")); configSource.Config.Application.Assemblies = list; configSource.Config.Application.LogProvider = "CommonFrameWork.Extensions.Log4Net.Log4NetLoggerFactory,CommonFrameWork.Extensions.Log4Net"; var application = AppRuntime.Create(configSource).ConfigMessageDispatcher(); //application.Starting += Add; //application.Started += Add2; //application.Stopping += Add3; application.Start(); //var res3 = ObjectContainer.Resolve<IOrderMainRepository2>(); ////var t3 = res3.Context; ////var entity3 = res3.GetByKey("1"); //res3.Add(new OrderMain2() {ID = "3",OrderNo = "2222"}); //res3.Context.Commit(); //var res = ObjectContainer.Resolve<IOrderMainRepository>(); //var t = res3.Context; //var entity = res.GetByKey("1"); var res3 = ObjectContainer.Resolve <IOrderDomainService>(); res3.Add(); Console.Read(); }
public static void Main(string[] args) { int i = 29; WriteLine($"The answer is {new Thing().Get(i, 23)}"); IApp app = AppRuntime.Create(); app.Start(); IServiceCollection services = new ServiceCollection(); IServiceProvider serviceProvider = ConfigureServices(services); //构建容器 ILoggerFactory loggerFactory = serviceProvider.GetService <ILoggerFactory>(); loggerFactory.AddConsole() .AddDebug(); app.UseCoreLogging(loggerFactory); var transientOpertion1 = serviceProvider.GetService <IOperationTransient>(); var scopepOperation1 = serviceProvider.GetService <IOperationScoped>(); var sigletonOperation1 = serviceProvider.GetService <IOperationSingleton>(); var transientOpertion2 = serviceProvider.GetService <IOperationTransient>(); var scopepOperation2 = serviceProvider.GetService <IOperationScoped>(); var sigletonOperation2 = serviceProvider.GetService <IOperationSingleton>(); IServiceScopeFactory[] scopeFactories = IocManager.Instance.ResolveAll <IServiceScopeFactory>(); IServiceScopeFactory scopeFactory = serviceProvider.GetService <IServiceScopeFactory>(); using (var scope = scopeFactory.CreateScope()) { IServiceProvider scopeProvider = scope.ServiceProvider; var transientOpertion3 = scopeProvider.GetService <IOperationTransient>(); var scopepOperation3 = scopeProvider.GetService <IOperationScoped>(); var sigletonOperation3 = scopeProvider.GetService <IOperationSingleton>(); var transientOpertion4 = scopeProvider.GetService <IOperationTransient>(); var scopepOperation4 = scopeProvider.GetService <IOperationScoped>(); var sigletonOperation4 = scopeProvider.GetService <IOperationSingleton>(); } IServiceProvider newServiceProvider = serviceProvider.GetService <IServiceProvider>(); ILog log = LogManager.GetLogger(typeof(Program)); log.Info("This is a LogManager Log"); }
public TestInit() { IConfigSource configSource = new DefaultConfig(); configSource.Config.Application.AppProvider = "CommonFrameWork.Application.DefaultApp,CommonFrameWork"; configSource.Config.Application.ObjectContainer = "CommonFrameWork.Extensions.Autofac.AutofacObjectContainer,CommonFrameWork.Extensions.Autofac"; configSource.Config.Application.Assemblies = Utils.GetAllAssemblies("Project.Domain.ModuleManager"); var application = AppRuntime.Create(configSource).UseMassTransit(); //application.Starting += Add; //application.Started += Add2; //application.Stopping += Add3; application.Start(); }
public static void Initial(TestContext context) { ManualConfigSource configSource = ConfigHelper.GetManualConfigSource(); application = AppRuntime.Create(configSource); application.Start(); var c = application.ObjectContainer.GetRealObjectContainer <UnityContainer>(); c.RegisterType <ICache, MemcachedCache>(); c.RegisterType <AbsoluteTimeExpiration, MemcachedAbsoluteTimeExpiration>("SCache", new InjectionConstructor( TimeSpan.FromSeconds(5))); c.RegisterType <AbsoluteTimeExpiration, MemcachedAbsoluteTimeExpiration>("S1Cache", new InjectionConstructor( TimeSpan.FromSeconds(15))); }