Opc.Ua.NumericRange.EnsureValid C# (CSharp) Method

EnsureValid() public method

Ensures the bounds are valid values for the object passed in.
Returns false if the object is not indexable or if the numeric range is out-of-bounds.
public EnsureValid ( object value ) : bool
value object The value to check
return bool
        public bool EnsureValid(object value)
        {
            int count = -1;

            // check for collections.
            ICollection collection = value as ICollection;

            if (collection != null)
            {
                count = collection.Count;
            }
            else
            {                
                // check for arrays.
                Array array = value as Array;
                
                if (array != null)
                {
                    count = array.Length;
                }
            }

            // ensure bounds are less than count.
            return EnsureValid(count);
        }

Same methods

NumericRange::EnsureValid ( int count ) : bool