2010-03-24 Jb Evain <jbevain@novell.com>
[mcs.git] / class / System.ServiceModel / System.ServiceModel.Channels / HttpCookieContainerBindingElement.cs
blob52ec66fd5212e72eb6b81c6b110b8644342b25ae
1 using System;
2 using System.Net;
3 using System.ServiceModel;
5 namespace System.ServiceModel.Channels
7 public class HttpCookieContainerBindingElement : BindingElement
9 HttpCookieContainerManager manager;
11 public HttpCookieContainerBindingElement ()
13 manager = new HttpCookieContainerManager ();
16 protected HttpCookieContainerBindingElement (HttpCookieContainerBindingElement elementToBeCloned)
18 if (elementToBeCloned == null)
19 throw new ArgumentNullException ("elementToBeCloned");
21 manager = new HttpCookieContainerManager (elementToBeCloned.manager);
24 public override IChannelFactory<TChannel> BuildChannelFactory<TChannel> (BindingContext context)
26 if (context == null)
27 throw new ArgumentNullException ("context");
28 context.RemainingBindingElements.Add (this);
29 return base.BuildChannelFactory<TChannel> (context);
32 public override BindingElement Clone ()
34 return new HttpCookieContainerBindingElement (this);
37 public override T GetProperty<T> (BindingContext context)
39 if (manager is T)
40 return (T) (object) manager;
41 return context.GetInnerProperty<T> ();
45 class HttpCookieContainerManager : IHttpCookieContainerManager
47 public HttpCookieContainerManager ()
49 CookieContainer = new CookieContainer ();
52 public HttpCookieContainerManager (HttpCookieContainerManager original)
54 CookieContainer = original.CookieContainer;
57 public CookieContainer CookieContainer { get; set; }