Ejemplo n.º 1
0
        public IDisposable Using(Guid?slotId, IDisposable disposable, [CallerFilePath] string callerFilePath = null, [CallerLineNumber] int?callerLineNumber = null, [CallerMemberName] string callerMemberName = null)
        {
            IDisposable ldlProxyDisposable;

            if ((object)slotId == null)
            {
                throw new ArgumentNullException(nameof(slotId));
            }

            if ((object)disposable == null)
            {
                throw new ArgumentNullException(nameof(disposable));
            }

            if ((object)callerFilePath == null)
            {
                throw new ArgumentNullException(nameof(callerFilePath));
            }

            if ((object)callerLineNumber == null)
            {
                throw new ArgumentNullException(nameof(callerLineNumber));
            }

            if ((object)callerMemberName == null)
            {
                throw new ArgumentNullException(nameof(callerMemberName));
            }

            ldlProxyDisposable = new UsingBlockProxy(this, slotId, disposable);             // forward call to .Dispose()

            this.Slot(this.FormatCallerInfo(callerFilePath, callerLineNumber, callerMemberName), slotId, disposable, this.FormatOperation("using", slotId, disposable));

            return(ldlProxyDisposable);
        }
Ejemplo n.º 2
0
        public IDisposableDispatch <TDisposable> Using <TDisposable>(Guid?slotId, TDisposable disposable, Action onDisposal = null, [CallerFilePath] string callerFilePath = null, [CallerLineNumber] int?callerLineNumber = null, [CallerMemberName] string callerMemberName = null)
            where TDisposable : IDisposable
        {
            IDisposableDispatch <TDisposable> disposableDispatch;

            if ((object)slotId == null)
            {
                throw new ArgumentNullException(nameof(slotId));
            }

            if ((object)disposable == null)
            {
                throw new ArgumentNullException(nameof(disposable));
            }

            if ((object)callerFilePath == null)
            {
                throw new ArgumentNullException(nameof(callerFilePath));
            }

            if ((object)callerLineNumber == null)
            {
                throw new ArgumentNullException(nameof(callerLineNumber));
            }

            if ((object)callerMemberName == null)
            {
                throw new ArgumentNullException(nameof(callerMemberName));
            }

            disposableDispatch = new UsingBlockProxy <TDisposable>(this, slotId, disposable);            // forward call to .Dispose()
            disposableDispatch.SafeCreate();

            this.Slot(FormatCallerInfo(callerFilePath, callerLineNumber, callerMemberName), slotId, disposable, FormatOperation(this.ObjectIdGenerator, "using", slotId, disposable));

            return(disposableDispatch);
        }