Ejemplo n.º 1
0
        /// <summary>Converts the specified value to a serializable string in ATOM format, or throws an exception if the value cannot be converted.</summary>
        /// <param name="value">Non-null value to convert.</param>
        /// <returns>The specified value converted to an ATOM string.</returns>
        internal static string ConvertPrimitiveToString(object value)
        {
            DebugUtils.CheckNoExternalCallers();

            string result;

            if (!TryConvertPrimitiveToString(value, out result))
            {
                throw new ODataException(Strings.AtomValueUtils_CannotConvertValueToAtomPrimitive(value.GetType().FullName));
            }

            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Converts the given value to the ATOM string representation
        /// and uses the writer to write it.
        /// </summary>
        /// <param name="writer">The writer to write the stringified value.</param>
        /// <param name="value">The value to be written.</param>
        internal static void WritePrimitiveValue(XmlWriter writer, object value)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(value != null, "value != null");

            if (!PrimitiveConverter.Instance.TryWriteAtom(value, writer))
            {
                string result;
                if (!TryConvertPrimitiveToString(value, out result))
                {
                    throw new ODataException(Strings.AtomValueUtils_CannotConvertValueToAtomPrimitive(value.GetType().FullName));
                }

                ODataAtomWriterUtils.WriteString(writer, result);
            }
        }