示例#1
0
        /// <summary>
        /// Traces container actions through a handler.
        /// </summary>
        /// <param name="container">The target container to trace.</param>
        /// <param name="onTraceEvent">The trace handler.</param>
        /// <returns>The trace token.</returns>
        public static IToken Trace([NotNull] this IMutableContainer container, [NotNull] Action <TraceEvent> onTraceEvent)
        {
            if (container == null)
            {
                throw new ArgumentNullException(nameof(container));
            }
            if (onTraceEvent == null)
            {
                throw new ArgumentNullException(nameof(onTraceEvent));
            }

            return(new Token(
                       container,
                       container
                       .ToTraceSource()
                       .Subscribe(
                           onTraceEvent,
                           error => { },
                           () => { })));
        }