private void RegisterCommandExecutionHandler(CommandExecutionHandler handler)
 {
     if (handler.IsProcedureHandler())
     {
         string commandText = (string)handler.RetrieveCommandText();
         handlers_key.Add(commandText, handler);
     }
     else
     {
         this.handlers_text.Add(handler);
     }
 }
Exemple #2
0
        internal static Func <DataSet, DbCommand, DbDataReader> TryRead(CommandExecutionHandler handlerRegistry, DbCommand cmd)
        {
            HandlerReadDesc handler;

            if (!s_map_CommandText_Read_Method.TryGetValue(cmd.CommandText, out handler))
            {
                // not yet cached
                IComparable handlerCommandText = handlerRegistry.RetrieveCommandText();// GetCommandTextImpl(tAccessor, handlerMethodName);

                string handlerCommandTextX = handlerCommandText as string;

                bool isOk;
                if (handlerCommandTextX == null)
                {
                    isOk = handlerCommandText.CompareTo(cmd) == 0;
                }
                else
                {
                    isOk = string.Equals(cmd.CommandText, handlerCommandTextX, StringComparison.Ordinal);
                }


                if (isOk)
                {
                    Func <DataSet, DbCommand, DbDataReader> handlerMethod = handlerRegistry.DoCompileReadMethod();
                    //handlerRegistry.SetCompiledReadMethod(handlerMethod);
                    handler = new HandlerReadDesc(handlerRegistry.RetrieveHandlerMethodName(), handlerMethod);
                    s_map_CommandText_Read_Method.Add(cmd.CommandText, handler);
                }
                else
                {
                    handler = null;
                }
            }
            else
            {
                // registered
            }

            if (handler != null && handler.MethodName == handlerRegistry.RetrieveHandlerMethodName())
            {
                return(handler.HandlerMethod);
            }


            return(null);
        }