protected virtual void InitApp() { Status = EntityAppStatus.Initializing; SetupLogFileWriters(); ActivationLog.WriteMessage("Initializing EntityApp {0}.====================================", this.AppName); this.AppEvents.OnInitializing(EntityAppInitStep.Initializing); //Check dependencies foreach (var mod in this.Modules) { var depList = mod.GetDependencies(); foreach (var dep in depList) { var ok = Modules.Any(m => dep.IsTypeOrSubType(m)); if (!ok) { ActivationLog.LogError($"Module {mod.Name} requires dependent module {dep} which is not included in the app."); } } } CheckActivationErrors(); //Build model var builder = new EntityModelBuilder(this); builder.BuildModel(); CheckActivationErrors(); //Notify modules that entity app is constructed foreach (var module in this.Modules) { module.Init(); } //init services; note that service might be registered more than once, under different interface var servList = this.GetAllServices().Distinct().ToList(); for (int i = 0; i < servList.Count; i++) { var service = servList[i]; var iServiceInit = service as IEntityServiceBase; if (iServiceInit != null) { iServiceInit.Init(this); } } //complete initialization this.AppEvents.OnInitializing(EntityAppInitStep.Initialized); foreach (var module in this.Modules) { module.AppInitComplete(); } builder.CheckErrors(); Status = EntityAppStatus.Initialized; ActivationLog.WriteMessage("App {0} initialized.", this.AppName); }
public static string LastFatalError; // error log sets this if it fails to persist error protected virtual void InitApp() { Util.Check(this.EntityClassProvider != null, "EntityApp.{0} may not be null. Use {1} method from Vita.Entities.Emit assembly to create provider instance.", nameof(EntityClassProvider), "Vita.Entities.Emit.EntityClassEmitter.CreateProvider()"); RegisterService <IEntityClassProvider>(EntityClassProvider); Status = EntityAppStatus.Initializing; CreateLogFileWriters(); ActivationLog.Info("Initializing EntityApp {0}.====================================", this.AppName); this.AppEvents.OnInitializing(EntityAppInitStep.Initializing); //Check dependencies foreach (var mod in this.Modules) { var depList = mod.GetDependencies(); foreach (var dep in depList) { var ok = Modules.Any(m => dep.IsTypeOrSubType(m)); if (!ok) { ActivationLog.Error("Module {0} requires dependent module {1} which is not included in the app.", mod.GetType(), dep); } } } ActivationLog.CheckErrors(); // Init linked apps foreach (var linkedApp in LinkedApps) { if (linkedApp.Status == EntityAppStatus.Created) { linkedApp.Init(); } } //Build model var builder = new EntityModelBuilder(this); builder.BuildModel(); ActivationLog.CheckErrors(); //Notify modules that entity app is constructed foreach (var module in this.Modules) { module.Init(); } //init services var servList = this.GetAllServices(); for (int i = 0; i < servList.Count; i++) { var service = servList[i]; var iServiceInit = service as IEntityServiceBase; if (iServiceInit != null) { iServiceInit.Init(this); } } //complete initialization this.AppEvents.OnInitializing(EntityAppInitStep.Initialized); foreach (var module in this.Modules) { module.AppInitComplete(); } builder.CheckErrors(); Status = EntityAppStatus.Initialized; ActivationLog.Info("App {0} initialized.", this.AppName); }