示例#1
0
        public DnfClient(string?instanceUrl, string?accessToken, string?refreshToken, Action <string>?logger = null)
        {
            Logger             = logger;
            SelectListResolver = new DataMemberSelectListResolver();
            HttpClient jsonClient;
            HttpClient xmlClient;

            if (UseCompression)
            {
                var httpHandler = new HttpClientHandler
                {
                    AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate
                };
                jsonClient = new HttpClient(httpHandler)
                {
                    Timeout = TimeSpan.FromSeconds(60 * 30)
                };
                //jsonClient.DefaultRequestHeaders.ConnectionClose = true;
                jsonClient.DefaultRequestHeaders.AcceptEncoding.Add(new StringWithQualityHeaderValue("gzip"));
                xmlClient = new HttpClient(httpHandler)
                {
                    Timeout = TimeSpan.FromSeconds(60 * 30)
                };
            }
            else
            {
                jsonClient = new HttpClient {
                    Timeout = TimeSpan.FromSeconds(60 * 30)
                };
                xmlClient = new HttpClient {
                    Timeout = TimeSpan.FromSeconds(60 * 30)
                };
            }

            //xmlClient.DefaultRequestHeaders.ConnectionClose = true;
            xmlClient.DefaultRequestHeaders.AcceptEncoding.Add(new StringWithQualityHeaderValue("gzip"));
            InstanceUrl  = instanceUrl;
            AccessToken  = accessToken;
            RefreshToken = refreshToken;
            ApiVersion   = DefaultApiVersion;

            JsonHttp = new JsonHttpClient(InstanceUrl, ApiVersion, AccessToken, jsonClient);
            XmlHttp  = new XmlHttpClient(InstanceUrl, ApiVersion, AccessToken, xmlClient);

            Chatter   = new ChatterClient(JsonHttp);
            Composite = new CompositeClient(JsonHttp, ApiVersion, Logger);
            Tooling   = new ToolingClient(JsonHttp);
            Bulk      = new BulkClient(XmlHttp, JsonHttp);
            Layout    = new LayoutClient(XmlHttp, JsonHttp);
        }
示例#2
0
 public ToolingClient(JsonHttpClient jsonHttp)
 {
     SelectListResolver = new DataMemberSelectListResolver();
     JsonHttp           = jsonHttp;
 }