XMLRW.cs 846 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  2. using BaseLibRWFile;
  3. namespace BaseLibRWFile
  4. {
  5. public abstract class XMLRW<T> where T : class
  6. {
  7. private static readonly object obj = new object();
  8. public static T Load(string file)
  9. {
  10. lock (obj)
  11. {
  12. return ClsXml.ReadXML(file, typeof(T)) as T;
  13. }
  14. }
  15. public static T Load(string file, Type t)
  16. {
  17. lock (obj)
  18. {
  19. return ClsXml.ReadXML(file, t) as T;
  20. }
  21. }
  22. public virtual void Save(string filePath)
  23. {
  24. ClsXml.WriteXML(this, filePath, this.GetType());
  25. }
  26. public virtual void SaveAs(string filePath)
  27. {
  28. ClsXml.WriteXML(this, filePath, typeof(T));
  29. }
  30. public abstract bool CheckIfNormal();
  31. }
  32. }