public static IValueProcessor GetValueProcessor(this SpecFlowContext context, Type dataType) { AddDefaultValueProcessors(context); var lookup = context.GetInherited <Dictionary <Type, IValueProcessor> >("__processorTypeLookup__"); lookup.TryGetValue(dataType, out IValueProcessor result); return(result); }
///// <summary> ///// Gets a value from the context or parent context(s) using a default key. Returns a boolean indicating ///// whether or not the value was found. ///// </summary> ///// <typeparam name="T">The type of the value to return.</typeparam> ///// <param name="context">The context.</param> ///// <param name="result">The value if found.</param> ///// <returns>A boolean indicating if the value was found.</returns> //public static bool TryGetInherited<T>(this SpecFlowContext context, out T result) // => TryGetInherited<T>(context, typeof(T).FullName, out result); /// <summary> /// Gets a value from the context or parent context(s) using a specified key. Adds and returns a specified /// default value if the key was not found. /// </summary> /// <typeparam name="T">The type of the value to return.</typeparam> /// <param name="context">The context.</param> /// <param name="key">The key.</param> /// <param name="defaultValue">The value to return if the key was not found.</param> /// <returns>The value associated with the specified key or the default value if not found.</returns> public static T GetInheritedOrDefault <T>(this SpecFlowContext context, string key, T defaultValue) { try { return(context.GetInherited <T>(key)); } catch { context.Set(defaultValue, key); return(defaultValue); } }
private static Dictionary <Type, ComparerMapping> GetComparerTypeMappingLookup(this SpecFlowContext context) { AddDefaultComparerMappings(context); return(context.GetInherited <Dictionary <Type, ComparerMapping> >("__comparerTypeMappingLookup__")); }
public static List <IValueProcessor> GetValueProcessorOrder(this SpecFlowContext context) { AddDefaultValueProcessors(context); return(context.GetInherited <List <IValueProcessor> >("__ValueProcessorOrder__")); }