/// <summary> /// Recursively searches for a connection string by name. Allows for linking connection strings to eachother by name /// </summary> /// <param name="provider">The provider to use</param> /// <param name="toTest">The name (or connection string) to return</param> /// <returns>The furthest resolvable value representing the connection string</returns> public static string FindConnectionString(this IProvideConfigurations provider, string toTest = "DefaultConnectionString") { if (provider is null) { throw new ArgumentNullException(nameof(provider)); } string ConnectionString; if (provider.GetConnectionString(toTest) != null) { ConnectionString = provider.GetConnectionString(toTest); } else if (!string.IsNullOrWhiteSpace(provider.GetConfiguration(toTest))) { ConnectionString = provider.FindConnectionString(provider.GetConfiguration(toTest)); } else { ConnectionString = toTest; } if (ConnectionString is null) { throw new Exception("Can not test for null connection string. How did we get here?"); } if (ConnectionString.StartsWith("name=", StringComparison.OrdinalIgnoreCase)) { ConnectionString = ConnectionString.Replace("name=", ""); ConnectionString = provider.FindConnectionString(ConnectionString); } return(ConnectionString); }
public ImageService(ImageRepository imageRepository, IProvideConfigurations configurationProvider, ISecurityProvider <Entity> securityProvider, IRepository <DatabaseFile>?databaseFileRepository = null) { this.ImageRepository = imageRepository; this.ConfigurationProvider = configurationProvider; this.DatabaseFileRepository = databaseFileRepository; this.SecurityProvider = securityProvider; }
public UserController(IProvideConfigurations configurationService, UserSession userSession, UserRepository userRepository, UserService userService, EmailValidationRepository emailValidationRepository, MessageBus?messageBus = null) { this.UserRepository = userRepository; this.EmailValidationRepository = emailValidationRepository; this.UserService = userService; this.ConfigurationService = configurationService; this.MessageBus = messageBus; this.UserSession = userSession; }
/// <summary> /// Checks connection strings first, then configurations /// </summary> /// <param name="provider">The IConfigurationProvider</param> /// <param name="Name">The name of the connection string/configuration</param> /// <returns>The value, if any is found, or null</returns> public static string ConnectionStringOrConfiguration(this IProvideConfigurations provider, string Name) { if (provider is null) { throw new ArgumentNullException(nameof(provider)); } return(provider.GetConnectionString(Name) ?? provider.GetConfiguration(Name)); }
/// <summary> /// Creates a new instance of this Email repository /// </summary> /// <param name="connectionInfo">Optional database connection info representing the database the emails are stored in. If provided, allows the repository to use ADO to update sent state as failsafe</param> /// <param name="configurationService">A Configuration Service instance used to extract values for the email system</param> /// <param name="dbContext">The Persistence context used to store EmailMessages</param> /// <param name="messageBus">An optional message bus used to send email message events</param> public EmailRepository(PersistenceConnectionInfo connectionInfo, IProvideConfigurations configurationService, IPersistenceContext <EmailMessage> dbContext, MessageBus messageBus = null) : base(dbContext, messageBus) { this.ConfigurationService = configurationService; PersistenceConnectionInfo = connectionInfo; if (connectionInfo != null) { DatabaseInstance = new DatabaseInstance(connectionInfo.ConnectionString); } }
/// <summary> /// Gets a configuration value as a bool /// </summary> /// <param name="provider"></param> /// <param name="Name">the name of the configuration value to get</param> /// <returns>The configuration value, or false if null</returns> public static bool GetBool(this IProvideConfigurations provider, string Name) { if (provider is null) { throw new ArgumentNullException(nameof(provider)); } string toReturn = provider.GetConfiguration(Name); return(toReturn != null && bool.Parse(toReturn)); }
/// <summary> /// Gets a configuration as an int /// </summary> /// <param name="provider">The provider to use</param> /// <param name="Name">The name of the configuration to get</param> /// <returns>the int representation (or 0 if null)</returns> public static int GetInt(this IProvideConfigurations provider, string Name) { if (provider is null) { throw new ArgumentNullException(nameof(provider)); } string toReturn = provider.GetConfiguration(Name); return(toReturn == null ? 0 : int.Parse(toReturn, NumberStyles.Integer, CultureInfo.CurrentCulture)); }
/// <summary> /// Returns a string value from an IProvideConfigurations as a Dictionary, assuming its delimited in Key=Value; notation /// </summary> /// <param name="provider">The provider to use as a source</param> /// <param name="key">The Key to search for</param> /// <returns>A dictionary representing the key value pairs found in the configuration value</returns> public static Dictionary <string, string> GetDictionary(this IProvideConfigurations provider, string key) { Contract.Requires(provider != null); string v = provider.GetConfiguration(key); if (v is null) { return(null); } else { return(v.ToDictionary()); } }
/// <summary> /// Returns a string value from an IProvideConfigurations as a Dictionary, assuming its delimited in Key=Value; notation /// </summary> /// <param name="provider">The provider to use as a source</param> /// <param name="key">The Key to search for</param> /// <returns>A dictionary representing the key value pairs found in the configuration value</returns> public static Dictionary <string, string> GetDictionary(this IProvideConfigurations provider, string key) { if (provider is null) { throw new ArgumentNullException(nameof(provider)); } string v = provider.GetConfiguration(key); if (v is null) { return(null); } else { return(v.ToDictionary()); } }
/// <summary> /// Instantiates this class, and creates a file system watcher (if null) to send messages back to the service /// if any changes occur during execution /// </summary> public FileService(IUserSession userSession = null, IProvideConfigurations configurationProvider = null) { this.UserSession = userSession; this.ConfigurationProvider = configurationProvider; lock (WatcherLock) { if (Watcher is null) { Watcher = new FileSystemWatcher { IncludeSubdirectories = true, Path = ApplicationPath, }; Watcher.Renamed += Watcher_Event; Watcher.Deleted += Watcher_Event; Watcher.Created += Watcher_Event; Watcher.Changed += Watcher_Event; Watcher.EnableRaisingEvents = true; } } }
/// <summary> /// Checks for the configuration "Debug" and returns its value /// </summary> /// <param name="provider">The provider to use</param> /// <returns>The value of "Debug"</returns> public static bool IsDebug(this IProvideConfigurations provider) { return(provider.GetBool("Debug")); }
/// <summary> /// Constructs a new instance of this service /// </summary> /// <param name="emailRepository">The IRepository implementation to be used when persisting the message</param> /// <param name="configurationProvider">A Configuration provider to use to retrieve email message configurations</param> public EmailService(IRepository <EmailMessage> emailRepository, IProvideConfigurations configurationProvider) : base(configurationProvider) { this.EmailRepository = emailRepository; }
/// <summary> /// Constructs a new instance of this mail service /// </summary> /// <param name="configurationProvider">The configuration provider to get email configurations from</param> public MailService(IProvideConfigurations configurationProvider) { this.ConfigurationProvider = configurationProvider; }
public StartupMessageHandler(IProvideConfigurations configurationProvider, PersistenceConnectionInfo connectionInfo) { this.ConfigurationProvider = configurationProvider; this.ConnectionInfo = connectionInfo; }
public Configuration(IProvideConfigurations configurationProvider) { this.ConfigurationProvider = configurationProvider; }
public ReportingController(IProvideConfigurations configurationService, IRepository <ParameterInfo> reportingParameterRepository, System.IServiceProvider serviceProvider, IUserSession userSession) : base(serviceProvider, userSession) { this.ConfigurationService = configurationService; this.ReportingDatabase = new DatabaseInstance(this.ConfigurationService.ConnectionStringOrConfiguration(ConfigurationNames.CONNECTION_STRINGS_REPORTING)); this.ReportingParameterRepository = reportingParameterRepository; }
public UserService(UserSession userSession, UserRepository userRepository, IRepository <Role> roleRepository, IProvideConfigurations configurationService, IRepository <AuthenticationToken> authenticationTokenRepository, ISendTemplates emailTemplateRepository = null, MessageBus?messageBus = null) : base(userRepository, emailTemplateRepository, authenticationTokenRepository) { this.UserSession = userSession; this.UserRepository = userRepository; this.RoleRepository = roleRepository; this.ConfigurationService = configurationService; this.MessageBus = messageBus; }
public FileController(IUserSession userSession, DatabaseFileRepository databaseFileRepository, IRepository <AuditableError> errorRepository, IProvideConfigurations configurationService, IServiceProvider serviceProvider, FileService fileService, MessageBus messageBus, ISecurityProvider <DatabaseFile>?securityProvider = null) : base(serviceProvider, userSession) { this.SecurityProvider = securityProvider; ; this.DatabaseFileRepository = databaseFileRepository; this.ConfigurationService = configurationService; this.ErrorRepository = errorRepository; this.MessageBus = messageBus; this.FileService = fileService; }
/// <summary> /// Constructs a new instance of the ConfigurationController /// </summary> /// <param name="configurationRepository">A repository used to persist configurations</param> /// <param name="configurationService">An IProvideConfigurations implementation used as a configuration source</param> /// <param name="serviceProvider">A ServiceProvider instance used for dependency injection</param> public ConfigurationController(IRepository <CmsConfiguration> configurationRepository, IProvideConfigurations configurationService, IServiceProvider serviceProvider, IUserSession userSession) : base(serviceProvider, userSession) { this.ConfigurationService = configurationService; this.ConfigurationRepository = configurationRepository; }
public AutoGenerate(IProvideConfigurations configurationService) { this.ConfigurationService = configurationService; }