コード例 #1
0
        public static IWeiboClientBuilder WithConfig(this IWeiboClientBuilder builder, string appKey, string appSecret, string redirectUri)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            if (string.IsNullOrEmpty(appKey))
            {
                throw new ArgumentException("AppKey 为空");
            }
            if (string.IsNullOrEmpty(appSecret))
            {
                throw new ArgumentException("AppSecret 为空");
            }
            if (string.IsNullOrEmpty(redirectUri))
            {
                throw new ArgumentException("RedirectUri 为空");
            }

            builder.Services.Configure <WeiboOptions>(options =>
            {
                options.AppKey      = appKey;
                options.AppSecret   = appSecret;
                options.RedirectUri = redirectUri;
            });
            return(builder);
        }
コード例 #2
0
        public static IWeiboClientBuilder UseDefaultAccessTokenStorage(this IWeiboClientBuilder builder)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            return(builder.UseAccessTokenStorage <AccessTokenStorage>());
        }
コード例 #3
0
        public static IWeiboClientBuilder UseAccessTokenStorage <T>(this IWeiboClientBuilder builder) where T : class, IAccessTokenStorage
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            builder.Services.AddTransient <IAccessTokenStorage, T>();
            return(builder);
        }
コード例 #4
0
        public static IWeiboClientBuilder UseAuthorizationProvider <T>(this IWeiboClientBuilder builder) where T : class, IAuthorizationProvider
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            builder.Services.AddTransient <IAuthorizationProvider, T>();
            return(builder);
        }
コード例 #5
0
        public static IWeiboClientBuilder UseDefaultAuthorizationProvider(this IWeiboClientBuilder builder)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            builder.UseAuthorizationProvider <UwpAuthorizationProvider>();
            return(builder);
        }