IfContext.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. namespace Prebuild.Core.Parse
  24. {
  25. /// <summary>
  26. ///
  27. /// </summary>
  28. public enum IfState
  29. {
  30. /// <summary>
  31. ///
  32. /// </summary>
  33. None,
  34. /// <summary>
  35. ///
  36. /// </summary>
  37. If,
  38. /// <summary>
  39. ///
  40. /// </summary>
  41. ElseIf,
  42. /// <summary>
  43. ///
  44. /// </summary>
  45. Else
  46. }
  47. /// <summary>
  48. /// Summary description for IfContext.
  49. /// </summary>
  50. // Inspired by the equivalent WiX class (see www.sourceforge.net/projects/wix/)
  51. public class IfContext
  52. {
  53. #region Properties
  54. bool m_Active;
  55. bool m_Keep;
  56. bool m_EverKept;
  57. IfState m_State = IfState.None;
  58. #endregion
  59. #region Constructors
  60. /// <summary>
  61. /// Initializes a new instance of the <see cref="IfContext"/> class.
  62. /// </summary>
  63. /// <param name="active">if set to <c>true</c> [active].</param>
  64. /// <param name="keep">if set to <c>true</c> [keep].</param>
  65. /// <param name="state">The state.</param>
  66. public IfContext(bool active, bool keep, IfState state)
  67. {
  68. m_Active = active;
  69. m_Keep = keep;
  70. m_EverKept = keep;
  71. m_State = state;
  72. }
  73. #endregion
  74. #region Properties
  75. /// <summary>
  76. /// Gets or sets a value indicating whether this <see cref="IfContext"/> is active.
  77. /// </summary>
  78. /// <value><c>true</c> if active; otherwise, <c>false</c>.</value>
  79. public bool Active
  80. {
  81. get
  82. {
  83. return m_Active;
  84. }
  85. set
  86. {
  87. m_Active = value;
  88. }
  89. }
  90. /// <summary>
  91. /// Gets or sets a value indicating whether this <see cref="IfContext"/> is keep.
  92. /// </summary>
  93. /// <value><c>true</c> if keep; otherwise, <c>false</c>.</value>
  94. public bool Keep
  95. {
  96. get
  97. {
  98. return m_Keep;
  99. }
  100. set
  101. {
  102. m_Keep = value;
  103. if(m_Keep)
  104. {
  105. m_EverKept = true;
  106. }
  107. }
  108. }
  109. /// <summary>
  110. /// Gets a value indicating whether [ever kept].
  111. /// </summary>
  112. /// <value><c>true</c> if [ever kept]; otherwise, <c>false</c>.</value>
  113. public bool EverKept
  114. {
  115. get
  116. {
  117. return m_EverKept;
  118. }
  119. }
  120. /// <summary>
  121. /// Gets or sets the state.
  122. /// </summary>
  123. /// <value>The state.</value>
  124. public IfState State
  125. {
  126. get
  127. {
  128. return m_State;
  129. }
  130. set
  131. {
  132. m_State = value;
  133. }
  134. }
  135. #endregion
  136. }
  137. }