public static SqlMethodAttribute GetSqlMethodAttribute(this MethodInfo method) { SqlMethodAttribute attribute = null; if (!sqlMethodAttributes.TryGetValue(method, out attribute)) { lock (sqlMethodAttributes) { if (!sqlMethodAttributes.TryGetValue(method, out attribute)) { attribute = method.GetCustomAttributes(typeof(SqlMethodAttribute), true).OfType <SqlMethodAttribute>().FirstOrDefault <SqlMethodAttribute>(); sqlMethodAttributes[method] = attribute; } } } return(attribute); }
public static string GetSqlMethodFormat(this ISqlFormatter formatter, MethodInfo method) { string str = null; if (dicSqlMethodFormats.TryGetValue(method, out str) || !method.IsDefined(typeof(SqlMethodAttribute), true)) { return(str); } SqlMethodAttribute sqlMethodAttribute = method.GetSqlMethodAttribute(); lock (dicSqlMethodFormats) { if (!dicSqlMethodFormats.TryGetValue(method, out str)) { dicSqlMethodFormats.Add(method, sqlMethodAttribute.Format); } } return(sqlMethodAttribute.Format); }