SessionConfig.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. // Copyright (C) 2005-2006 Novell, Inc (http://www.novell.com)
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. namespace System.Web.SessionState
  30. {
  31. class SessionConfig
  32. {
  33. internal SessionStateMode Mode;
  34. internal int Timeout; // minutes
  35. internal bool CookieLess;
  36. internal string StateConnectionString;
  37. internal string SqlConnectionString;
  38. internal string StateNetworkTimeout;
  39. public SessionConfig (object parent)
  40. {
  41. SessionConfig p = (parent as SessionConfig);
  42. if (p != null) {
  43. CookieLess = p.CookieLess;
  44. Mode = p.Mode;
  45. Timeout = p.Timeout;
  46. StateConnectionString = p.StateConnectionString;
  47. SqlConnectionString = p.SqlConnectionString;
  48. } else {
  49. Mode = SessionStateMode.InProc;
  50. Timeout = 20;
  51. StateConnectionString = "127.0.0.1:42424";
  52. SqlConnectionString = "user id=sa;password=;data source=127.0.0.1";
  53. }
  54. }
  55. internal bool SetMode (string value)
  56. {
  57. try {
  58. Mode = (SessionStateMode) Enum.Parse (typeof (SessionStateMode), value, true);
  59. } catch {
  60. return false;
  61. }
  62. return true;
  63. }
  64. internal bool SetCookieLess (string value)
  65. {
  66. if (value == null)
  67. return false;
  68. CookieLess = (0 == String.Compare ("true", value, true));
  69. if (!CookieLess && String.Compare ("false", value, true) != 0)
  70. return false;
  71. return true;
  72. }
  73. internal bool SetTimeout (string value)
  74. {
  75. try {
  76. Timeout = Int32.Parse (value);
  77. } catch {
  78. return false;
  79. }
  80. return true;
  81. }
  82. internal void SetStateConnectionString (string value)
  83. {
  84. StateConnectionString = value;
  85. }
  86. internal void SetSqlConnectionString (string value)
  87. {
  88. SqlConnectionString = value;
  89. }
  90. internal void SetStateNetworkTimeout (string value)
  91. {
  92. StateNetworkTimeout = value;
  93. }
  94. }
  95. }