internal bool AddEPGEntry(EPGEntry newEntry) { foreach (EPGEntry oldEntry in EPGCollection) { if (newEntry.StartTime == oldEntry.StartTime) { EPGCollection.Insert(EPGCollection.IndexOf(oldEntry), newEntry); EPGCollection.Remove(oldEntry); return(false); } else { if (newEntry.StartTime > oldEntry.StartTime && (newEntry.StartTime + newEntry.Duration) <= (oldEntry.StartTime + oldEntry.Duration)) { return(false); } if (newEntry.StartTime < oldEntry.StartTime) { EPGCollection.Insert(EPGCollection.IndexOf(oldEntry), newEntry); return(true); } } } EPGCollection.Add(newEntry); return(true); }
/// <summary> /// Add an EPG entry for the station. /// </summary> /// <param name="newEntry">The EPG entry.</param> /// <returns>True if it was added; false if it replaced an existing entry.</returns> public bool AddEPGEntry(EPGEntry newEntry) { if (newEntry == null) { throw (new ArgumentException("The new entry cannot be null", "newEntry")); } foreach (EPGEntry oldEntry in EPGCollection) { if (newEntry.StartTime == oldEntry.StartTime) { if (newEntry.EventName != null) { EPGCollection.Insert(EPGCollection.IndexOf(oldEntry), newEntry); EPGCollection.Remove(oldEntry); } return(false); } else { if (newEntry.StartTime > oldEntry.StartTime && (newEntry.StartTime + newEntry.Duration) <= (oldEntry.StartTime + oldEntry.Duration)) { return(false); } if (newEntry.StartTime < oldEntry.StartTime) { EPGCollection.Insert(EPGCollection.IndexOf(oldEntry), newEntry); return(true); } } } EPGCollection.Add(newEntry); return(true); }