public static void TimeoutCallback(this WebExpander e, object state, bool timedOut) { if (!timedOut) { return; } var request = state as HttpWebRequest; if (request != null) { request.Abort(); } }
public static WebProxy GetProxy(this WebExpander exp, string url) { if (!J_ <ProxyUse> .Sz.As <bool>()) { return(new WebProxy()); } if (!UseProxyFor(exp, url)) { return(new WebProxy()); } var proxy = !string.IsNullOrWhiteSpace(J_ <ProxyServer> .Sz) ? new WebProxy(J_ <ProxyServer> .Sz, J_ <ProxyPort> .Sz.As <int>()) : WebProxy.GetDefaultProxy(); proxy.Credentials = !string.IsNullOrWhiteSpace(J_ <ProxyUser> .Sz) ? new NetworkCredential(J_ <ProxyUser> .Sz, J_ <ProxyPassword> .Sz) : CredentialCache.DefaultCredentials; return(proxy); }
public static bool UseProxyFor(this WebExpander exp, string url) { if (!J_ <ProxyUse> .Sz.As <bool>()) { return(false); } url = url.Replace("https://", string.Empty).Replace("http://", string.Empty); foreach (var exclude in ProxyExcludesList) { if (url.StartsWith(exclude)) { return(false); } } return(true); }
public static T To <T>(this WebExpander exp, string json, WebConverter converter = null) { return((T)(converter ?? Converter).Deserialize(json, typeof(T))); }
public static object To(this WebExpander e, string s, Type type, WebConverter converter = null) { return((converter ?? Converter).Deserialize(s, type)); }
public static string Of <TConverter>(this WebExpander e, object value) where TConverter : WebConverter { return((Je.sys.InstanceOf <TConverter>()).Serialize(value)); }
public static string Of(this WebExpander e, object value, WebConverter converter = null) { return((converter ?? Converter).Serialize(value)); }
public static TResult To <TResult, TConverter>(this WebExpander exp, string json) where TConverter : WebConverter { return((TResult)(Je.sys.InstanceOf <TConverter>()).Deserialize(json, typeof(TResult))); }