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());
        }
Beispiel #2
0
        public string Invalidate(AdProvider adProvider)
        {
            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
            {
                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.Children.Clear();
            AdRotatorRoot.Children.Add((FrameworkElement)providerElement);
            return(adProvider.AdProviderType.ToString());
        }
        public string Invalidate(AdProvider adProvider)
        {
            if (adProvider == null)
            {
                adRotatorControl.GetAd(null);
                return("No Provider set");
            }
            if (adProvider.AdProviderType == AdType.None)
            {
                return(adRotatorControl.AdsFailed());
            }

            //(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
            {
                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");
            }
            Dispatcher.BeginInvoke(() =>
            {
                AdRotatorRoot.Children.Clear();
                AdRotatorRoot.Children.Add((FrameworkElement)providerElement);
                OnLog(string.Format("Displaying ads for {0}", adProvider.AdProviderType));
            });
            return(adProvider.AdProviderType.ToString());
        }