public async Task <string> Invalidate(AdProvider adProvider) { if (!IsAdRotatorEnabled) { OnLog(AdRotatorControlID, "Control is not enabled"); return("Control Disabled"); } if (adProvider == null) { adRotatorControl.GetAd(null); return("No Provider set"); } if (adProvider.AdProviderType == AdType.None) { return(adRotatorControl.AdsFailed()); } if (SlidingAdDirection != AdSlideDirection.None && !_slidingAdTimerStarted) { _slidingAdTimerStarted = true; ResetSlidingAdTimer(SlidingAdDisplaySeconds); } //(SJ) should we make this call the GetAd function? or keep it seperate //Isn't the aim of the GetAd function to return an ad to display or would this break other implementations? object providerElement = null; try { if (adProvider.AdProviderType == AdType.DefaultHouseAd) { var defaultHouseAd = new DefaultHouseAd(AdRotatorControlID, fileHelper); //houseAd.AdLoaded += (s, e) => adRotatorControl.OnAdAvailable(AdType.DefaultHouseAd); defaultHouseAd.AdLoadingFailed += (s, e) => adRotatorControl.AdFailed(AdType.DefaultHouseAd); defaultHouseAd.AdClicked += (s, e) => OnDefaultHouseAdClicked(); var defaultHouseAdBody = string.IsNullOrEmpty(adProvider.SecondaryId) ? DefaultHouseAdBody : adProvider.SecondaryId; var defaultHouseAdURI = string.IsNullOrEmpty(adProvider.AppId) ? DefaultHouseAdURI : adProvider.AppId; providerElement = await defaultHouseAd.Initialise(defaultHouseAdBody, defaultHouseAdURI); } else { providerElement = adRotatorControl.GetProviderFrameworkElement(CurrentPlatform, adProvider); } } catch { adRotatorControl.AdFailed(adProvider.AdProviderType); return("Ad Failed to initialise"); } if (providerElement == null) { adRotatorControl.AdFailed(adProvider.AdProviderType); return("No Ad Returned"); } AdRotatorRoot.Child = null; AdRotatorRoot.Child = (FrameworkElement)providerElement; return(adProvider.AdProviderType.ToString()); }
private object CreateDefaultHouseAdControl() { var defaultHouseAd = new DefaultHouseAd(); defaultHouseAd.Width = AdWidth; defaultHouseAd.Height = AdHeight; ((DefaultHouseAd)defaultHouseAd).AdClicked += new DefaultHouseAd.OnAdClicked(defaultHouseAd_AdClicked); ((DefaultHouseAd)defaultHouseAd).AdLoaded += new DefaultHouseAd.OnAdLoaded(defaultHouseAd_AdLoaded); ((DefaultHouseAd)defaultHouseAd).AdLoadingFailed += new DefaultHouseAd.OnAdFailed(defaultHouseAd_AdLoadingFailed); defaultHouseAd.GetDefaultHouseAd(DefaultHouseAdBody, DefaultHouseAdURI); if (defaultHouseAd == null || !defaultHouseAd.isValid) { OnLog(string.Format("No Default HouseAd Config available")); return new Model.NoneProvider(); } else { OnLog(string.Format("DefaultHouseAd Created")); return defaultHouseAd; } }