PageRenderTime 7ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/stable-1.2.0/Powershell/GetPHPConfigurationCmdlet.cs

#
C# | 41 lines | 30 code | 3 blank | 8 comment | 2 complexity | 6abf6ead327bcdaa00eedd0b7e1df41b 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 System.Management.Automation;
12using Microsoft.Web.Administration;
13using Web.Management.PHP.Config;
14
15namespace Web.Management.PHP.Powershell
16{
17
18    [Cmdlet(VerbsCommon.Get, "PHPConfiguration")]
19    [OutputType(typeof(PHPConfigurationItem))]
20    public sealed class GetPHPConfigurationCmdlet : BaseCmdlet
21    {
22        protected override void DoProcessing()
23        {
24            using (ServerManager serverManager = new ServerManager())
25            {
26                ServerManagerWrapper serverManagerWrapper = new ServerManagerWrapper(serverManager, this.SiteName, this.VirtualPath);
27                PHPConfigHelper configHelper = new PHPConfigHelper(serverManagerWrapper);
28                PHPConfigInfo configInfo = configHelper.GetPHPConfigInfo();
29                if (configInfo.RegistrationType == PHPRegistrationType.FastCgi)
30                {
31                    PHPConfigurationItem configurationItem = new PHPConfigurationItem(configInfo);
32                    WriteObject(configurationItem);
33                }
34                else
35                {
36                    throw new InvalidOperationException(Resources.PHPIsNotRegisteredError);
37                }
38            }
39        }
40    }
41}