object IAutoGenerator.Generate(AutoGenerateContext context) { // Create an instance of a dictionary (public and non-public) IDictionary <TKey, TValue> items; try { items = (IDictionary <TKey, TValue>)Activator.CreateInstance(context.GenerateType, true); } catch { items = new Dictionary <TKey, TValue>(); } // Get a list of keys var keys = context.GenerateUniqueMany <TKey>(); foreach (var key in keys) { // Get a matching value for the current key and add to the dictionary var value = context.Generate <TValue>(); if (value != null) { items.Add(key, value); } } return(items); }
object IAutoGenerator.Generate(AutoGenerateContext context) { var items = new Dictionary <TKey, TValue>(); // Get a list of keys var keys = context.GenerateMany <TKey>(); foreach (var key in keys) { // Get a matching value for the current key and add to the dictionary var value = context.Generate <TValue>(); if (value != null) { items.Add(key, value); } } return(items); }
object IAutoGenerator.Generate(AutoGenerateContext context) { return(context.Generate <TType>()); }