示例#1
0
        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);
        }
示例#2
0
        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);
        }