private AdSequencingSourcePayload TriggerAdSequencingSource(IAdSequencingSource Source)
        {
            IAdPayload payload = null;

#if !WINDOWS_PHONE && !SILVERLIGHT3
            var plugins = PayloadHandlers.Where(i => Source.Format.ToLower() == i.Metadata.SupportedFormat.ToLower());
#else
            var plugins = PayloadHandlers.Where(i => i.LooseMetadata.ContainsKey("SupportedFormat") && (((string)i.LooseMetadata["SupportedFormat"]).ToLower() == Source.Format.ToLower()));
#endif
            var handlers = plugins.Select(i => i.Value);

            foreach (var payloadHandler in handlers)
            {
                payload = payloadHandler.Handle(Source);
                if (payload != null)
                {
                    break;
                }
            }

            if (payload != null)
            {
                var result = new AdSequencingSourcePayload(payload);
                foreach (var child in Source.Sources)
                {
                    var childResult = TriggerAdSequencingSource(child);
                    if (childResult != null)
                    {
                        result.AddChild(childResult);
                    }
                }
                return(result);
            }
            else
            {
                // pass this info upstream
                player.OnAdFailed(Source);
                return(null);
            }
        }
 /// <summary>
 /// Creates a new payload for a single ad source.
 /// </summary>
 /// <param name="AdSourcePayload">The payload that came from the ad handler</param>
 public AdSequencingSourcePayload(IAdPayload AdSourcePayload)
 {
     adSourcePayload = AdSourcePayload;
     adSourcePayload.Deactivated += new EventHandler(AdSourcePayload_Deactivated);
 }
 private void payload_Deactivated(object sender, EventArgs e)
 {
     Payload = null;
     OnDeactivate();
 }
 private void payload_Deactivated(object sender, EventArgs e)
 {
     Payload = null;
     OnDeactivate();
 }
 /// <summary>
 /// Creates a new payload for a single ad source.
 /// </summary>
 /// <param name="AdSourcePayload">The payload that came from the ad handler</param>
 public AdSequencingSourcePayload(IAdPayload AdSourcePayload)
 {
     adSourcePayload              = AdSourcePayload;
     adSourcePayload.Deactivated += new EventHandler(AdSourcePayload_Deactivated);
 }