private void AdSourcePayload_Deactivated(object sender, EventArgs e)
 {
     if (sender == ActiveSource)
     {
         ActiveSource = null;
     }
 }
        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);
            }
        }
 private void AdSourcePayload_Deactivated(object sender, EventArgs e)
 {
     if (sender == ActiveSource) ActiveSource = null;
 }
 /// <summary>
 /// Adds a child payload assumed to be playing simultaneously with the parent. This is good for companion ads.
 /// </summary>
 /// <param name="Child">The child payload whose life cycle is dependent on the partent.</param>
 public void AddChild(AdSequencingSourcePayload Child)
 {
     Child.AdSourcePayload.Deactivated += new EventHandler(Child_Deactivated);
     Children.Add(Child);
 }
 /// <summary>
 /// Adds a child payload assumed to be playing simultaneously with the parent. This is good for companion ads.
 /// </summary>
 /// <param name="Child">The child payload whose life cycle is dependent on the partent.</param>
 public void AddChild(AdSequencingSourcePayload Child)
 {
     Child.AdSourcePayload.Deactivated += new EventHandler(Child_Deactivated);
     Children.Add(Child);
 }