private static TResult Open <TResult>(PrimitiveValue value) where TResult : IConvertible
        {
            ConcreteValue <TResult> r = value as ConcreteValue <TResult>;

            if (r != null)
            {
                return(r.value);
            }

            INumber n = value as INumber;

            if (n != null)
            {
                return(n.Cast <TResult>());
            }

            throw new InvalidCastException(string.Format("Unable to convert {0} to {1}", value.ValueType, typeof(TResult)));
        }
    public static bool TryOpen <TResult>(PrimitiveValue value, out TResult v)
    {
        ConcreteValue <TResult> r = value as ConcreteValue <TResult>;

        if (r != null)
        {
            v = r.value;
            return(true);
        }

        INumber n = value as INumber;

        if (n != null)
        {
            v = n.Cast <TResult>();
            return(true);
        }

        v = default(TResult);
        return(false);
    }