private delegate SqlType TypeWithLenCreateDelegate(int length); // Func<int, T> private static T GetTypeWithLen <T>(int length, TypeWithLenCreateDelegate createDelegate) where T : SqlType { string key = GetKeyForLengthBased(typeof(T).Name, length); SqlType result = SqlTypes.GetOrAdd(key, k => createDelegate(length)); return((T)result); }
private delegate SqlType TypeWithLenCreateDelegate(int length); // Func<int, T> private static T GetTypeWithLen <T>(int length, TypeWithLenCreateDelegate createDelegate) where T : SqlType { string key = GetKeyForLengthBased(typeof(T).Name, length); SqlType result; if (!SqlTypes.TryGetValue(key, out result)) { result = createDelegate(length); SqlTypes.Add(key, result); } return((T)result); }