aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarcinzelent <marcin@zelent.net>2017-05-27 15:08:46 +0200
committermarcinzelent <marcin@zelent.net>2017-05-27 15:08:46 +0200
commit44065455f5e237164e15cda9894be2d3399fad9a (patch)
tree38dff88c8537a56a6953143b07b25328fc1111bc
parent5b8184a2fd8183f47637300bbda80b36e9f2023f (diff)
Optimized singleton.
-rw-r--r--ApartmentManager/ApartmentManager/Singletons/UserSingleton.cs24
1 files changed, 5 insertions, 19 deletions
diff --git a/ApartmentManager/ApartmentManager/Singletons/UserSingleton.cs b/ApartmentManager/ApartmentManager/Singletons/UserSingleton.cs
index e5ca71e..1f291c9 100644
--- a/ApartmentManager/ApartmentManager/Singletons/UserSingleton.cs
+++ b/ApartmentManager/ApartmentManager/Singletons/UserSingleton.cs
@@ -1,28 +1,14 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using ApartmentManager.Model;
-namespace ApartmentManager.Model
+namespace ApartmentManager.Singletons
{
public class UserSingleton
{
- private static UserSingleton instance;
+ private static UserSingleton _instance;
+ public static UserSingleton Instance => _instance ?? (_instance = new UserSingleton());
+
public User CurrentUser { get; set; }
private UserSingleton() { }
-
- public static UserSingleton Instance
- {
- get
- {
- if (instance == null)
- {
- instance = new UserSingleton();
- }
- return instance;
- }
- }
}
}