本文整理汇总了C#中IAppSettings.Get方法的典型用法代码示例。如果您正苦于以下问题:C# IAppSettings.Get方法的具体用法?C# IAppSettings.Get怎么用?C# IAppSettings.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAppSettings
的用法示例。
在下文中一共展示了IAppSettings.Get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AppConfig
public AppConfig(IAppSettings appSettings)
{
this.Env = appSettings.Get("Env", Env.Local);
this.EnableCdn = appSettings.Get("EnableCdn", false);
this.CdnPrefix = appSettings.Get("CdnPrefix", "");
this.AdminUserNames = appSettings.Get("AdminUserNames", new List<string>());
}
示例2: FacebookAuthProvider
public FacebookAuthProvider(IAppSettings appSettings)
: base(appSettings, Realm, Name, "AppId", "AppSecret")
{
this.AppId = appSettings.GetString("oauth.facebook.AppId");
this.AppSecret = appSettings.GetString("oauth.facebook.AppSecret");
this.Permissions = appSettings.Get("oauth.facebook.Permissions", new string[0]);
this.Fields = appSettings.Get("oauth.facebook.Fields", DefaultFields);
}
示例3: TodoModule
public TodoModule(IAppSettings appSettings, ITodoService todoService, IServiceBus bus)
{
_todoService = todoService;
_bus = bus;
Post["/todo"] = _ =>
{
var slashCommand = this.Bind<SlashCommand>();
if (slashCommand == null ||
slashCommand.command.Missing())
{
Log.Info("Rejected an incoming slash command (unable to parse request body).");
return HttpStatusCode.BadRequest.WithReason("Unable to parse slash command.");
}
if (!appSettings.Get("todo:slackSlashCommandToken").Equals(slashCommand.token))
{
Log.Info("Blocked an unauthorized slash command.");
return HttpStatusCode.Unauthorized.WithReason("Missing or invalid token.");
}
if (!slashCommand.command.Equals("/todo", StringComparison.InvariantCultureIgnoreCase))
{
Log.Info("Rejected an incoming slash command ({0} is not handled by this module).", slashCommand.command);
return HttpStatusCode.BadRequest.WithReason("Unsupported slash command.");
}
var responseText = HandleTodo(slashCommand);
if (responseText.Missing())
{
return HttpStatusCode.OK;
}
return responseText;
};
}
示例4: FourSquareOAuth2Provider
public FourSquareOAuth2Provider(IAppSettings appSettings)
: base(appSettings, Realm, Name)
{
this.AuthorizeUrl = this.AuthorizeUrl ?? Realm;
this.AccessTokenUrl = this.AccessTokenUrl ?? "https://foursquare.com/oauth2/access_token";
this.UserProfileUrl = this.UserProfileUrl ?? "https://api.foursquare.com/v2/users/self";
// https://developer.foursquare.com/overview/versioning
DateTime versionDate;
if (!DateTime.TryParse(appSettings.GetString("oauth.{0}.Version".Fmt(Name)), out versionDate))
versionDate = DateTime.UtcNow;
// version dates before June 9, 2012 will automatically be rejected
if (versionDate < new DateTime(2012, 6, 9))
versionDate = DateTime.UtcNow;
this.Version = versionDate;
// Profile Image URL requires dimensions (Width x height) in the URL (default = 64x64 and minimum = 16x16)
int profileImageWidth;
if (!int.TryParse(appSettings.GetString("oauth.{0}.ProfileImageWidth".Fmt(Name)), out profileImageWidth))
profileImageWidth = 64;
this.ProfileImageWidth = Math.Max(profileImageWidth, 16);
int profileImageHeight;
if (!int.TryParse(appSettings.GetString("oauth.{0}.ProfileImageHeight".Fmt(Name)), out profileImageHeight))
profileImageHeight = 64;
this.ProfileImageHeight = Math.Max(profileImageHeight, 16);
Scopes = appSettings.Get("oauth.{0}.Scopes".Fmt(Name), new[] { "basic" });
}
示例5: SamlAuthProvider
public SamlAuthProvider(IAppSettings appSettings, string authRealm, string provider, X509Certificate2 signingCert)
{
Logger.Info("SamlAuthProvider Starting up for Realm: {0}, Provider: {1}".Fmt(authRealm, provider));
this.AuthRealm = appSettings != null ? appSettings.Get("SamlRealm", authRealm) : authRealm;
this.Provider = provider;
this.SamlSigningCert = signingCert;
if(appSettings != null)
{
this.CallbackUrl = appSettings.GetString("saml.{0}.CallbackUrl".Fmt(provider)) ?? this.FallbackConfig(appSettings.GetString("saml.CallbackUrl"));
this.IdpInitiatedRedirect = appSettings.GetString("saml.{0}.IdpInitiatedRedirect".Fmt(provider)) ?? this.FallbackConfig(appSettings.GetString("saml.IdpInitiatedRedirect"));
this.RedirectUrl = appSettings.GetString("saml.{0}.RedirectUrl".Fmt(provider)) ?? this.FallbackConfig(appSettings.GetString("saml.RedirectUrl"));
this.LogoutUrl = appSettings.GetString("saml.{0}.LogoutUrl".Fmt(provider)) ?? this.FallbackConfig(appSettings.GetString("saml.LogoutUrl"));
this.Issuer = appSettings.GetString("saml.{0}.Issuer".Fmt(provider)) ?? this.FallbackConfig(appSettings.GetString("saml.Issuer"));
this.AuthorizeUrl = appSettings.GetString("saml.{0}.AuthorizeUrl".Fmt(provider)) ?? this.FallbackConfig(appSettings.GetString("saml.AuthorizeUrl"));
this.SamlResponseFormKey = appSettings.GetString("saml.{0}.ResponseFormKey".Fmt(provider)) ?? this.FallbackConfig(appSettings.GetString("saml.ResponseFormKey"));
Logger.Info("Obtained the following settings from appSettings");
Logger.Info(new
{
this.CallbackUrl,
this.RedirectUrl,
this.LogoutUrl,
this.Issuer,
this.AuthorizeUrl,
this.SamlResponseFormKey
}.ToJson());
}
}
示例6: GithubAuthProvider
public GithubAuthProvider(IAppSettings appSettings)
: base(appSettings, Realm, Name, "ClientId", "ClientSecret")
{
ClientId = appSettings.GetString("oauth.github.ClientId");
ClientSecret = appSettings.GetString("oauth.github.ClientSecret");
Scopes = appSettings.Get("oauth.github.Scopes", new[] { "user" });
}
示例7: OAuthProvider
public OAuthProvider(IAppSettings appSettings, string authRealm, string oAuthProvider,
string consumerKeyName, string consumerSecretName)
{
this.AuthRealm = appSettings.Get("OAuthRealm", authRealm);
this.Provider = oAuthProvider;
this.RedirectUrl = appSettings.GetString("oauth.{0}.RedirectUrl".Fmt(oAuthProvider));
this.CallbackUrl = appSettings.GetString("oauth.{0}.CallbackUrl".Fmt(oAuthProvider));
this.ConsumerKey = appSettings.GetString("oauth.{0}.{1}".Fmt(oAuthProvider, consumerKeyName));
this.ConsumerSecret = appSettings.GetString("oauth.{0}.{1}".Fmt(oAuthProvider, consumerSecretName));
this.RequestTokenUrl = appSettings.Get("oauth.{0}.RequestTokenUrl".Fmt(oAuthProvider), authRealm + "oauth/request_token");
this.AuthorizeUrl = appSettings.Get("oauth.{0}.AuthorizeUrl".Fmt(oAuthProvider), authRealm + "oauth/authorize");
this.AccessTokenUrl = appSettings.Get("oauth.{0}.AccessTokenUrl".Fmt(oAuthProvider), authRealm + "oauth/access_token");
this.OAuthUtils = new OAuthAuthorizer(this);
this.AuthHttpGateway = new AuthHttpGateway();
}
示例8: WhoisModule
public WhoisModule(IAppSettings appSettings, IServiceBus bus)
{
_bus = bus;
Post["/whois"] = _ =>
{
var slashCommand = this.Bind<SlashCommand>();
if (slashCommand == null ||
slashCommand.command.Missing())
{
Log.Info("Rejected an incoming slash command (unable to parse request body).");
return HttpStatusCode.BadRequest.WithReason("Unable to parse slash command.");
}
if (!appSettings.Get("whois:slackSlashCommandToken").Equals(slashCommand.token))
{
Log.Info("Blocked an unauthorized slash command.");
return HttpStatusCode.Unauthorized.WithReason("Missing or invalid token.");
}
if (!slashCommand.command.Equals("/whois", StringComparison.InvariantCultureIgnoreCase))
{
Log.Info("Rejected an incoming slash command ({0} is not handled by this module).", slashCommand.command);
return HttpStatusCode.BadRequest.WithReason("Unsupported slash command.");
}
var responseText = HandleWhois(slashCommand);
if (responseText.Missing())
{
return HttpStatusCode.OK;
}
return responseText;
};
Post["/whois/fullcontact/person"] = _ =>
{
// Parse the request data
var person = this.BindTo(new FullContactPersonResult());
if (person == null ||
person.Result == null)
{
Log.Info("Rejected webhook call from FullContact (unable to parse request body).");
return HttpStatusCode.BadRequest.WithReason("Unable to parse request body.");
}
// Get the pending command that corresponds to the posted data
if (string.IsNullOrWhiteSpace(person.WebhookId))
{
Log.Info("Rejected a webhook call from FullContact (webhookId missing).");
return HttpStatusCode.BadRequest.WithReason("The webhookId property is missing from the request body.");
}
bus.Publish(person);
return HttpStatusCode.OK;
};
}
示例9: Init
public override void Init(IAppSettings appSettings = null)
{
this.SetBearerTokenOnAuthenticateResponse = appSettings == null
|| appSettings.Get("jwt.SetBearerTokenOnAuthenticateResponse", true);
ServiceRoutes = new Dictionary<Type, string[]>
{
{ typeof(ConvertSessionToTokenService), new[] { "/session-to-token" } },
};
base.Init(appSettings);
}
示例10: OAuthProvider
public OAuthProvider(IAppSettings appSettings, string authRealm, string oAuthProvider,
string consumerKeyName, string consumerSecretName)
{
this.AuthRealm = appSettings.Get("OAuthRealm", authRealm);
this.Provider = oAuthProvider;
this.RedirectUrl = appSettings.GetString($"oauth.{oAuthProvider}.RedirectUrl")
?? FallbackConfig(appSettings.GetString("oauth.RedirectUrl"));
this.CallbackUrl = appSettings.GetString($"oauth.{oAuthProvider}.CallbackUrl")
?? FallbackConfig(appSettings.GetString("oauth.CallbackUrl"));
this.ConsumerKey = appSettings.GetString($"oauth.{oAuthProvider}.{consumerKeyName}");
this.ConsumerSecret = appSettings.GetString($"oauth.{oAuthProvider}.{consumerSecretName}");
this.RequestTokenUrl = appSettings.Get($"oauth.{oAuthProvider}.RequestTokenUrl", authRealm + "oauth/request_token");
this.AuthorizeUrl = appSettings.Get($"oauth.{oAuthProvider}.AuthorizeUrl", authRealm + "oauth/authorize");
this.AccessTokenUrl = appSettings.Get($"oauth.{oAuthProvider}.AccessTokenUrl", authRealm + "oauth/access_token");
this.SaveExtendedUserInfo = appSettings.Get($"oauth.{oAuthProvider}.SaveExtendedUserInfo", true);
this.OAuthUtils = new OAuthAuthorizer(this);
this.AuthHttpGateway = new AuthHttpGateway();
}
示例11: AuthProvider
protected AuthProvider(IAppSettings appSettings, string authRealm, string oAuthProvider)
: this()
{
// Enhancement per https://github.com/ServiceStack/ServiceStack/issues/741
this.AuthRealm = appSettings != null ? appSettings.Get("OAuthRealm", authRealm) : authRealm;
this.Provider = oAuthProvider;
if (appSettings != null)
{
this.CallbackUrl = appSettings.GetString("oauth.{0}.CallbackUrl".Fmt(oAuthProvider))
?? FallbackConfig(appSettings.GetString("oauth.CallbackUrl"));
this.RedirectUrl = appSettings.GetString("oauth.{0}.RedirectUrl".Fmt(oAuthProvider))
?? FallbackConfig(appSettings.GetString("oauth.RedirectUrl"));
}
}
示例12: AadAuthProvider
public AadAuthProvider(IAppSettings appSettings)
: base(appSettings, Realm, Name, "ClientId", "ClientSecret")
{
AppSettings = appSettings;
TenantId = AppSettings.Get<string>("oauth.{0}.TenantId".Fmt(Provider), null);
DomainHint = AppSettings.Get<string>("oauth.{0}.DomainHint".Fmt(Provider), null);
ResourceId = AppSettings.Get("oauth.{0}.ResourceId".Fmt(Provider), "00000002-0000-0000-c000-000000000000");
Scopes = AppSettings.Get("oauth.{0}.Scopes".Fmt(Provider), new[] { "user_impersonation" });
FailureRedirectPath = AppSettings.Get("oauth.{0}.FailureRedirectPath".Fmt(Provider), "/");
if (RedirectUrl != null && LogConfigurationWarnings)
Log.Warn("{0} auth provider does not use the RedirectUrl, but one has been configured.".Fmt(Provider));
if (RequestTokenUrl != Realm + "oauth/request_token" && LogConfigurationWarnings)
Log.Warn("{0} auth provider does not use the RequestTokenUrl, but one has been configured.".Fmt(Provider));
}
示例13: Init
public virtual void Init(IAppSettings appSettings = null)
{
RequireSecureConnection = true;
EncryptPayload = false;
HashAlgorithm = "HS256";
RequireHashAlgorithm = true;
Issuer = "ssjwt";
ExpireTokensIn = TimeSpan.FromDays(14);
FallbackAuthKeys = new List<byte[]>();
FallbackPublicKeys = new List<RSAParameters>();
if (appSettings != null)
{
RequireSecureConnection = appSettings.Get("jwt.RequireSecureConnection", RequireSecureConnection);
RequireHashAlgorithm = appSettings.Get("jwt.RequireHashAlgorithm", RequireHashAlgorithm);
EncryptPayload = appSettings.Get("jwt.EncryptPayload", EncryptPayload);
Issuer = appSettings.GetString("jwt.Issuer");
Audience = appSettings.GetString("jwt.Audience");
KeyId = appSettings.GetString("jwt.KeyId");
var hashAlg = appSettings.GetString("jwt.HashAlgorithm");
if (!string.IsNullOrEmpty(hashAlg))
HashAlgorithm = hashAlg;
var privateKeyXml = appSettings.GetString("jwt.PrivateKeyXml");
if (privateKeyXml != null)
PrivateKeyXml = privateKeyXml;
var publicKeyXml = appSettings.GetString("jwt.PublicKeyXml");
if (publicKeyXml != null)
PublicKeyXml = publicKeyXml;
var base64 = appSettings.GetString("jwt.AuthKeyBase64");
if (base64 != null)
AuthKeyBase64 = base64;
var dateStr = appSettings.GetString("jwt.InvalidateTokensIssuedBefore");
if (!string.IsNullOrEmpty(dateStr))
InvalidateTokensIssuedBefore = dateStr.FromJsv<DateTime>();
ExpireTokensIn = appSettings.Get("jwt.ExpireTokensIn", ExpireTokensIn);
var intStr = appSettings.GetString("jwt.ExpireTokensInDays");
if (intStr != null)
ExpireTokensInDays = int.Parse(intStr);
string base64Key;
var i = 1;
while ((base64Key = appSettings.GetString("jwt.PrivateKeyXml." + i++)) != null)
{
var publicKey = base64Key.ToPublicRSAParameters();
FallbackPublicKeys.Add(publicKey);
}
i = 1;
while ((base64Key = appSettings.GetString("jwt.PublicKeyXml." + i++)) != null)
{
var publicKey = base64Key.ToPublicRSAParameters();
FallbackPublicKeys.Add(publicKey);
}
i = 1;
while ((base64Key = appSettings.GetString("jwt.AuthKeyBase64." + i++)) != null)
{
var authKey = Convert.FromBase64String(base64Key);
FallbackAuthKeys.Add(authKey);
}
}
}
示例14: TwitterAuthProvider
public TwitterAuthProvider(IAppSettings appSettings)
: base(appSettings, Realm, Name)
{
this.AuthorizeUrl = appSettings.Get("oauth.twitter.AuthorizeUrl", Realm + "oauth/authenticate");
}
示例15: ExampleConfig
public ExampleConfig(IAppSettings appConfig)
{
ConnectionString = appConfig.GetString("ConnectionString");
DefaultFibonacciLimit = appConfig.Get("DefaultFibonacciLimit", 10);
}