/// <summary> /// Registers a /// <see cref="CookieSpecFactory">CookieSpecFactory</see> /// with the given identifier. /// If a specification with the given name already exists it will be overridden. /// This nameis the same one used to retrieve the /// <see cref="CookieSpecFactory">CookieSpecFactory</see> /// from /// <see cref="GetCookieSpec(string)">GetCookieSpec(string)</see> /// . /// </summary> /// <param name="name">the identifier for this specification</param> /// <param name="factory"> /// the /// <see cref="CookieSpecFactory">CookieSpecFactory</see> /// class to register /// </param> /// <seealso cref="GetCookieSpec(string)">GetCookieSpec(string)</seealso> public void Register(string name, CookieSpecFactory factory) { Args.NotNull(name, "Name"); Args.NotNull(factory, "Cookie spec factory"); registeredSpecs.Put(name.ToLower(Sharpen.Extensions.GetEnglishCulture()), factory ); }
/// <summary> /// Gets the /// <see cref="CookieSpec">cookie specification</see> /// with the given ID. /// </summary> /// <param name="name"> /// the /// <see cref="CookieSpec">cookie specification</see> /// identifier /// </param> /// <param name="params"> /// the /// <see cref="Apache.Http.Params.HttpParams">HTTP parameters</see> /// for the cookie /// specification. /// </param> /// <returns> /// /// <see cref="CookieSpec">cookie specification</see> /// </returns> /// <exception cref="System.InvalidOperationException">if a policy with the given name cannot be found /// </exception> public CookieSpec GetCookieSpec(string name, HttpParams @params) { Args.NotNull(name, "Name"); CookieSpecFactory factory = registeredSpecs.Get(name.ToLower(Sharpen.Extensions.GetEnglishCulture() )); if (factory != null) { return(factory.NewInstance(@params)); } else { throw new InvalidOperationException("Unsupported cookie spec: " + name); } }