Exemple #1
0
        private Tuple <int, string, string> Send(string url, HttpMethod httpMethod, Content content = null, bool isUseApiAddress = false)
        {
            var authenticationSite = new AuthenticationSite()
            {
                AuthenticationType = "Auth", Uuid = Guid.NewGuid().ToString()
            };

            _iAuthenticationServices.Add(authenticationSite);

            var client = new System.Net.Http.HttpClient();

            client.DefaultRequestHeaders.Add("Authorization", authenticationSite.Uuid);

            var apiException = new ApiException();

            var result = ApiProxy.Send(httpMethod, url, content, client, apiException, isUseApiAddress);

            var error = string.Empty;

            if (apiException.Code != 200)
            {
                if (apiException.Code == 404)
                {
                    error = $"参数保存失败,{url}地址不存在,请检查输入的域名地址{apiException.Code}";
                }
                else
                {
                    error = $"参数保存失败,{url}服务器错误 Code={apiException.Code}";
                }
            }
            return(new Tuple <int, string, string>(apiException.Code, error, result));
        }
Exemple #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var auth = new AuthenticationSite();

            Configuration.GetSection("AuthenticationSite").Bind(auth);

            //DI : To pass whole config in contructor
            services.AddSingleton <AuthenticationSite>(auth);

            //DI : TO pass a section in option
            services.Configure <AuthenticationSite>(options => Configuration.GetSection("AuthenticationSite").Bind(options));


            services.AddMvc();
        }
 public ValuesController(AuthenticationSite authenticationSite, IOptions <AuthenticationSite> options)
 {
 }
Exemple #4
0
 public int Add(AuthenticationSite authenticationSite)
 {
     return(_authenticationSite.Add(authenticationSite));
 }
Exemple #5
0
 public AuthenticationServices()
 {
     _authenticationSite = new AuthenticationSite();
 }