//-----------------------------------------------------------------------
//
// Copyright (c) Andrew Arnott. All rights reserved.
//
//-----------------------------------------------------------------------
namespace DotNetOAuth.Messaging {
using System;
using System.Diagnostics;
///
/// An immutable description of a URL that receives messages.
///
[DebuggerDisplay("{AllowedMethods} {Location}")]
public class MessageReceivingEndpoint {
///
/// Initializes a new instance of the class.
///
/// The URL of this endpoint.
/// The HTTP method(s) allowed.
public MessageReceivingEndpoint(string locationUri, HttpDeliveryMethod method)
: this(new Uri(locationUri), method) { }
///
/// Initializes a new instance of the class.
///
/// The URL of this endpoint.
/// The HTTP method(s) allowed.
public MessageReceivingEndpoint(Uri location, HttpDeliveryMethod method) {
if (location == null) {
throw new ArgumentNullException("location");
}
if (method == HttpDeliveryMethod.None) {
throw new ArgumentOutOfRangeException("method");
}
if ((method & (HttpDeliveryMethod.PostRequest | HttpDeliveryMethod.GetRequest)) == 0) {
throw new ArgumentOutOfRangeException("method", MessagingStrings.GetOrPostFlagsRequired);
}
this.Location = location;
this.AllowedMethods = method;
}
///
/// Gets the URL of this endpoint.
///
public Uri Location { get; private set; }
///
/// Gets the HTTP method(s) allowed.
///
public HttpDeliveryMethod AllowedMethods { get; private set; }
}
}