public void Unsubscribe(IValueObserver observer) { if (observers.Contains(observer)) { return; } observers.Remove(observer); observer.Observable = null; }
public void Subscribe(IValueObserver observer) { if (observers.Contains(observer) || observer == null) { return; } observers.Add(observer); observer.Observable = this; observer.UpdateValue(); }
public static void ObserveDuration(this IValueObserver observer, Action method) { var ts = Stopwatch.GetTimestamp(); try { method(); } finally { observer.Observe(GetDuration(ts)); } }
public static async Task <T> ObserveDurationAsync <T>(this IValueObserver observer, Func <Task <T> > method) { var ts = Stopwatch.GetTimestamp(); try { return(await method().ConfigureAwait(false)); } finally { observer.Observe(GetDuration(ts)); } }
public static T ObserveDuration <T>(this IValueObserver observer, Func <T> method) { var ts = Stopwatch.GetTimestamp(); try { return(method()); } finally { observer.Observe(GetDuration(ts)); } }
public async static Task <T> ObserveDurationAsync <T>(this IValueObserver observer, Func <Task <T> > method, DurationUnit unit = DurationUnit.Seconds) { var stopwatch = Stopwatch.StartNew(); try { return(await method().ConfigureAwait(false)); } finally { observer.Observe(GetDurationValue(stopwatch.Elapsed, unit)); } }
public static T ObserveDuration <T>(this IValueObserver observer, Func <T> method, DurationUnit unit = DurationUnit.Seconds) { var stopwatch = Stopwatch.StartNew(); try { return(method()); } finally { observer.Observe(GetDurationValue(stopwatch.Elapsed, unit)); } }
public static void ObserveDuration(this IValueObserver observer, Action method, DurationUnit unit = DurationUnit.Seconds) { var stopwatch = Stopwatch.StartNew(); try { method(); } finally { observer.Observe(GetDurationValue(stopwatch.Elapsed, unit)); } }
public static async Task ObserveDurationAsync(this IValueObserver observer, Func <Task> method, DurationUnit unit) { var stopwatch = Stopwatch.StartNew(); try { await method().ConfigureAwait(false); } finally { observer.Observe(GetDurationValue(stopwatch.Elapsed, unit)); } }
public static async Task ObserveDurationAsync(this IValueObserver observer, Func <Task> method, DurationUnit unit = DurationUnit.Seconds) { var ts = Stopwatch.GetTimestamp(); try { await method().ConfigureAwait(false); } finally { observer.Observe(GetDuration(ts, unit)); } }
public static void ObserveDuration(this IValueObserver observer, Action method, DurationUnit unit = DurationUnit.Seconds) { var ts = Stopwatch.GetTimestamp(); try { method(); } finally { observer.Observe(GetDuration(ts, unit)); } }
public static Task <T> ObserveDurationAsync <T>(this IValueObserver observer, Func <Task <T> > method) { return(ObserveDurationAsync(observer, method, DurationUnit.Seconds)); }
public static T ObserveDuration <T>(this IValueObserver observer, Func <T> method) { return(ObserveDuration(observer, method, DurationUnit.Seconds)); }
public static void ObserveDuration(this IValueObserver observer, Action method) { ObserveDuration(observer, method, DurationUnit.Seconds); }
public static void Observe(this IValueObserver observer, double val, DateTimeOffset timestamp) { observer.Observe(val, timestamp.ToUnixTime()); }