SiteMapProviderCollection.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //
  2. // System.Web.SiteMapProviderCollection
  3. //
  4. // Authors:
  5. // Ben Maurer ([email protected])
  6. //
  7. // (C) 2003 Ben Maurer
  8. //
  9. #if NET_1_2
  10. using System.Collections;
  11. using System.Collections.Specialized;
  12. using System.Text;
  13. using System.Configuration.Provider;
  14. using System.Web.UI;
  15. namespace System.Web {
  16. public class SiteMapProviderCollection : ProviderCollection
  17. {
  18. public SiteMapProviderCollection () {}
  19. public override void Add (IProvider provider)
  20. {
  21. if (provider == null)
  22. throw new ArgumentNullException ("provider");
  23. if ((provider as ISiteMapProvider) == null)
  24. throw new InvalidOperationException(String.Format ("{0} must implement {1} to act as a site map provider", provider.GetType (), typeof (ISiteMapProvider)));
  25. base.Add (provider);
  26. }
  27. public virtual void AddArray (IProvider[] providerArray)
  28. {
  29. foreach (IProvider p in providerArray) {
  30. if (this [p.Name] != null)
  31. throw new ArgumentException ("Duplicate site map providers");
  32. Add (p);
  33. }
  34. }
  35. public ISiteMapProvider this [string name] { get { return (ISiteMapProvider) base [name]; } }
  36. }
  37. }
  38. #endif