public void Created(DisposableWrapper wrapper, out int id)
 {
     id = Interlocked.Increment(ref _nextId);
     _all.TryAdd(id, new DisposableInfoImpl(wrapper, id));
     _types.AddOrUpdate(wrapper.GetType(), 1, (i, value) => value + 1);
     _locations.AddOrUpdate(new CustomTrace(wrapper.StackTrace), 1, (i, value) => value + 1);
     LogWrapperEvent(wrapper, id, "Created", true);
 }
 public DisposableInfoImpl(DisposableWrapper wrapper, int id)
 {
     TraceId     = id;
     WrapperType = wrapper.GetType();
     if (wrapper is IDebugDisposable)
     {
         _item = new WeakReference <IDebugDisposable>((IDebugDisposable)wrapper);
     }
 }
        private void LogWrapperEvent(DisposableWrapper wrapper, int id, string name, bool stack)
        {
            IDebugDisposable debug = wrapper as IDebugDisposable;

            Logger.Instance.TraceExtra(typeof(DisposableTracerFull), "{0}: {1}, disposed={2}, release={3}{4}", name, id,
                                       debug?.IsDisposed,
                                       (wrapper as IComWrapper)?.MustRelease,
                                       stack ? ("\n" + new CustomTrace(new StackTrace(2, true)).ToString()) : "");
        }
        public void Deleted(DisposableWrapper wrapper, bool wasDisposed)
        {
            if (!wasDisposed)
            {
                DisposedInternal(wrapper);
            }

            DisposableInfo dummy;

            _all.TryRemove(wrapper.TraceId, out dummy);
            LogWrapperEvent(wrapper, wrapper.TraceId, "Deleted", true);
        }
Esempio n. 5
0
 public void Disposed(DisposableWrapper wrapper)
 {
 }
Esempio n. 6
0
 public void Deleted(DisposableWrapper wrapper, bool wasDisposed)
 {
 }
Esempio n. 7
0
 public void Created(DisposableWrapper wrapper, out int id)
 {
     id = -1;
 }
 private void DisposedInternal(DisposableWrapper wrapper)
 {
     _types.AddOrUpdate(wrapper.GetType(), 0, (i, value) => value - 1);
     _locations.AddOrUpdate(new CustomTrace(wrapper.StackTrace), 0, (i, value) => value - 1);
 }
 public void Disposed(DisposableWrapper wrapper)
 {
     LogWrapperEvent(wrapper, wrapper.TraceId, "Disposed", true);
     DisposedInternal(wrapper);
 }