当前位置: 首页>>代码示例>>C#>>正文


C# IAppSettings.Get方法代码示例

本文整理汇总了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>());
 }
开发者ID:rjaydadula,项目名称:SocialBootstrapApi,代码行数:7,代码来源:AppConfig.cs

示例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);
 }
开发者ID:yuinlin,项目名称:ServiceStack,代码行数:8,代码来源:FacebookAuthProvider.cs

示例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;
            };
        }
开发者ID:rapidexpert,项目名称:SlackCommander,代码行数:33,代码来源:TodoModule.cs

示例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" });
        }
开发者ID:jin29neci,项目名称:ServiceStack,代码行数:33,代码来源:FourSquareOAuth2Provider.cs

示例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());
            }

            
        }
开发者ID:americansystems,项目名称:servicestack-auth-saml,代码行数:29,代码来源:SamlAuthProvider.cs

示例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" });
 }
开发者ID:vebin,项目名称:soa,代码行数:7,代码来源:GithubAuthProvider.cs

示例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();
        }
开发者ID:GDBSD,项目名称:ServiceStack,代码行数:18,代码来源:OAuthProvider.cs

示例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;
            };
        }
开发者ID:rapidexpert,项目名称:SlackCommander,代码行数:54,代码来源:WhoisModule.cs

示例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);
        }
开发者ID:AVee,项目名称:ServiceStack,代码行数:12,代码来源:JwtAuthProvider.cs

示例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();
        }
开发者ID:AVee,项目名称:ServiceStack,代码行数:21,代码来源:OAuthProvider.cs

示例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"));
            }
        }
开发者ID:dittodhole,项目名称:dotnet-ServiceStack,代码行数:15,代码来源:AuthProvider.cs

示例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));
 }
开发者ID:jfoshee,项目名称:ServiceStack.Authentication.Aad,代码行数:14,代码来源:AadAuthProvider.cs

示例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);
                }
            }
        }
开发者ID:AVee,项目名称:ServiceStack,代码行数:71,代码来源:JwtAuthProviderReader.cs

示例14: TwitterAuthProvider

 public TwitterAuthProvider(IAppSettings appSettings)
     : base(appSettings, Realm, Name)
 {
     this.AuthorizeUrl = appSettings.Get("oauth.twitter.AuthorizeUrl", Realm + "oauth/authenticate");
 }
开发者ID:AVee,项目名称:ServiceStack,代码行数:5,代码来源:TwitterAuthProvider.cs

示例15: ExampleConfig

		public ExampleConfig(IAppSettings appConfig)
		{
			ConnectionString = appConfig.GetString("ConnectionString");
			DefaultFibonacciLimit = appConfig.Get("DefaultFibonacciLimit", 10);
		}
开发者ID:BilliamBrown,项目名称:ServiceStack,代码行数:5,代码来源:ExampleConfig.cs


注:本文中的IAppSettings.Get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。