From 44065455f5e237164e15cda9894be2d3399fad9a Mon Sep 17 00:00:00 2001 From: marcinzelent Date: Sat, 27 May 2017 15:08:46 +0200 Subject: Optimized singleton. --- .../ApartmentManager/Singletons/UserSingleton.cs | 24 +++++----------------- 1 file 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; - } - } } } -- cgit v1.2.3