//----------------------------------------------------------------------- // // Copyright (c) Andrew Arnott. All rights reserved. // //----------------------------------------------------------------------- namespace DotNetOpenAuth.Messaging { using System; using System.Collections.Generic; using System.Linq; using System.Text; using DotNetOpenAuth.Messaging.Reflection; /// /// A message part encoder that translates between byte[] and base64web encoded strings. /// internal class Base64WebEncoder : IMessagePartEncoder { /// /// Encodes the specified value. /// /// The value. Guaranteed to never be null. /// The in string form, ready for message transport. public string Encode(object value) { return MessagingUtilities.ConvertToBase64WebSafeString((byte[])value); } /// /// Decodes the specified value. /// /// The string value carried by the transport. Guaranteed to never be null, although it may be empty. /// The deserialized form of the given string. /// Thrown when the string value given cannot be decoded into the required object type. public object Decode(string value) { return MessagingUtilities.FromBase64WebSafeString(value); } } }