Files
mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpCookieContainerBindingElement.cs
T
Atsushi Eno ad860bce0a 2010-01-13 Astushi Enomoto <[email protected]>
* net_2_1_raw_System.ServiceModel.dll.sources :
	  add HttpCookieContainerBindingElement.cs.

	* HttpCookieContainerBindingElement.cs : new.
	* IHttpCookieContainer.cs : fix type name.
	* HttpRequestChannel.cs, HttpChannelFactory.cs : support above.

	* BasicHttpBinding.cs : add SL3 EnableHttpCookieContainer support.


svn path=/trunk/mcs/; revision=149435
2010-01-13 08:13:43 +00:00

60 lines
1.5 KiB
C#

using System;
using System.Net;
using System.ServiceModel;
namespace System.ServiceModel.Channels
{
public class HttpCookieContainerBindingElement : BindingElement
{
HttpCookieContainerManager manager;
public HttpCookieContainerBindingElement ()
{
manager = new HttpCookieContainerManager ();
}
protected HttpCookieContainerBindingElement (HttpCookieContainerBindingElement elementToBeCloned)
{
if (elementToBeCloned == null)
throw new ArgumentNullException ("elementToBeCloned");
manager = new HttpCookieContainerManager (elementToBeCloned.manager);
}
public override IChannelFactory<TChannel> BuildChannelFactory<TChannel> (BindingContext context)
{
if (context == null)
throw new ArgumentNullException ("context");
context.RemainingBindingElements.Add (this);
return base.BuildChannelFactory<TChannel> (context);
}
public override BindingElement Clone ()
{
return new HttpCookieContainerBindingElement (this);
}
public override T GetProperty<T> (BindingContext context)
{
if (manager is T)
return (T) (object) manager;
return context.GetInnerProperty<T> ();
}
}
class HttpCookieContainerManager : IHttpCookieContainerManager
{
public HttpCookieContainerManager ()
{
CookieContainer = new CookieContainer ();
}
public HttpCookieContainerManager (HttpCookieContainerManager original)
{
CookieContainer = original.CookieContainer;
}
public CookieContainer CookieContainer { get; set; }
}
}