SessionConfig.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. internal string StateNetworkTimeout;
  20. public SessionConfig (object parent)
  21. {
  22. if (parent is SessionConfig) {
  23. SessionConfig p = (SessionConfig) parent;
  24. CookieLess = p.CookieLess;
  25. Mode = p.Mode;
  26. Timeout = p.Timeout;
  27. StateConnectionString = p.StateConnectionString;
  28. SqlConnectionString = p.SqlConnectionString;
  29. } else {
  30. CookieLess = false;
  31. Mode = SessionStateMode.InProc;
  32. Timeout = 20;
  33. StateConnectionString = "127.0.0.1:42424";
  34. SqlConnectionString = "user id=sa;password=;data source=127.0.0.1";
  35. }
  36. }
  37. internal bool SetMode (string value)
  38. {
  39. try {
  40. Mode = (SessionStateMode) Enum.Parse (typeof (SessionStateMode), value, true);
  41. } catch {
  42. return false;
  43. }
  44. return true;
  45. }
  46. internal bool SetCookieLess (string value)
  47. {
  48. if (value == null)
  49. return false;
  50. CookieLess = (0 == String.Compare ("true", value, true));
  51. if (!CookieLess && String.Compare ("false", value, true) != 0)
  52. return false;
  53. return true;
  54. }
  55. internal bool SetTimeout (string value)
  56. {
  57. try {
  58. Timeout = Int32.Parse (value);
  59. } catch {
  60. return false;
  61. }
  62. return true;
  63. }
  64. internal void SetStateConnectionString (string value)
  65. {
  66. StateConnectionString = value;
  67. }
  68. internal void SetSqlConnectionString (string value)
  69. {
  70. SqlConnectionString = value;
  71. }
  72. internal void SetStateNetworkTimeout (string value)
  73. {
  74. StateNetworkTimeout = value;
  75. }
  76. }
  77. }