Esempio n. 1
0
        public override bool IsInRange(object value)
        {
            ulong ulongValue;

            switch (value)
            {
            case bool v:
                ulongValue = v ? 1u : 0u;
                break;

            case char v:
                ulongValue = v;
                break;

            case sbyte v:
                if (v < 0)
                {
                    return(false);
                }
                ulongValue = (ulong)v;
                break;

            case byte v:
                ulongValue = v;
                break;

            case int v:
                if (v < 0)
                {
                    return(false);
                }
                ulongValue = (ulong)v;
                break;

            case uint v:
                ulongValue = v;
                break;

            case long v:
                if (v < 0)
                {
                    return(false);
                }
                ulongValue = (ulong)v;
                break;

            case ulong v:
                ulongValue = v;
                break;

            default:
                return(false);
            }

            return(TypeLimits.GetUIntRange(_bitlen).ContainsValue(ulongValue));
        }
Esempio n. 2
0
        public override bool IsInRange(object value)
        {
            long longValue;

            switch (value)
            {
            case bool v:
                longValue = v ? 1 : 0;
                break;

            case char v:
                longValue = v;
                break;

            case sbyte v:
                longValue = v;
                break;

            case byte v:
                longValue = v;
                break;

            case int v:
                longValue = v;
                break;

            case uint v:
                longValue = v;
                break;

            case long v:
                longValue = v;
                break;

            case ulong v:
                if (v > long.MaxValue)
                {
                    return(false);
                }
                longValue = (long)v;
                break;

            default:
                return(false);
            }

            return(TypeLimits.GetIntRange(_bitlen).ContainsValue(longValue));
        }
Esempio n. 3
0
        public override bool IsInRange(object value)
        {
            double doubleValue;

            switch (value)
            {
            case float v:
                doubleValue = v;
                break;

            case double v:
                doubleValue = v;
                break;

            default:
                return(false);
            }

            return(TypeLimits.GetFloatRange(_bitlen).ContainsValue(doubleValue));
        }