SessionConfig.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //
  2. // System.Web.SessionState.SessionConfig
  3. //
  4. // Authors:
  5. // Gonzalo Paniagua Javier ([email protected])
  6. //
  7. // (C) 2003 Ximian, Inc (http://www.ximian.com)
  8. //
  9. using System;
  10. namespace System.Web.SessionState
  11. {
  12. class SessionConfig
  13. {
  14. internal SessionStateMode Mode;
  15. internal int Timeout; // minutes
  16. internal bool CookieLess;
  17. internal string StateConnectionString;
  18. internal string SqlConnectionString;
  19. public SessionConfig (object parent)
  20. {
  21. if (parent is SessionConfig) {
  22. SessionConfig p = (SessionConfig) parent;
  23. CookieLess = p.CookieLess;
  24. Mode = p.Mode;
  25. Timeout = p.Timeout;
  26. StateConnectionString = p.StateConnectionString;
  27. SqlConnectionString = p.SqlConnectionString;
  28. } else {
  29. CookieLess = false;
  30. Mode = SessionStateMode.InProc;
  31. Timeout = 20;
  32. StateConnectionString = "127.0.0.1:42424";
  33. SqlConnectionString = "user id=sa;password=;data source=127.0.0.1";
  34. }
  35. }
  36. internal bool SetMode (string value)
  37. {
  38. try {
  39. Mode = (SessionStateMode) Enum.Parse (typeof (SessionStateMode), value, true);
  40. } catch {
  41. return false;
  42. }
  43. return true;
  44. }
  45. internal bool SetCookieLess (string value)
  46. {
  47. if (value == null)
  48. return false;
  49. CookieLess = (0 == String.Compare ("true", value, true));
  50. if (!CookieLess && String.Compare ("false", value, true) != 0)
  51. return false;
  52. return true;
  53. }
  54. internal bool SetTimeout (string value)
  55. {
  56. try {
  57. Timeout = Int32.Parse (value);
  58. } catch {
  59. return false;
  60. }
  61. return true;
  62. }
  63. internal void SetStateConnectionString (string value)
  64. {
  65. StateConnectionString = value;
  66. }
  67. internal void SetSqlConnectionString (string value)
  68. {
  69. SqlConnectionString = value;
  70. }
  71. }
  72. }