protected override IConfigurationProvider OnCreateDefaultProvider(string sectionName, object configData) { string jsonFile = "JsonConfiguration.txt"; if (configData != null) jsonFile = configData as string; var provider = new JsonFileConfigurationProvider<JsonFileConfiguration>() { JsonConfigurationFile = jsonFile, EncryptionKey = "ultra-seekrit", // use a generated value here PropertiesToEncrypt = "Password,AppConnectionString" }; return provider; }
protected override IConfigurationProvider OnCreateDefaultProvider(string sectionName, object configData) { var provider = new JsonFileConfigurationProvider <WeblogAddinConfiguration>() { JsonConfigurationFile = Path.Combine(mmApp.Configuration.CommonFolder, "WebLogAddIn.json") }; if (!File.Exists(provider.JsonConfigurationFile)) { if (!Directory.Exists(Path.GetDirectoryName(provider.JsonConfigurationFile))) { Directory.CreateDirectory(Path.GetDirectoryName(provider.JsonConfigurationFile)); } } return(provider); }
protected override IConfigurationProvider OnCreateDefaultProvider(string sectionName, object configData) { string jsonFile = "JsonConfiguration.txt"; if (configData != null) { jsonFile = configData as string; } var provider = new JsonFileConfigurationProvider <JsonFileConfiguration>() { JsonConfigurationFile = jsonFile, EncryptionKey = "ultra-seekrit", // use a generated value here PropertiesToEncrypt = "Password,AppConnectionString,License.LicenseKey" }; return(provider); }
protected override void OnInitialize(IConfigurationProvider provider, string sectionName, object configData) { if (provider == null) { #if NETFULL provider = new ConfigurationFileConfigurationProvider <LogManagerConfiguration>() { ConfigurationSection = "LogManager" }; #else provider = new JsonFileConfigurationProvider <LogManagerConfiguration>() { JsonConfigurationFile = "LogConfiguration.json" }; #endif } Provider = provider; Read(); }
protected override IConfigurationProvider OnCreateDefaultProvider(string sectionName, object configData) { var provider = new JsonFileConfigurationProvider <ApplicationConfiguration>() { JsonConfigurationFile = Path.Combine(CommonFolder, "MarkdownMonster.json") }; if (!File.Exists(provider.JsonConfigurationFile)) { if (!Directory.Exists(Path.GetDirectoryName(provider.JsonConfigurationFile))) { Directory.CreateDirectory(Path.GetDirectoryName(provider.JsonConfigurationFile)); } } if (!Directory.Exists(AddinsFolder)) { Directory.CreateDirectory(AddinsFolder); } return(provider); }
/// <summary> /// Test QBO api call /// </summary> /// <param name="apiCallFunction"></param> public async Task QBOApiCall(Action <ServiceContext> apiCallFunction) { var oauthClient = new OAuth2Client( _auth2Keys.ClientId, _auth2Keys.ClientSecret, _auth2Keys.RedirectUrl, _auth2Keys.Environment); var token = await _tokens.Token.FirstOrDefaultAsync(t => t.RealmId == _auth2Keys.RealmId); try { if (_auth2Keys.RealmId != "") { if (token.AccessToken != null && token.RealmId != null) { var reqValidator = new OAuth2RequestValidator(token.AccessToken); var configurationProvider = new JsonFileConfigurationProvider(Directory.GetCurrentDirectory() + "\\appsettings.json"); var context = new ServiceContext(token.RealmId, IntuitServicesType.QBO, reqValidator, configurationProvider); context.IppConfiguration.BaseUrl.Qbo = _auth2Keys.QBOBaseUrl; apiCallFunction(context); } } } catch (IdsException ex) { if (ex.Message == "Unauthorized-401") { var tokens = await oauthClient.RefreshTokenAsync(token.RefreshToken); if (tokens.AccessToken != null && tokens.RefreshToken != null) { await UpdateTokens(token.RealmId, tokens.AccessToken, tokens.RefreshToken); await QBOApiCall(apiCallFunction); } } } }
protected override IConfigurationProvider OnCreateDefaultProvider(string sectionName, object configData) { var commonFolder = CommonFolder; var cfFile = Path.Combine(InternalCommonFolder, "CommonFolderLocation.txt"); if (File.Exists(cfFile)) { commonFolder = File.ReadAllText(cfFile); if (!Directory.Exists(commonFolder)) { commonFolder = InternalCommonFolder; File.Delete(cfFile); } } if (string.IsNullOrWhiteSpace(commonFolder)) { commonFolder = CommonFolder; File.Delete(cfFile); } var provider = new JsonFileConfigurationProvider <ApplicationConfiguration>() { JsonConfigurationFile = Path.Combine(commonFolder, "MarkdownMonster.json") }; if (!File.Exists(provider.JsonConfigurationFile)) { if (!Directory.Exists(Path.GetDirectoryName(provider.JsonConfigurationFile))) { Directory.CreateDirectory(Path.GetDirectoryName(provider.JsonConfigurationFile)); } } if (!Directory.Exists(AddinsFolder)) { Directory.CreateDirectory(AddinsFolder); } return(provider); }
public void ReadConfigurationFromValidJsonFile( IConfigurationBuilder configBuilder = null, JsonFileConfigurationSource configurationSource = null, IConfigurationRoot configuration = null, JsonFileConfigurationProvider configProvider = null, IConfigurationSection configSection = null) { "Given a new configuration builder" .x(() => { configBuilder = new ConfigurationBuilder(); }); $"And the host builder gets a {nameof(JsonFileConfigurationSource)} added" .x(() => { configBuilder.Add <JsonFileConfigurationSource>(source => { configurationSource = source; }); }); $"And the {nameof(JsonFileConfigurationSource)} targets to a valid json file" .x(() => { configurationSource.Path = @"Specifications\Configuration\Json\JsonFileConfigurationFeature.json"; }); $"And the identifier callback of the {nameof(JsonFileConfigurationSource)} is configured" .x(() => { configurationSource.IsIdentifier = (name, prefixes) => { return(prefixes.FirstOrDefault() switch { "Endpoints" => (string.Equals(name, "Id", StringComparison.OrdinalIgnoreCase)), "Routes" => (string.Equals(name, "RouteId", StringComparison.OrdinalIgnoreCase)), _ => false }); }; });
protected override IConfigurationProvider OnCreateDefaultProvider(string sectionName, object configData) { // force JSON.NET to load if not loaded already string t = JsonConvert.SerializeObject("X"); var provider = new JsonFileConfigurationProvider<ApplicationSecrets>() { JsonConfigurationFile= Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"CodePasteKeys.json"), // don't really need to encrypt - just keep out of source control //EncryptionKey = "CodePaste|App:Secrets@", //PropertiesToEncrypt = "GoogleClientId,GoggleClientSecret,TwitterConsumerKey,TwitterConsumerSecret,GitHubClientId,GitHubClientSecret" }; return provider; }
/// <summary> /// Override this method to create the custom default provider. Here we allow for different /// configuration providers so we don't have to rely on .NET configuration classed (for vNext) /// </summary> protected override IConfigurationProvider OnCreateDefaultProvider(string sectionName, object configData) { if (string.IsNullOrEmpty(sectionName)) sectionName = "DbResourceConfiguration"; IConfigurationProvider provider; if (ConfigurationMode == ConfigurationModes.JsonFile) { provider = new JsonFileConfigurationProvider<DbResourceConfiguration>() { JsonConfigurationFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DbResourceConfiguration.json") }; } else if (ConfigurationMode == ConfigurationModes.XmlFile) { provider = new XmlFileConfigurationProvider<DbResourceConfiguration>() { XmlConfigurationFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DbResourceConfiguration.xml") }; } else { provider = new ConfigurationFileConfigurationProvider<DbResourceConfiguration>() { ConfigurationSection = sectionName }; } return provider; }
protected override IConfigurationProvider OnCreateDefaultProvider(string sectionName, object configData) { var provider = new JsonFileConfigurationProvider<WebSurgeConfiguration>() { JsonConfigurationFile = App.UserDataPath + "WebSurgeConfiguration.json", EncryptionKey = App.EncryptionMachineKey, PropertiesToEncrypt = "StressTester.Password" }; Provider = provider; return provider; }