33 lines
		
	
	
		
			784 B
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			33 lines
		
	
	
		
			784 B
		
	
	
	
		
			C#
		
	
	
	
|  | using System.Collections.Generic; | |||
|  | 
 | |||
|  | public static class LocalCacheManager { | |||
|  | 
 | |||
|  |     private static Dictionary<string, object> dictionary = new Dictionary<string, object>(); | |||
|  | 
 | |||
|  |     public static void Save(string tag, object value){ | |||
|  |         dictionary[tag] = value; | |||
|  |     } | |||
|  | 
 | |||
|  |     public static T Load<T>(string tag, T defaultValue){ | |||
|  |         if(Exists(tag)){ | |||
|  |             return Load<T>(tag); | |||
|  |         }else{ | |||
|  |             return defaultValue; | |||
|  |         } | |||
|  |     } | |||
|  |     public static T Load<T>(string tag){ | |||
|  |         return (T)dictionary[tag]; | |||
|  |     } | |||
|  | 
 | |||
|  |     public static bool Exists(string tag){ | |||
|  |         return dictionary.ContainsKey(tag); | |||
|  |     } | |||
|  |      | |||
|  |     public static bool Remove(string tag){ | |||
|  |         return dictionary.Remove(tag); | |||
|  |     } | |||
|  | 
 | |||
|  |     public static void Clear(){ | |||
|  |         dictionary.Clear(); | |||
|  |     } | |||
|  | } |