//-----------------------------------------------------------------------
//
// Copyright (c) Outercurve Foundation. All rights reserved.
//
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.OpenId.ChannelElements {
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DotNetOpenAuth.Messaging.Reflection;
///
/// A Uri encoder that serializes using
/// rather than the standard .
///
internal class OriginalStringUriEncoder : IMessagePartEncoder {
#region IMessagePartEncoder Members
///
/// Encodes the specified value.
///
/// The value. Guaranteed to never be null.
///
/// The in string form, ready for message transport.
///
public string Encode(object value) {
Uri uriValue = (Uri)value;
return uriValue != null ? uriValue.OriginalString : null;
}
///
/// 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 value != null ? new Uri(value) : null;
}
#endregion
}
}