PageRenderTime 40ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/stable-1.2.0/Server/Handlers/HandlerElement.cs

#
C# | 183 lines | 159 code | 16 blank | 8 comment | 5 complexity | ed2163ae4bc9ffb6982e27dba6bc058c MD5 | raw file
Possible License(s): CC-BY-SA-3.0
  1. //-----------------------------------------------------------------------
  2. // <copyright>
  3. // Copyright (C) Ruslan Yakushev for the PHP Manager for IIS project.
  4. //
  5. // This file is subject to the terms and conditions of the Microsoft Public License (MS-PL).
  6. // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL for more details.
  7. // </copyright>
  8. //-----------------------------------------------------------------------
  9. using System;
  10. using Microsoft.Web.Administration;
  11. namespace Web.Management.PHP.Handlers
  12. {
  13. public sealed class HandlerElement : ConfigurationElement
  14. {
  15. private string _executable;
  16. private string _arguments;
  17. public bool AllowPathInfo
  18. {
  19. get
  20. {
  21. return (bool)base["allowPathInfo"];
  22. }
  23. set
  24. {
  25. base["allowPathInfo"] = value;
  26. }
  27. }
  28. public string Arguments
  29. {
  30. get
  31. {
  32. if (_arguments == null)
  33. {
  34. string rawExecutable = SplitScriptProcessor(ScriptProcessor, out _arguments);
  35. _executable = Environment.ExpandEnvironmentVariables(rawExecutable);
  36. }
  37. return _arguments;
  38. }
  39. }
  40. public string Executable
  41. {
  42. get
  43. {
  44. if (_executable == null)
  45. {
  46. string rawExecutable = SplitScriptProcessor(ScriptProcessor, out _arguments);
  47. _executable = Environment.ExpandEnvironmentVariables(rawExecutable);
  48. }
  49. return _executable;
  50. }
  51. }
  52. public string Modules
  53. {
  54. get
  55. {
  56. return (string)base["modules"];
  57. }
  58. set
  59. {
  60. base["modules"] = value;
  61. }
  62. }
  63. public string Name
  64. {
  65. get
  66. {
  67. return (string)base["name"];
  68. }
  69. set
  70. {
  71. base["name"] = value;
  72. }
  73. }
  74. public string Path
  75. {
  76. get
  77. {
  78. return (string)base["path"];
  79. }
  80. set
  81. {
  82. base["path"] = value;
  83. }
  84. }
  85. public string PreCondition
  86. {
  87. get
  88. {
  89. return (string)base["preCondition"];
  90. }
  91. set
  92. {
  93. base["preCondition"] = value;
  94. }
  95. }
  96. public RequireAccess RequireAccess
  97. {
  98. get
  99. {
  100. return (RequireAccess)base["requireAccess"];
  101. }
  102. set
  103. {
  104. base["requireAccess"] = (int)value;
  105. }
  106. }
  107. public ResourceType ResourceType
  108. {
  109. get
  110. {
  111. return (ResourceType)base["resourceType"];
  112. }
  113. set
  114. {
  115. base["resourceType"] = (int)value;
  116. }
  117. }
  118. public string ScriptProcessor
  119. {
  120. get
  121. {
  122. return (string)base["scriptProcessor"];
  123. }
  124. set
  125. {
  126. base["scriptProcessor"] = value;
  127. _executable = null;
  128. _arguments = null;
  129. }
  130. }
  131. public string Type
  132. {
  133. get
  134. {
  135. return (string)base["type"];
  136. }
  137. set
  138. {
  139. base["type"] = value;
  140. }
  141. }
  142. public string Verb
  143. {
  144. get
  145. {
  146. return (string)base["verb"];
  147. }
  148. set
  149. {
  150. base["verb"] = value;
  151. }
  152. }
  153. private static string SplitScriptProcessor(string scriptProcessor, out string arguments)
  154. {
  155. string[] s = scriptProcessor.Split(new char[] { '|' }, StringSplitOptions.None);
  156. if (s.Length > 1)
  157. {
  158. arguments = s[1];
  159. }
  160. else
  161. {
  162. arguments = String.Empty;
  163. }
  164. return s[0];
  165. }
  166. }
  167. }