ProcessNode.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #region BSD License
  2. /*
  3. Copyright (c) 2004-2005 Matthew Holmes ([email protected]), Dan Moorehead ([email protected])
  4. Redistribution and use in source and binary forms, with or without modification, are permitted
  5. provided that the following conditions are met:
  6. * Redistributions of source code must retain the above copyright notice, this list of conditions
  7. and the following disclaimer.
  8. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
  9. and the following disclaimer in the documentation and/or other materials provided with the
  10. distribution.
  11. * The name of the author may not be used to endorse or promote products derived from this software
  12. without specific prior written permission.
  13. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
  14. BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  15. ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  16. EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  17. OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  18. OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  19. IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  20. */
  21. #endregion
  22. using System;
  23. using System.Xml;
  24. using Prebuild.Core.Attributes;
  25. using Prebuild.Core.Interfaces;
  26. using Prebuild.Core.Utilities;
  27. namespace Prebuild.Core.Nodes
  28. {
  29. /// <summary>
  30. ///
  31. /// </summary>
  32. [DataNode("Process")]
  33. public class ProcessNode : DataNode
  34. {
  35. #region Fields
  36. private string m_Path;
  37. private bool m_IsValid = true;
  38. #endregion
  39. #region Properties
  40. /// <summary>
  41. /// Gets the path.
  42. /// </summary>
  43. /// <value>The path.</value>
  44. public string Path
  45. {
  46. get
  47. {
  48. return m_Path;
  49. }
  50. }
  51. /// <summary>
  52. /// Gets a value indicating whether this instance is valid.
  53. /// </summary>
  54. /// <value><c>true</c> if this instance is valid; otherwise, <c>false</c>.</value>
  55. public bool IsValid
  56. {
  57. get
  58. {
  59. return m_IsValid;
  60. }
  61. }
  62. #endregion
  63. #region Public Methods
  64. /// <summary>
  65. /// Parses the specified node.
  66. /// </summary>
  67. /// <param name="node">The node.</param>
  68. public override void Parse(XmlNode node)
  69. {
  70. if( node == null )
  71. {
  72. throw new ArgumentNullException("node");
  73. }
  74. m_Path = Helper.InterpolateForEnvironmentVariables(node.InnerText);
  75. if(m_Path == null)
  76. {
  77. m_Path = "";
  78. }
  79. try
  80. {
  81. m_Path = Helper.ResolvePath(m_Path);
  82. }
  83. catch(ArgumentException)
  84. {
  85. Kernel.Instance.Log.Write(LogType.Warning, "Could not find prebuild file for processing: {0}", m_Path);
  86. m_IsValid = false;
  87. }
  88. }
  89. #endregion
  90. }
  91. }