public void Intercept(IInvocation invocation)
        {
            AssertIsNotDesposed();

            string methodName = invocation.Method.Name;

            // Early out if it'a call to Dispose()
            if (methodName == nameof(IDisposable.Dispose))
            {
                _wrapperClient.Dispose();
                _isDisposed = true;
                return;
            }

            object[] parameters     = invocation.Arguments;
            Type[]   parameterTypes = invocation.Method.GetParameters().Select(x => x.ParameterType).ToArray();
            Type     returnType     = invocation.Method.ReturnType;

            var dllImportAttribute = GetLegacyAttribute <LegacyDllImportAttribute>(_interfaceType);
            var dllMethodAttribute = GetLegacyAttribute <LegacyDllMethodAttribute>(invocation.Method);

            string libraryName = dllImportAttribute.LibraryName;

            if (OverrideLibraryName != null)
            {
                libraryName = OverrideLibraryName;
            }

            invocation.ReturnValue = _wrapperClient.InvokeInternal(libraryName, methodName, parameters, parameterTypes, returnType, dllMethodAttribute);
        }
        protected virtual void Dispose(bool disposing)
        {
            if (_isDisposed)
            {
                return;
            }

            if (disposing)
            {
                _wrapperClient.Dispose();
                // Free any other managed objects here.
                //
            }

            // Free any unmanaged objects here.
            //
            _isDisposed = true;
        }