ReferenceNode.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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("Reference")]
  33. public class ReferenceNode : DataNode, IComparable
  34. {
  35. #region Fields
  36. private string m_Name = "unknown";
  37. private string m_Path;
  38. private string m_LocalCopy;
  39. private string m_Version;
  40. #endregion
  41. #region Properties
  42. /// <summary>
  43. /// Gets the name.
  44. /// </summary>
  45. /// <value>The name.</value>
  46. public string Name
  47. {
  48. get
  49. {
  50. return m_Name;
  51. }
  52. }
  53. /// <summary>
  54. /// Gets the path.
  55. /// </summary>
  56. /// <value>The path.</value>
  57. public string Path
  58. {
  59. get
  60. {
  61. return m_Path;
  62. }
  63. }
  64. /// <summary>
  65. /// Gets a value indicating whether [local copy specified].
  66. /// </summary>
  67. /// <value><c>true</c> if [local copy specified]; otherwise, <c>false</c>.</value>
  68. public bool LocalCopySpecified
  69. {
  70. get
  71. {
  72. return ( m_LocalCopy != null && m_LocalCopy.Length == 0);
  73. }
  74. }
  75. /// <summary>
  76. /// Gets a value indicating whether [local copy].
  77. /// </summary>
  78. /// <value><c>true</c> if [local copy]; otherwise, <c>false</c>.</value>
  79. public bool LocalCopy
  80. {
  81. get
  82. {
  83. if( m_LocalCopy == null)
  84. {
  85. return false;
  86. }
  87. return bool.Parse(m_LocalCopy);
  88. }
  89. }
  90. /// <summary>
  91. /// Gets the version.
  92. /// </summary>
  93. /// <value>The version.</value>
  94. public string Version
  95. {
  96. get
  97. {
  98. return m_Version;
  99. }
  100. }
  101. #endregion
  102. #region Public Methods
  103. /// <summary>
  104. /// Parses the specified node.
  105. /// </summary>
  106. /// <param name="node">The node.</param>
  107. public override void Parse(XmlNode node)
  108. {
  109. m_Name = Helper.AttributeValue(node, "name", m_Name);
  110. m_Path = Helper.AttributeValue(node, "path", m_Path);
  111. m_LocalCopy = Helper.AttributeValue(node, "localCopy", m_LocalCopy);
  112. m_Version = Helper.AttributeValue(node, "version", m_Version);
  113. }
  114. #endregion
  115. #region IComparable Members
  116. public int CompareTo(object obj)
  117. {
  118. ReferenceNode that = (ReferenceNode)obj;
  119. return this.m_Name.CompareTo(that.m_Name);
  120. }
  121. #endregion
  122. }
  123. }