ToolInfo.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace Prebuild.Core.Targets
  5. {
  6. /// <summary>
  7. ///
  8. /// </summary>
  9. public struct ToolInfo
  10. {
  11. string name;
  12. string guid;
  13. string fileExtension;
  14. string xmlTag;
  15. string importProject;
  16. /// <summary>
  17. /// Gets or sets the name.
  18. /// </summary>
  19. /// <value>The name.</value>
  20. public string Name
  21. {
  22. get
  23. {
  24. return name;
  25. }
  26. set
  27. {
  28. name = value;
  29. }
  30. }
  31. /// <summary>
  32. /// Gets or sets the GUID.
  33. /// </summary>
  34. /// <value>The GUID.</value>
  35. public string Guid
  36. {
  37. get
  38. {
  39. return guid;
  40. }
  41. set
  42. {
  43. guid = value;
  44. }
  45. }
  46. /// <summary>
  47. /// Gets or sets the file extension.
  48. /// </summary>
  49. /// <value>The file extension.</value>
  50. public string FileExtension
  51. {
  52. get
  53. {
  54. return fileExtension;
  55. }
  56. set
  57. {
  58. fileExtension = value;
  59. }
  60. }
  61. public string LanguageExtension
  62. {
  63. get
  64. {
  65. switch (this.Name)
  66. {
  67. case "C#":
  68. return ".cs";
  69. case "VisualBasic":
  70. return ".vb";
  71. case "Boo":
  72. return ".boo";
  73. default:
  74. return ".cs";
  75. }
  76. }
  77. }
  78. /// <summary>
  79. /// Gets or sets the XML tag.
  80. /// </summary>
  81. /// <value>The XML tag.</value>
  82. public string XmlTag
  83. {
  84. get
  85. {
  86. return xmlTag;
  87. }
  88. set
  89. {
  90. xmlTag = value;
  91. }
  92. }
  93. /// <summary>
  94. /// Gets or sets the import project property.
  95. /// </summary>
  96. /// <value>The ImportProject tag.</value>
  97. public string ImportProject
  98. {
  99. get
  100. {
  101. return importProject;
  102. }
  103. set
  104. {
  105. importProject = value;
  106. }
  107. }
  108. /// <summary>
  109. /// Initializes a new instance of the <see cref="ToolInfo"/> class.
  110. /// </summary>
  111. /// <param name="name">The name.</param>
  112. /// <param name="guid">The GUID.</param>
  113. /// <param name="fileExtension">The file extension.</param>
  114. /// <param name="xml">The XML.</param>
  115. /// <param name="importProject">The import project.</param>
  116. public ToolInfo(string name, string guid, string fileExtension, string xml, string importProject)
  117. {
  118. this.name = name;
  119. this.guid = guid;
  120. this.fileExtension = fileExtension;
  121. this.xmlTag = xml;
  122. this.importProject = importProject;
  123. }
  124. /// <summary>
  125. /// Initializes a new instance of the <see cref="ToolInfo"/> class.
  126. /// </summary>
  127. /// <param name="name">The name.</param>
  128. /// <param name="guid">The GUID.</param>
  129. /// <param name="fileExtension">The file extension.</param>
  130. /// <param name="xml">The XML.</param>
  131. public ToolInfo(string name, string guid, string fileExtension, string xml)
  132. {
  133. this.name = name;
  134. this.guid = guid;
  135. this.fileExtension = fileExtension;
  136. this.xmlTag = xml;
  137. this.importProject = "$(MSBuildBinPath)\\Microsoft." + xml + ".Targets";
  138. }
  139. /// <summary>
  140. /// Equals operator
  141. /// </summary>
  142. /// <param name="obj">ToolInfo to compare</param>
  143. /// <returns>true if toolInfos are equal</returns>
  144. public override bool Equals(object obj)
  145. {
  146. if (obj == null)
  147. {
  148. throw new ArgumentNullException("obj");
  149. }
  150. if (obj.GetType() != typeof(ToolInfo))
  151. return false;
  152. ToolInfo c = (ToolInfo)obj;
  153. return ((this.name == c.name) && (this.guid == c.guid) && (this.fileExtension == c.fileExtension) && (this.importProject == c.importProject));
  154. }
  155. /// <summary>
  156. /// Equals operator
  157. /// </summary>
  158. /// <param name="c1">ToolInfo to compare</param>
  159. /// <param name="c2">ToolInfo to compare</param>
  160. /// <returns>True if toolInfos are equal</returns>
  161. public static bool operator ==(ToolInfo c1, ToolInfo c2)
  162. {
  163. return ((c1.name == c2.name) && (c1.guid == c2.guid) && (c1.fileExtension == c2.fileExtension) && (c1.importProject == c2.importProject) && (c1.xmlTag == c2.xmlTag));
  164. }
  165. /// <summary>
  166. /// Not equals operator
  167. /// </summary>
  168. /// <param name="c1">ToolInfo to compare</param>
  169. /// <param name="c2">ToolInfo to compare</param>
  170. /// <returns>True if toolInfos are not equal</returns>
  171. public static bool operator !=(ToolInfo c1, ToolInfo c2)
  172. {
  173. return !(c1 == c2);
  174. }
  175. /// <summary>
  176. /// Hash Code
  177. /// </summary>
  178. /// <returns>Hash code</returns>
  179. public override int GetHashCode()
  180. {
  181. return name.GetHashCode() ^ guid.GetHashCode() ^ this.fileExtension.GetHashCode() ^ this.importProject.GetHashCode() ^ this.xmlTag.GetHashCode();
  182. }
  183. }
  184. }