Utils.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /**
  2. * Namespace: System.Web.UI
  3. * Class: Utils
  4. *
  5. * Author: Gaurav Vaish
  6. * Maintainer-> [email protected]
  7. * Implementation: yes
  8. * Contact: <[email protected]>
  9. * Status: ??%
  10. *
  11. * (C) Gaurav Vaish (2001)
  12. */
  13. using System;
  14. using System.Collections;
  15. using System.Web;
  16. using System.Reflection;
  17. namespace System.Web.UI
  18. {
  19. internal class Utils
  20. {
  21. internal static object InvokeMethod(MethodInfo info, object obj, object[] parameters)
  22. {
  23. object retVal = null;
  24. try
  25. {
  26. retVal = info.Invoke(obj, parameters);
  27. } catch(TargetInvocationException tie)
  28. {
  29. throw tie.InnerException;
  30. }
  31. return retVal;
  32. }
  33. internal static string GetClientValidatedEvent(Page page)
  34. {
  35. return "if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate();";
  36. }
  37. internal static string GetClientValidatedPostBack(Control control)
  38. {
  39. return (" { if (typeof(Page_ClientValidate) != 'function' || Page_ClientValidate()) " +
  40. control.Page.GetPostBackEventReference(control) +
  41. " } " );
  42. }
  43. [MonoTODO]
  44. internal static string GetScriptLocation(HttpContext context)
  45. {
  46. IDictionary dict = context.GetConfig("system.web/webControls")
  47. as IDictionary;
  48. string loc = null;
  49. if(dict != null)
  50. {
  51. loc = dict["clientScriptsLocation"] as string;
  52. }
  53. if(loc == null)
  54. {
  55. throw new HttpException("Missing_clientScriptsLocation");
  56. }
  57. if(loc.IndexOf("{0}") > 0)
  58. {
  59. //FIXME: Version Number of the ASP.Net should come into play.
  60. //Like if ASP 1.0 and 1.1 both are installed, the script
  61. // locations are in /aspnet_client/system_web/1_0_3705_0/
  62. // and /aspnet_client/system_web/1_1_4322/
  63. // (these entries are from my machine
  64. // So, first I should get this Version Info from somewhere
  65. loc = String.Format(loc, "system_web");
  66. }
  67. return loc;
  68. }
  69. }
  70. }