Resource`1.cs 795 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace SmartCoalApplication.Base
  7. {
  8. public abstract class Resource<T>
  9. {
  10. protected T resource;
  11. public T Reference
  12. {
  13. get
  14. {
  15. if (this.resource == null)
  16. {
  17. this.resource = Load();
  18. }
  19. return this.resource;
  20. }
  21. }
  22. public T GetCopy()
  23. {
  24. return Load();
  25. }
  26. protected abstract T Load();
  27. protected Resource()
  28. {
  29. this.resource = default(T);
  30. }
  31. protected Resource(T resource)
  32. {
  33. this.resource = resource;
  34. }
  35. }
  36. }