コード例 #1
0
        private async Task <Response> GetResponse(SqlResponseCommand command)
        {
            //var responder = command switch {
            //    SqlResponseCommand.GeneralInfo => new GeneralInfo(ConnectionString),
            //    SqlResponseCommand.TableList => new TableList(ConnectionString),
            //    _ => new Error()
            //};
            //return responder.GetResponse();

            ICommandResponder responder;

            switch (command)
            {
            case SqlResponseCommand.GeneralInfo:
                responder = new GeneralInfo(ConnectionString);
                break;

            case SqlResponseCommand.TableList:
                responder = new TableList(ConnectionString);
                break;

            default:
                responder = new Error();
                break;
            }

            return(await responder.GetResponse());
        }
コード例 #2
0
        private async Task <Response> GetResponse(SqlResponseCommand command)
        {
            //var responder = command switch {
            //    SqlResponseCommand.GeneralInfo => new GeneralInfo(ConnectionString),
            //    SqlResponseCommand.TableList => new TableList(ConnectionString),
            //    _ => new Error()
            //};
            //return responder.GetResponse();


            //Server error handling:
            //localhost:2019/sql/invalid
            if (string.IsNullOrEmpty(ConnectionString))
            {
                ICommandResponder responder;
                switch (command)
                {
                case SqlResponseCommand.GeneralInfo:
                    responder = new GeneralInfo(ConnectionString);
                    break;

                case SqlResponseCommand.TableList:
                    responder = new TableList(ConnectionString);
                    break;

                default:
                    responder = new Error();
                    break;
                }
            }
            else
            {
                var responder = new ErrorConnectionString();
                return(await responder.GetResponse());
            }
        }