Beispiel #1
0
        /// <summary>Compare class value with the value of the second class</summary>
        /// <param name="other">Class whose value we are comparing with</param>
        /// <returns>less then 0 if if parameter is less then, 0 if paramater is equal and greater then 0 if parameter is greater then the class value</returns>
        public int CompareTo(Counter64 other)
        {
            if (other == null)
            {
                return(-1);
            }

            return(value.CompareTo(other.Value));
        }
Beispiel #2
0
        /// <summary>SET class value from another Counter64 class cast as <seealso cref="AsnType"/>.</summary>
        /// <param name="value">Counter64 class cast as <seealso cref="AsnType"/></param>
        /// <exception cref="ArgumentException">Argument is not Counter64 type.</exception>
        public void Set(AsnType value)
        {
            Counter64 val = value as Counter64;

            if (val != null)
            {
                this.value = val.Value;
            }
            else
            {
                throw new ArgumentException("Invalid argument type.");
            }
        }
Beispiel #3
0
        /// <summary>Return difference between two Counter64 values taking counter roll-over into account.</summary>
        /// <param name="first">First or older value</param>
        /// <param name="second">Second or newer value</param>
        /// <returns>Difference between the two values</returns>
        public static ulong Diff(Counter64 first, Counter64 second)
        {
            ulong f   = first.Value;
            ulong s   = second.Value;
            ulong res = 0;

            if (s > f)
            {
                // in case of a roll-over event
                res = (ulong.MaxValue - f) + s;
            }
            else
            {
                res = s - f;
            }

            return(res);
        }
Beispiel #4
0
 /// <summary>Constructor</summary>
 /// <param name="value">Copy value</param>
 public Counter64(Counter64 value)
     : this()
 {
     this.value = value.Value;
 }