Ejemplo n.º 1
0
 /// <summary>
 /// Constructs a new instance of the <see cref="TraceObserver{T}"/> class for tracing OnNext, OnError and OnCompleted calls.
 /// </summary>
 /// <param name="nextFormat">The format in which values will be traced.  A single replacement token {0} is supported.</param>
 /// <param name="errorFormat">The format in which the error will be traced.  A single replacement token {0} is supported.</param>
 /// <param name="completedMessage">The message to be traced for the completed notification.</param>
 public TraceObserver(string nextFormat, string errorFormat, string completedMessage)
     : this(TraceDefaults.GetFormatOnNext <T>(nextFormat), TraceDefaults.GetFormatOnError(errorFormat), TraceDefaults.GetMessageOnCompleted(completedMessage))
 {
     Contract.Requires(nextFormat != null);
     Contract.Requires(errorFormat != null);
     Contract.Requires(completedMessage != null);
 }
        public static IObservable <T> TraceOnError <T>(this IObservable <T> source, string format)
        {
            Contract.Requires(source != null);
            Contract.Requires(format != null);
            Contract.Ensures(Contract.Result <IObservable <T> >() != null);

            return(source.Do(new TraceObserver <T>(_ => null, TraceDefaults.GetFormatOnError(format))));
        }
Ejemplo n.º 3
0
        public static IEnumerable <T> TraceOnError <T>(this IEnumerable <T> source, TraceSource trace, string format)
        {
            Contract.Requires(source != null);
            Contract.Requires(trace != null);
            Contract.Requires(format != null);
            Contract.Ensures(Contract.Result <IEnumerable <T> >() != null);

            var enumerable = source.Do(new TraceObserver <T>(trace, _ => null, TraceDefaults.GetFormatOnError(format)));

            Contract.Assume(enumerable != null);

            return(enumerable);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Constructs a new instance of the <see cref="TraceObserver{T}"/> class for tracing OnNext and OnError calls.
 /// </summary>
 /// <param name="nextFormat">The format in which values will be traced.  A single replacement token {0} is supported.</param>
 /// <param name="errorFormat">The format in which the error will be traced.  A single replacement token {0} is supported.</param>
 public TraceObserver(string nextFormat, string errorFormat)
     : this(TraceDefaults.GetFormatOnNext <T>(nextFormat), TraceDefaults.GetFormatOnError(errorFormat))
 {
     Contract.Requires(nextFormat != null);
     Contract.Requires(errorFormat != null);
 }