示例#1
0
        /// <summary>
        /// Invoked when disposing or finalizing this instance.
        /// </summary>
        /// <param name="disposing">True if the object is being disposed, false otherwise.</param>
        protected virtual void OnDispose(bool disposing)
        {
            try
            {
                _TimerDisposed = true; if (_Timer != null)
                {
                    _Timer.Stop(); _Timer.Dispose();
                }
                _Timer = null;
            }
            catch { }

            if (disposing)
            {
                try { if (_UberOperations != null)
                      {
                          DiscardChanges(); _UberOperations.Dispose();
                      }
                }
                catch { }

                try { if (_UberMaps != null)
                      {
                          ClearMaps(); _UberMaps.Dispose();
                      }
                }
                catch { }

                try { if (_TemplateLink != null)
                      {
                          _TemplateLink.Dispose();
                      }
                }
                catch { }
            }

            _UberOperations = null;
            _UberMaps       = null;
            _Link           = null;
            _TemplateLink   = null;

            _IsDisposed = true;
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance.
        /// </summary>
        /// <param name="link">The link this repository will be associated with.</param>
        public DataRepository(IDataLink link)
        {
            if (link == null)
            {
                throw new ArgumentNullException("link", "Data Link cannot be null.");
            }
            if (link.IsDisposed)
            {
                throw new ObjectDisposedException(link.ToString());
            }

            _Link         = link;
            _TemplateLink = link.Clone();

            _SerialId       = ++Uber.RepositoryLastSerial;
            _UberMaps       = new UberMapCollection(this);
            _UberOperations = new UberOperationList(this);

            if (Uber.EnableCollector)
            {
                EnableCollector();
            }
        }