Exemplo n.º 1
0
        public static void TimeoutCallback(this WebExpander e, object state, bool timedOut)
        {
            if (!timedOut)
            {
                return;
            }
            var request = state as HttpWebRequest;

            if (request != null)
            {
                request.Abort();
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 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);
 }
Exemplo n.º 4
0
 public static T To <T>(this WebExpander exp, string json, WebConverter converter = null)
 {
     return((T)(converter ?? Converter).Deserialize(json, typeof(T)));
 }
Exemplo n.º 5
0
 public static object To(this WebExpander e, string s, Type type, WebConverter converter = null)
 {
     return((converter ?? Converter).Deserialize(s, type));
 }
Exemplo n.º 6
0
 public static string Of <TConverter>(this WebExpander e, object value) where TConverter : WebConverter
 {
     return((Je.sys.InstanceOf <TConverter>()).Serialize(value));
 }
Exemplo n.º 7
0
 public static string Of(this WebExpander e, object value, WebConverter converter = null)
 {
     return((converter ?? Converter).Serialize(value));
 }
Exemplo n.º 8
0
 public static TResult To <TResult, TConverter>(this WebExpander exp, string json) where TConverter : WebConverter
 {
     return((TResult)(Je.sys.InstanceOf <TConverter>()).Deserialize(json, typeof(TResult)));
 }