public void RemoveObject <TInterface>(TInterface instance, ObjectPath?path = null)
            where TInterface : notnull
        {
            var    fullPath     = buildFullPath(path);
            IProxy?removedProxy = null;

            syncRoot.Wait();
            try
            {
                if (managedObjects.TryGetValue(fullPath, out var proxies))
                {
                    var proxy = proxies.SingleOrDefault(x => ReferenceEquals(x.Target, instance));
                    proxies.Remove(proxy);
                    if (proxies.Count == 0)
                    {
                        managedObjects.Remove(fullPath);
                    }
                    removedProxy = proxy;
                }
            }
            finally
            {
                syncRoot.Release();
            }
            removedProxy?.Dispose();
        }
예제 #2
0
 public void Dispose()
 {
     using (Logging.Facade.InfoTraceMethodCall("Dispose"))
     {
         _implementor.Dispose();
     }
 }
예제 #3
0
 internal static void Dispose(IProxy proxy)
 {
     if (proxy != null)
     {
         proxy.Dispose();
         proxy = null;
     }
 }
 public void Dispose()
 {
     foreach (var proxies in managedObjects)
     {
         foreach (var proxy in proxies.Value)
         {
             proxy.Dispose();
         }
     }
     thisProxy.Dispose();
     syncRoot.Dispose();
 }
예제 #5
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    _proxy.Dispose();
                    _repository.Dispose();
                }

                disposedValue = true;
            }
        }
예제 #6
0
        /// <summary>
        /// Dispose this Context.
        /// </summary>
        public void Dispose()
        {
            GenericEventHandler <IReadOnlyZetboxContext> temp = Disposing;

            if (temp != null)
            {
                temp(this, new GenericEventArgs <IReadOnlyZetboxContext>()
                {
                    Data = this
                });
            }

            lock (_lock)
            {
                if (!disposed)
                {
                    proxy.Dispose();
                    DisposedAt = new StackTrace(true);
                }
                disposed = true;
            }
            // TODO: use correct Dispose implementation pattern
            GC.SuppressFinalize(this);
        }