/// <summary>
 /// Inititializes a new instance of the AppContext class.
 /// </summary>
 public AppContextBase(ErrorLoggerBase errorLogger, AuditLoggerBase auditLogger, Action <Action> backgroundAction, AppOptions options)
 {
     _errorLogger      = errorLogger ?? new TraceErrorLogger();
     _auditLogger      = auditLogger ?? new TraceAuditLogger();
     _backgroundAction = backgroundAction != null ? backgroundAction : (Action action) => ThreadPool.QueueUserWorkItem(a => action());
     _options          = options ?? new AppOptions();
 }
 /// <summary>
 /// Inititializes a new instance of the AppContext class.
 /// </summary>
 /// <param name="errorLogger">The default stateless error logger that can be used by app services and the parent application to log errors. If null, the default error logger will output to the console or trace listeners.</param>
 /// <param name="auditLogger">The default stateless audit logger that can be used by app services and the parent application to log an audit trail. If null, the default audit logger will output to the console or trace listeners.</param>
 /// <param name="backgroundAction">If null, the default mechanism, ThreadPool.QueueUserWorkItem, is used. NOTE: ASP.NET applications should use (Action action) => HostingEnvironment.QueueBackgroundWorkItem(a => action()). Otherwise, background threads spawned using AppContext.QueueBackgroundAction are subject to AppPool teardowns and may never complete.</param>
 public AppContextBase(ErrorLoggerBase errorLogger, AuditLoggerBase auditLogger, Action <Action> backgroundAction, params KeyValuePair <string, object>[] options)
     : this(errorLogger, auditLogger, backgroundAction, new AppOptions())
 {
     foreach (KeyValuePair <string, object> option in options)
     {
         _options.Add(option);
     }
 }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the AppContextFactory class.
        /// </summary>
        /// <param name="appServices">Injected AppServiceBase types.</param>
        /// <param name="errorLogger">The default stateless error logger that can be used by app services and the parent application to log errors. If null, the default error logger will output to the console or trace listeners.</param>
        /// <param name="auditLogger">The default stateless audit logger that can be used by app services and the parent application to log an audit trail. If null, the default audit logger will output to the console or trace listeners.</param>
        /// <param name="backgroundAction">If null, the default mechanism, ThreadPool.QueueUserWorkItem, is used. NOTE: ASP.NET applications should use (Action action) => HostingEnvironment.QueueBackgroundWorkItem(a => action()). Otherwise, background threads spawned using AppContext.QueueBackgroundAction are subject to AppPool teardowns and may never complete.</param>
        /// <param name="factoryBackgroundAction">If null, the default mechanism, ThreadPool.QueueUserWorkItem, is used. NOTE: ASP.NET applications should use (Action action) => HostingEnvironment.QueueBackgroundWorkItem(a => action()). Otherwise, background threads spawned using AppContext.QueueBackgroundAction are subject to AppPool teardowns and may never complete.</param>
        /// <param name="options">A collection of custom options that can be used by AppService UoW classes for application specific purposes.</param>
        public AppContextFactory(IEnumerable <KeyValuePair <Type, Type> > appServices, ErrorLoggerBase errorLogger, AuditLoggerBase auditLogger, Action <Action> backgroundAction, Action <Action <TAppContext> > factoryBackgroundAction, AppOptions options)
        {
            _appServices = appServices != null?appServices.ToList() : new List <KeyValuePair <Type, Type> >();

            _errorLogger             = errorLogger ?? new TraceErrorLogger();
            _auditLogger             = auditLogger ?? new TraceAuditLogger();
            _backgroundAction        = backgroundAction != null ? backgroundAction : (Action action) => ThreadPool.QueueUserWorkItem(a => action());
            _factoryBackgroundAction = factoryBackgroundAction != null ? factoryBackgroundAction : (Action <TAppContext> action) => ThreadPool.QueueUserWorkItem(a => { using (var appContext = this.NewAppContext()) { action(appContext); } });
            _options = options ?? new AppOptions();
        }
 /// <summary>
 /// Inititializes a new instance of the AppContext class.
 /// </summary>
 /// <param name="errorLogger">The default stateless error logger that can be used by app services and the parent application to log errors. If null, the default error logger will output to the console or trace listeners.</param>
 /// <param name="auditLogger">The default stateless audit logger that can be used by app services and the parent application to log an audit trail. If null, the default audit logger will output to the console or trace listeners.</param>
 /// <param name="backgroundAction">If null, the default mechanism, ThreadPool.QueueUserWorkItem, is used. NOTE: ASP.NET applications should use (Action action) => HostingEnvironment.QueueBackgroundWorkItem(a => action()). Otherwise, background threads spawned using AppContext.QueueBackgroundAction are subject to AppPool teardowns and may never complete.</param>
 public AppContextBase(ErrorLoggerBase errorLogger, AuditLoggerBase auditLogger, Action <Action> backgroundAction, IEnumerable <KeyValuePair <string, object> > options)
     : this(errorLogger, auditLogger, backgroundAction, new AppOptions(options))
 {
 }
Beispiel #5
0
 /// <summary>
 /// Initializes a new instance of the AppContextFactory class.
 /// </summary>
 /// <param name="appServices">Injected AppServiceBase types.</param>
 /// <param name="errorLogger">The default stateless error logger that can be used by app services and the parent application to log errors. If null, the default error logger will output to the console or trace listeners.</param>
 /// <param name="auditLogger">The default stateless audit logger that can be used by app services and the parent application to log an audit trail. If null, the default audit logger will output to the console or trace listeners.</param>
 /// <param name="backgroundAction">If null, the default mechanism, ThreadPool.QueueUserWorkItem, is used. NOTE: ASP.NET applications should use (Action action) => HostingEnvironment.QueueBackgroundWorkItem(a => action()). Otherwise, background threads spawned using AppContext.QueueBackgroundAction are subject to AppPool teardowns and may never complete.</param>
 /// <param name="factoryBackgroundAction">If null, the default mechanism, ThreadPool.QueueUserWorkItem, is used. NOTE: ASP.NET applications should use (Action action) => HostingEnvironment.QueueBackgroundWorkItem(a => action()). Otherwise, background threads spawned using AppContext.QueueBackgroundAction are subject to AppPool teardowns and may never complete.</param>
 /// <param name="options">A collection of custom options that can be used by AppService UoW classes for application specific purposes.</param>
 public AppContextFactory(IEnumerable <KeyValuePair <Type, Type> > appServices, ErrorLoggerBase errorLogger, AuditLoggerBase auditLogger, Action <Action> backgroundAction, Action <Action <TAppContext> > factoryBackgroundAction, IEnumerable <KeyValuePair <string, object> > options)
     : this(appServices, errorLogger, auditLogger, backgroundAction, factoryBackgroundAction, new AppOptions(options))
 {
 }
Beispiel #6
0
 /// <summary>
 /// Initializes a new instance of the AppContextFactory class.
 /// </summary>
 /// <param name="appServices">Injected AppServiceBase types.</param>
 /// <param name="errorLogger">The default stateless error logger that can be used by app services and the parent application to log errors. If null, the default error logger will output to the console or trace listeners.</param>
 /// <param name="auditLogger">The default stateless audit logger that can be used by app services and the parent application to log an audit trail. If null, the default audit logger will output to the console or trace listeners.</param>
 /// <param name="backgroundAction">If null, the default mechanism, ThreadPool.QueueUserWorkItem, is used. NOTE: ASP.NET applications should use (Action action) => HostingEnvironment.QueueBackgroundWorkItem(a => action()). Otherwise, background threads spawned using AppContext.QueueBackgroundAction are subject to AppPool teardowns and may never complete.</param>
 /// <param name="factoryBackgroundAction">If null, the default mechanism, ThreadPool.QueueUserWorkItem, is used. NOTE: ASP.NET applications should use (Action action) => HostingEnvironment.QueueBackgroundWorkItem(a => action()). Otherwise, background threads spawned using AppContext.QueueBackgroundAction are subject to AppPool teardowns and may never complete.</param>
 /// <param name="optionsLists">A collection of custom options that can be used by AppService UoW classes for application specific purposes.</param>
 public AppContextFactory(IEnumerable <KeyValuePair <Type, Type> > appServices, ErrorLoggerBase errorLogger, AuditLoggerBase auditLogger, Action <Action> backgroundAction, Action <Action <TAppContext> > factoryBackgroundAction, params IEnumerable <KeyValuePair <string, object> >[] optionsLists)
     : this(appServices, errorLogger, auditLogger, backgroundAction, factoryBackgroundAction, new AppOptions())
 {
     foreach (IEnumerable <KeyValuePair <string, object> > optionsList in optionsLists)
     {
         foreach (KeyValuePair <string, object> option in optionsList)
         {
             _options.Add(option);
         }
     }
 }