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