Exemple #1
0
        public BoxValue <T> InitValue <T>(string key, InitializeMethod <T> initializeMethod)
        {
            if (values.TryGetValue(typeof(T), out var hashtable))
            {
                if (hashtable.TryGetValue(key, out var value))
                {
                    return((BoxValue <T>)value);
                }
                else
                {
                    var newValue = new BoxValue <T>(initializeMethod());
                    hashtable.Add(key, newValue);
                    return(newValue);
                }
            }
            else
            {
                hashtable = new Dictionary <string, object>();
                values.Add(typeof(T), hashtable);

                var newValue = new BoxValue <T>(initializeMethod());
                hashtable.Add(key, newValue);
                return(newValue);
            }
        }
 /// <summary>
 /// Registers the initializer method.
 /// </summary>
 /// <param name="method">The method.</param>
 /// <param name="priority">The priority.</param>
 public static void RegisterInitializerMethod(InitializeMethod method, int priority)
 {
     items.Add(new InitializationItem()
     {
         CallBack = method, Priority = priority
     });
 }
Exemple #3
0
        public void Add <TPs, TDs>(CreateMethod create, InitializeMethod method = null) where TPs : TP where TDs : TD
        {
            var p = typeof(TPs);
            var d = typeof(TDs);

            descProduct.Add(d, p);

            factories.Add(p, create);
            methods.Add(p, method);
        }
Exemple #4
0
 public void Add <TPs, TDs>(InitializeMethod method = null) where TPs : TP, new() where TDs : TD
 {
     Add <TPs, TDs>(() => new TPs(), method);
 }
 /// <summary>
 /// Registers the initializer method.
 /// </summary>
 /// <param name="method">The method.</param>
 /// <param name="priority">The priority.</param>
 public static void RegisterInitializerMethod(InitializeMethod method, int priority)
 {
     items.Add(new InitializationItem() { CallBack = method, Priority = priority });
 }