Exemple #1
0
        /// <summary>
        /// Erzeugt die Beschreibung eines Eintrags aus der Programmzeitschrift und vermerkt diese
        /// in der Gesamtliste.
        /// </summary>
        /// <remarks>Wird auf einem separaten <see cref="Thread"/> ausgeführt und
        /// muss alle Zugriff auf die statischen Daten geeignet synchronisieren.</remarks>
        /// <param name="source">Die Quelle, zu der die Information gehört.</param>
        /// <param name="identifier">Die eindeutige Kennung der Sendung.</param>
        /// <param name="startTime">Anfangszeitpunkt in UTC / GMT.</param>
        /// <param name="duration">Dauer der zugehörigen Sendung.</param>
        /// <param name="descriptors">Ergänzende Beschreibungen zur Sendung.</param>
        /// <returns>Die neu erzeugte Beschreibungsinstanz.</returns>
        private void AddGuideItem(SourceIdentifier source, uint identifier, DateTime startTime, TimeSpan duration, legacy.Descriptor[] descriptors)
        {
            // First create it
            ProgramGuideItem info = CreateGuideItem(source, identifier, startTime, duration, descriptors);

            if (null == info)
            {
                return;
            }

            // Must synchronize
            lock (m_EPGItems)
            {
                // Attach to the source list
                Dictionary <DateTime, ProgramGuideItem> list;
                if (!m_EPGItems.TryGetValue(source, out list))
                {
                    // Create new
                    list = new Dictionary <DateTime, ProgramGuideItem>();

                    // Add it
                    m_EPGItems[source] = list;
                }

                // Old count
                int before = list.Count;

                // Remember
                list[startTime] = info;

                // New count
                m_EPGItemCount += (list.Count - before);
            }
        }
Exemple #2
0
        /// <summary>
        /// Meldet alle gesammelten Informationen der Programmzeitschrift.
        /// </summary>
        private ProgramGuideItem[] CreateGuideItems()
        {
            // Result
            List <ProgramGuideItem> schedules = new List <ProgramGuideItem>();

            // Lock out - actually this should not be necessary
            lock (m_EPGItems)
            {
                // Loop over all we found
                foreach (Dictionary <DateTime, ProgramGuideItem> list in m_EPGItems.Values)
                {
                    // Get all dates for one source
                    List <DateTime> dates = new List <DateTime>(list.Keys);

                    // Sort ascending
                    dates.Sort();

                    // Next allowed date
                    DateTime allowed = DateTime.MinValue;

                    // Process all dates
                    foreach (DateTime start in dates)
                    {
                        // Attach to the item
                        ProgramGuideItem info = list[start];

                        // Start is hidden
                        if (start < allowed)
                        {
                            // End is hidden - discard all
                            if (info.End <= allowed)
                            {
                                continue;
                            }

                            // Adjust duration
                            info.Duration = (int)(info.End - allowed).TotalSeconds;

                            // Adjust start
                            info.Start = allowed;
                        }

                        // Remember it
                        schedules.Add(info);

                        // Set the end as the new allowed point
                        allowed = info.End;
                    }
                }

                // Wipe out
                m_EPGItems.Clear();
            }

            // Report
            return(schedules.ToArray());
        }