/// <summary> /// Gets the executor by walking the stack looking for an appropriate ConnectionAttribute /// decoration on either method or class (in that order). If no such decoration is found, /// an InvalidOperationException will be thrown. /// </summary> /// <returns></returns> public ISqlProvider GetExecutorByWalkingTheStack() { AbstractConnectionAttribute attrib = GetConnectionAttribute(); if (attrib == null) { throw new InvalidOperationException("Unable to locate connection string attribute"); } name = attrib.Name; return(attrib.GetExecutor()); }
private AbstractConnectionAttribute GetConnectionForMethod(MemberInfo method) { // First, check if the method is decorated AbstractConnectionAttribute connectionAttribute = GetAttribFromList(Attribute.GetCustomAttributes(method, typeof(AbstractConnectionAttribute))); if (connectionAttribute != null) { return(connectionAttribute); } // Method not decorated. Check class return(GetAttribFromList(Attribute.GetCustomAttributes(method.DeclaringType, typeof(AbstractConnectionAttribute)))); }