DatabaseProjectNode.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Xml;
  5. using Prebuild.Core.Attributes;
  6. using Prebuild.Core.Interfaces;
  7. using Prebuild.Core.Utilities;
  8. namespace Prebuild.Core.Nodes
  9. {
  10. [DataNode("DatabaseProject")]
  11. public class DatabaseProjectNode : DataNode
  12. {
  13. string name;
  14. string path;
  15. string fullpath;
  16. Guid guid = Guid.NewGuid();
  17. readonly List<AuthorNode> authors = new List<AuthorNode>();
  18. readonly List<DatabaseReferenceNode> references = new List<DatabaseReferenceNode>();
  19. public Guid Guid
  20. {
  21. get { return guid; }
  22. }
  23. public string Name
  24. {
  25. get { return name; }
  26. }
  27. public string Path
  28. {
  29. get { return path; }
  30. }
  31. public string FullPath
  32. {
  33. get { return fullpath; }
  34. }
  35. public IEnumerable<DatabaseReferenceNode> References
  36. {
  37. get { return references; }
  38. }
  39. public override void Parse(XmlNode node)
  40. {
  41. name = Helper.AttributeValue(node, "name", name);
  42. path = Helper.AttributeValue(node, "path", name);
  43. try
  44. {
  45. fullpath = Helper.ResolvePath(path);
  46. }
  47. catch
  48. {
  49. throw new WarningException("Could not resolve Solution path: {0}", path);
  50. }
  51. Kernel.Instance.CurrentWorkingDirectory.Push();
  52. try
  53. {
  54. Helper.SetCurrentDir(fullpath);
  55. if (node == null)
  56. {
  57. throw new ArgumentNullException("node");
  58. }
  59. foreach (XmlNode child in node.ChildNodes)
  60. {
  61. IDataNode dataNode = Kernel.Instance.ParseNode(child, this);
  62. if (dataNode == null)
  63. continue;
  64. if (dataNode is AuthorNode)
  65. authors.Add((AuthorNode)dataNode);
  66. else if (dataNode is DatabaseReferenceNode)
  67. references.Add((DatabaseReferenceNode)dataNode);
  68. }
  69. }
  70. finally
  71. {
  72. Kernel.Instance.CurrentWorkingDirectory.Pop();
  73. }
  74. base.Parse(node);
  75. }
  76. }
  77. }