Exemplo n.º 1
0
        public void OnDeserialization(object sender)
        {
            ItemType[] serializedItems;
            lock (this)
            {
                serializedItems = _items.ToArray();
                _items.Clear();
            }

            foreach (ItemType item in serializedItems)
            {// Resubscribe for events etc.
                Add(item);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Will clear class filters and sinks (or optionaly also remove them).
        /// </summary>
        /// <param name="completeClear">Will also remove the sinks and filters. Pass false to only clear them.</param>
        public void Clear(bool completeClear)
        {
            ITracerItemSink[] sinks;
            lock (this)
            {
                sinks = _itemSinks.ToArray();
            }

            foreach (ITracerItemSink sink in sinks)
            {
                sink.Clear();
                if (completeClear)
                {
                    sink.Dispose();
                }
            }

            if (completeClear)
            {
                lock (this)
                {
                    _itemSinks.Clear();
                    _filters.Clear();
                }
            }

            if (TracerClearedEvent != null)
            {
                TracerClearedEvent(this, completeClear);
            }
        }