예제 #1
0
파일: Util.cs 프로젝트: radtek/ProxyService
        public static UpStreamProxy DeSerializeToUpStream(string xml)
        {
            XmlSerializer ser = new XmlSerializer(typeof(UpStreamProxy));
            StringReader  stringReader;

            stringReader = new StringReader(xml);
            XmlTextReader xmlReader;

            xmlReader = new XmlTextReader(stringReader);
            UpStreamProxy configParams = (UpStreamProxy)ser.Deserialize(xmlReader);

            xmlReader.Close();
            stringReader.Close();

            return(configParams);
        }
예제 #2
0
파일: Util.cs 프로젝트: radtek/ProxyService
 public static bool ReadProxyConfig()
 {
     try
     {
         string pathOfConfigFile = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
         pathOfConfigFile = Path.Combine(pathOfConfigFile, "ProxyConfig.xml");
         string        text         = File.ReadAllText(pathOfConfigFile);
         UpStreamProxy tempUpStream = DeSerializeToUpStream(text);
         if (IsIPv4(tempUpStream.IPAddress))
         {
             if (tempUpStream.Port > 1 && tempUpStream.Port < 65535)
             {
                 ProxyConfig.UpStream = tempUpStream;
                 ProxyConfig.AssignWebProxy();
             }
         }
     }
     catch (Exception)
     {
         ProxyConfig.UpStream = null;
     }
     return(true);
 }