예제 #1
0
        internal static bool TryKeyBinaryToString(object binaryValue, out string result)
        {
            const System.Reflection.BindingFlags Flags = System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.InvokeMethod;

            byte[] bytes = (byte[])binaryValue.GetType().InvokeMember("ToArray", Flags, null, binaryValue, null, null /* ParamModifiers */, System.Globalization.CultureInfo.InvariantCulture, null /* NamedParams */);
            return(WebConvert.TryKeyPrimitiveToString(bytes, out result));
        }
예제 #2
0
        internal static bool TryKeyPrimitiveToString(object value, out string result)
        {
            if (IsBinaryValue(value))
            {
                return(TryKeyBinaryToString(value, out result));
            }
            // Support DateTimeOffset
            if (value is DateTimeOffset)
            {
                value = ((DateTimeOffset)value).UtcDateTime;
            }
            else if (value is DateTimeOffset?)
            {
                value = ((DateTimeOffset?)value).Value.UtcDateTime;
            }

            return(WebConvert.TryKeyPrimitiveToString(value, out result));
        }