Example #1
0
        /// <summary>
        /// Serializes the specified timers to the <c>Timers.xml</c> file.
        /// </summary>
        /// <param name="timers">The collection of timers which will be serialized.</param>
        private static void SerializeTimers(TimersCollection timers)
        {
            using (Stream stream = OpenTimersXmlFile())
            {
                stream.SetLength(0);

                DataContractSerializer serializer = CreateSerializer();
                serializer.WriteObject(stream, timers);
            }
        }
Example #2
0
        /// <summary>
        /// Persists the specified timers to the store.
        /// </summary>
        /// <param name="timers">The timers to persist.</param>
        public void PersistTimers(IEnumerable <Timer> timers)
        {
            if (timers == null)
            {
                throw new ArgumentNullException("timers");
            }

            var timersCollection = new TimersCollection();

            timersCollection.AddRange(timers);

            SerializeTimers(timersCollection);
        }