Exemple #1
0
        public void Unsubscribe(IValueObserver observer)
        {
            if (observers.Contains(observer))
            {
                return;
            }

            observers.Remove(observer);
            observer.Observable = null;
        }
Exemple #2
0
        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));
            }
        }
Exemple #6
0
        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));
            }
        }
Exemple #7
0
        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));
            }
        }
Exemple #8
0
        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));
            }
        }
Exemple #9
0
        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));
            }
        }
Exemple #10
0
        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));
            }
        }
Exemple #11
0
        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));
            }
        }
Exemple #12
0
 public static Task <T> ObserveDurationAsync <T>(this IValueObserver observer, Func <Task <T> > method)
 {
     return(ObserveDurationAsync(observer, method, DurationUnit.Seconds));
 }
Exemple #13
0
 public static T ObserveDuration <T>(this IValueObserver observer, Func <T> method)
 {
     return(ObserveDuration(observer, method, DurationUnit.Seconds));
 }
Exemple #14
0
 public static void ObserveDuration(this IValueObserver observer, Action method)
 {
     ObserveDuration(observer, method, DurationUnit.Seconds);
 }
Exemple #15
0
 public static void Observe(this IValueObserver observer, double val, DateTimeOffset timestamp)
 {
     observer.Observe(val, timestamp.ToUnixTime());
 }