using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace Little_System_Cleaner.Registry_Cleaner.Helpers.Backup
{
    public class RegistryEntries
    {
        private DateTime _dateTimeCreated = DateTime.Now;
        private List<RegistryEntry> _regEntries = new List<RegistryEntry>();

        public int Count
        {
            get { return this._regEntries.Count; }
        }

        [XmlAttribute("Created")]
        public long Created
        {
            get { return this._dateTimeCreated.ToBinary(); }
            set { this._dateTimeCreated = DateTime.FromBinary(value); }
        }

        [XmlArray("RegistryEntries")]
        [XmlArrayItem("RegistryEntry")]
        public List<RegistryEntry> RegEntries
        {
            get { return this._regEntries; }
            set { this._regEntries = value; }
        }

        public RegistryEntry this[int i]
        {
            get
            {
                // This indexer is very simple, and just returns or sets 
                // the corresponding element from the internal array. 
                return this.RegEntries[i];
            }
            set
            {
                this.RegEntries[i] = value;
            }
        }


        public DateTime CreatedDateTime
        {
            get { return this._dateTimeCreated; }
        }

        public RegistryEntries()
        {
        }

        public void Clear()
        {
            this.RegEntries.Clear();
        }

        public bool Contains(RegistryEntry val)
        {
            return this.RegEntries.Contains(val);
        }

        public int IndexOf(RegistryEntry val)
        {
            return this.RegEntries.IndexOf(val);
        }

        public void Add(RegistryEntry val)
        {
            this.RegEntries.Add(val);
        }
    }
}
