private void CheckTvInitialized(TvDiscovery.Tv2014InitInfo tv)
 {
     try
     {
         HttpMessage httpMessages  = new HttpMessage(tv.ServiceUri);
         HttpMessage httpMessages1 = this.transport.SendRequest(httpMessages);
         if (!string.IsNullOrEmpty(httpMessages1.Content))
         {
             if (JObject.Parse(httpMessages1.Content) != null)
             {
                 this.foundTvs.Remove(tv);
                 this.devicePool.Add(tv.DeviceInfo);
             }
             else
             {
                 return;
             }
         }
     }
     catch (WebException webException)
     {
     }
     catch (JsonException jsonException)
     {
     }
 }
 private void upnpDiscovery_DeviceDisconnected(object sender, DeviceInfoEventArgs e)
 {
     TvDiscovery.Tv2014InitInfo tv2014InitInfo = this.foundTvs.Find((TvDiscovery.Tv2014InitInfo arg) => arg.DeviceInfo.UniqueServiceName == e.DeviceInfo.UniqueServiceName);
     if (tv2014InitInfo != null)
     {
         this.foundTvs.Remove(tv2014InitInfo);
     }
     this.devicePool.Remove(e.DeviceInfo.UniqueServiceName);
 }
 private void upnpDiscovery_DeviceConnected(object sender, DeviceInfoEventArgs e)
 {
     Logger.Instance.LogMessageFormat("[SmartView2][TvDiscovery]upnpDiscovery_DeviceConnected started... ", new object[0]);
     if (e.DeviceInfo.DeviceType != "urn:dial-multiscreen-org:device:dialreceiver:1")
     {
         Logger   instance   = Logger.Instance;
         object[] deviceType = new object[] { e.DeviceInfo.DeviceType, e.DeviceInfo.DeviceAddress };
         instance.LogMessageFormat("[SmartView2][TvDiscovery]upnpDiscovery_DeviceConnected Device is not Dial Receiver, TV type is {0}, with address: {1}.", deviceType);
         return;
     }
     TvDiscovery.Tv2014InitInfo tv2014Data = TvDiscovery.GetTv2014Data(e.DeviceInfo);
     if (tv2014Data != null)
     {
         Logger.Instance.LogMessageFormat("[SmartView2][TvDiscovery]upnpDiscovery_DeviceConnected TV 2014 found.", new object[0]);
         this.foundTvs.Add(tv2014Data);
         return;
     }
     Logger.Instance.LogMessageFormat("[SmartView2][TvDiscovery]upnpDiscovery_DeviceConnected Earlier TV found", new object[0]);
     this.devicePool.Add(e.DeviceInfo);
 }
 private static TvDiscovery.Tv2014InitInfo GetTv2014Data(DeviceInfo deviceInfo)
 {
     TvDiscovery.Tv2014InitInfo tv2014InitInfo;
     using (TextReader stringReader = new StringReader(deviceInfo.SourceXml))
     {
         XmlDocument xmlDocument = new XmlDocument();
         xmlDocument.Load(stringReader);
         XmlNodeList elementsByTagName = xmlDocument.GetElementsByTagName("Capability", "http://www.sec.co.kr/dlna");
         if (elementsByTagName == null || elementsByTagName.Count == 0)
         {
             tv2014InitInfo = null;
         }
         else
         {
             foreach (XmlElement xmlElement in elementsByTagName)
             {
                 if (xmlElement.GetAttribute("name") != "samsung:multiscreen:1")
                 {
                     continue;
                 }
                 UriBuilder uriBuilder = new UriBuilder(deviceInfo.DeviceAddress)
                 {
                     Port = int.Parse(xmlElement.GetAttribute("port")),
                     Path = xmlElement.GetAttribute("location")
                 };
                 TvDiscovery.Tv2014InitInfo tv2014InitInfo1 = new TvDiscovery.Tv2014InitInfo()
                 {
                     DeviceInfo = deviceInfo,
                     ServiceUri = uriBuilder.Uri
                 };
                 tv2014InitInfo = tv2014InitInfo1;
                 return(tv2014InitInfo);
             }
             return(null);
         }
     }
     return(tv2014InitInfo);
 }
 private void FindInitializedDevices()
 {
     TvDiscovery.Tv2014InitInfo[] array = new TvDiscovery.Tv2014InitInfo[0];
     array = this.foundTvs.ToArray <TvDiscovery.Tv2014InitInfo>();
     Parallel.ForEach <TvDiscovery.Tv2014InitInfo>(array, (TvDiscovery.Tv2014InitInfo tv) => this.CheckTvInitialized(tv));
 }