private void OnTextureDataDownload(System.Object sender, DownloadDataCompletedEventArgs e) { Logger.Log(this, "OnImageDownloaded: Entered"); if (e.Cancelled) { String errorMesage = "Image Load. Request Cancelled."; InternalAdLoadFailedArgs args = new InternalAdLoadFailedArgs(1, errorMesage); adListener.OnAdLoadFailed(args); //AnalyticsWebManager.Push(new AdEventDTO(this.adUnitId, AdEventDTO.EventType.AdResourceDownloadFailed, errorMesage), AnalyticsWebWrapperDTO.Action.AdEvent, AnalyticsWebManager.PRIORITY.HIGH); return; } if (e.Error != null) { String errorMessage = e.Error.Message; InternalAdLoadFailedArgs args = new InternalAdLoadFailedArgs(2, errorMessage); adListener.OnAdLoadFailed(args); //AnalyticsWebManager.Push(new AdEventDTO(this.adUnitId, AdEventDTO.EventType.AdResourceDownloadFailed, errorMessage), AnalyticsWebWrapperDTO.Action.AdEvent, AnalyticsWebManager.PRIORITY.HIGH); return; } byte[] data = e.Result; IPlatformObjectsFactory factory = PlatformObjectsFactoryHolder.GetFactory(); this.textureObject = factory.GetTextureObject(); bool result = this.textureObject.CreateTextureObject(data); if (!result) //client couldn't create the texture object { } adListener.OnAdLoaded(this); //AnalyticsWebManager.Push(new AdEventDTO(this.adUnitId, AdEventDTO.EventType.AdResourceDownloadSuccess, ""), AnalyticsWebWrapperDTO.Action.AdEvent, AnalyticsWebManager.PRIORITY.HIGH); }
public void DownloadTextureData() { WebClient imageLoadWebClient = new WebClient(); imageLoadWebClient.DownloadDataCompleted += OnTextureDataDownload; Uri uri = new Uri(textureImageUrl); try { imageLoadWebClient.DownloadDataAsync(uri); } catch (System.Net.WebException excp) { String errorMessage = "Web Exception"; InternalAdLoadFailedArgs args = new InternalAdLoadFailedArgs(1, errorMessage); adListener.OnAdLoadFailed(args); Console.WriteLine("Exception caught: {0}", excp); } catch (ArgumentNullException excp) { String errorMessage = "Null arguement exception"; InternalAdLoadFailedArgs args = new InternalAdLoadFailedArgs(1, errorMessage); adListener.OnAdLoadFailed(args); Console.WriteLine("Exception caught: {0}", excp); } }