Exemple #1
0
 private void OnListChange()
 {
     if (this.WriteDelayMs > 0)
     {
         if (DateTime.UtcNow >= LastSerialize.AddMilliseconds(this.WriteDelayMs))
         {
             this.LastSerialize = DateTime.UtcNow;
             _List.XmlSerialize(this.FilePathName);
         }
     }
     else
     {
         _List.XmlSerialize(this.FilePathName);
     }
 }
Exemple #2
0
        public SerializeableSortableBindingList(string filePathName, int writeDelayMs)
        {
            try
            {
                this.FilePathName  = AssemblyPath + "\\" + filePathName;
                this.LastSerialize = DateTime.MinValue;

                this._List        = new SortableBindingList <T>();
                this.WriteDelayMs = writeDelayMs;

                if (!File.Exists(this.FilePathName))
                {
                    _List = new SortableBindingList <T>();

                    _List.XmlSerialize(this.FilePathName);
                    _List.XmlDeserialize(this.FilePathName);
                }
                else
                {
                    this._List = _List.XmlDeserialize(this.FilePathName);
                }

                if (_List != null)
                {
                    this._List.ListChanged += OnListChangeHandler;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("[SerializeableSortableBindingList] Exception [" + ex + "]");
            }
        }
Exemple #3
0
        public SerializeableSortableBindingList(string filePathName, int writeDelayMs)
        {
            this.FilePathName  = AssemblyPath + "\\" + filePathName;
            this.LastSerialize = DateTime.MinValue;
            this.FileName      = Path.GetFileName(this.FilePathName);

            this._List        = new SortableBindingList <T>();
            this.WriteDelayMs = writeDelayMs;

            if (!File.Exists(this.FilePathName))
            {
                _List = new SortableBindingList <T>();

                _List.XmlSerialize(this.FilePathName);
                _List.XmlDeserialize(this.FilePathName);
            }
            else
            {
                this._List = _List.XmlDeserialize(this.FilePathName);
            }
            this._List.ListChanged += OnListChangeHandler;
        }