Esempio n. 1
0
 public DbModelBuilder(EntityModel entityModel, DbModelConfig config, IBufferedLog log)
 {
     _entityModel   = entityModel;
     _dbModelConfig = config;
     _namingPolicy  = _dbModelConfig.NamingPolicy;
     _log           = log;
     _driver        = _dbModelConfig.Driver;
 }
Esempio n. 2
0
 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);
     }
 }
Esempio n. 3
0
        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
        }
Esempio n. 4
0
        /// <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());
        }
Esempio n. 5
0
        public static bool HasErrors(this IBufferedLog log)
        {
            var hasErrors = log.GetAll().Any(e => e.IsError);

            return(hasErrors);
        }
Esempio n. 6
0
        public static string GetAllAsText(this IBufferedLog log)
        {
            var text = string.Join(Environment.NewLine, log.GetAll());

            return(text);
        }