public DbModelBuilder(EntityModel entityModel, DbModelConfig config, IBufferedLog log) { _entityModel = entityModel; _dbModelConfig = config; _namingPolicy = _dbModelConfig.NamingPolicy; _log = log; _driver = _dbModelConfig.Driver; }
public static void CheckErrors(this IBufferedLog log, string message) { if (log.ErrorCount > 0) { var bufLog = log as IBufferedLog; var errors = bufLog?.GetAllAsText() ?? "See details in error log."; System.Diagnostics.Trace.WriteLine(message + Environment.NewLine + errors); throw new StartupFailureException(message, errors); } }
public EntityModelBuilder(EntityApp app) { _app = app; Log = _app.ActivationLog; _customization = (EntityModelCustomizationService)_app.GetService <IEntityModelCustomizationService>(); Model = _app.Model = new EntityModel(_app); #if DEBUG RandomizeAttributesOrder = true; #endif }
/// <summary> Constructs a new EntityApp instance. </summary> public EntityApp(string appName = null, string version = "1.0.0.0", string activationLogPath = null) { _shutdownTokenSource = new CancellationTokenSource(); AppName = appName ?? this.GetType().Name; Version = new Version(version); Status = EntityAppStatus.Created; AppEvents = new EntityAppEvents(this); DataSourceEvents = new DataSourceEvents(this); AppDomain.CurrentDomain.DomainUnload += CurrentDomain_DomainUnload; // Time service and Timers service are global singletons, we register these here, as early as possible this.TimeService = Vita.Entities.Services.Implementations.TimeService.Instance; this.RegisterService <ITimeService>(this.TimeService); var timers = new TimerService(); this.RegisterService <ITimerService>(timers); this.RegisterService <ITimerServiceControl>(timers); // Logging services this.LogService = new LogService(); RegisterService <ILogService>(LogService); this.LogService.Subscribe(OnLogEntryWritten); var logBatchingService = new LogBatchingService(); RegisterService <ILogBatchingService>(logBatchingService); logBatchingService.Subscribe(OnLogBatchProduced); ActivationLog = new BufferedLog(LogContext.SystemLogContext, 10000, LogService); //Misc services var custService = new EntityModelCustomizationService(this); this.RegisterService <IEntityModelCustomizationService>(custService); this.DataAccess = new DataAccessService(this); RegisterService <IDataAccessService>(this.DataAccess); RegisterService <IBackgroundTaskService>(new DefaultBackgroundTaskService()); RegisterService <IHashingService>(new HashingService()); }
public static bool HasErrors(this IBufferedLog log) { var hasErrors = log.GetAll().Any(e => e.IsError); return(hasErrors); }
public static string GetAllAsText(this IBufferedLog log) { var text = string.Join(Environment.NewLine, log.GetAll()); return(text); }