ModuleItem.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //
  2. // System.Web.Configuration.ModuleItem
  3. //
  4. // Author:
  5. // Patrik Torstensson ([email protected])
  6. //
  7. using System;
  8. namespace System.Web.Configuration {
  9. class ModuleItem {
  10. private Type _type;
  11. private string _typeName;
  12. private string _name;
  13. public ModuleItem(string name, string type) {
  14. _typeName = type;
  15. _name = name;
  16. _type = Type.GetType (type, true);
  17. if (!typeof(IHttpModule).IsAssignableFrom(_type))
  18. throw new HttpException(HttpRuntime.FormatResourceString("type_not_module"));
  19. }
  20. public ModuleItem(string name, Type type) {
  21. _typeName = type.ToString ();
  22. _name = name;
  23. _type = type;
  24. if (!typeof(IHttpModule).IsAssignableFrom(_type))
  25. throw new HttpException(HttpRuntime.FormatResourceString("type_not_module"));
  26. }
  27. public IHttpModule Create() {
  28. return (IHttpModule) HttpRuntime.CreateInternalObject(_type);
  29. }
  30. public Type Type {
  31. get {
  32. return _type;
  33. }
  34. }
  35. public bool IsMatch (string name)
  36. {
  37. return (_type.Name == name || _type.FullName == name);
  38. }
  39. public string ModuleName {
  40. get {
  41. return _name;
  42. }
  43. }
  44. }
  45. }