PageRenderTime 25ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/Model/Component.cs

https://github.com/shader/QuickArch
C# | 58 lines | 51 code | 7 blank | 0 comment | 0 complexity | fc2ab57429d0303d88cc8e8156c8931f MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows;
  6. using System.Xml.Linq;
  7. using QuickArch.Properties;
  8. namespace QuickArch.Model
  9. {
  10. public abstract class Component
  11. {
  12. #region Fields
  13. public string Filename;
  14. public Dictionary<String, String> Properties {get; set;}
  15. private Guid _id = Guid.NewGuid();
  16. protected Component _parent;
  17. #endregion
  18. #region Constructors
  19. public Component() : this(null) { }
  20. public Component(string name) : this(name, null) { }
  21. public Component(string name, Component parent)
  22. {
  23. Properties = new Dictionary<string, string>();
  24. Properties.Add("Name", name);
  25. _parent = parent;
  26. }
  27. #endregion
  28. #region Properties
  29. public string Name
  30. {
  31. get { return Properties["Name"]; }
  32. set { Properties["Name"] = value; }
  33. }
  34. public Guid ID
  35. {
  36. get { return _id; }
  37. }
  38. #endregion
  39. public abstract void Save(); // save to the predefined file
  40. public abstract void Save(XElement parent); // save information under parent's tree
  41. public void SaveAs(string filename) // set filename, and then save
  42. {
  43. Filename = filename;
  44. Save();
  45. }
  46. public void Delete()
  47. {
  48. (_parent as System).RemoveComponent(this);
  49. }
  50. }
  51. }