PageRenderTime 30ms CodeModel.GetById 20ms app.highlight 7ms RepoModel.GetById 2ms app.codeStats 0ms

/trunk/Server/Handlers/HandlerElement.cs

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