Example #1
0
        private static bool HasAttribute <T>(HystrixRollingNumberEvent hystrixRollingNumberEvent)
        {
            var type       = typeof(HystrixRollingNumberEvent);
            var memInfo    = type.GetMember(hystrixRollingNumberEvent.ToString());
            var attributes = memInfo[0].GetCustomAttributes(typeof(T), false);

            return(attributes.Length > 0);
        }
 public LongAdder GetAdder(HystrixRollingNumberEvent type)
 {
     if (!HystrixRollingNumberEventHelper.IsCounter(type))
     {
         throw new InvalidOperationException("Type is not a Counter: " + type.ToString());
     }
     return(adderForCounterType[(int)type]);
 }
 public long Get(HystrixRollingNumberEvent type)
 {
     if (HystrixRollingNumberEventHelper.IsCounter(type))
     {
         return(adderForCounterType[(int)type].Sum());
     }
     if (HystrixRollingNumberEventHelper.IsMaxUpdater(type))
     {
         return(updaterForCounterType[(int)type].Max);
     }
     throw new InvalidOperationException("Unknown type of event: " + type.ToString());
 }
            public LongMaxUpdater GetMaxUpdater(HystrixRollingNumberEvent type)
            {
                if (!HystrixRollingNumberEventHelper.IsMaxUpdater(type))
                {
                    throw new InvalidOperationException("Type is not a MaxUpdater: " + type.ToString());
                }

                return _updaterForCounterType[(int)type];
            }