Exemplo n.º 1
0
        /// <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());
        }
Exemplo n.º 2
0
        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))));
        }