Ejemplo n.º 1
0
        internal static void CheckAndThrow(string variable, Designer root, string method, string[] variables = null)
        {
            QueryTalkException exception;

            root.CheckNull(Chainer.Arg(() => variable, variable), method);
            if (root.chainException != null)
            {
                if (variables != null)
                {
                    root.chainException.Arguments = String.Format("variable name = null{0}   variables = ({1})",
                                                                  Environment.NewLine,
                                                                  String.Join(", ", variables.Select(v => v ?? Text.ClrNull)));
                }
                else
                {
                    root.chainException.Arguments = "variable name = null";
                }

                root.TryThrow(root.chainException, method);
            }

            bool check = Variable.TryValidateName(variable, out exception);

            root.TryThrow(exception, method);

            if (!check)
            {
                exception = new QueryTalkException("SetChainer.CheckAndThrow",
                                                   QueryTalkExceptionType.InvalidVariableName,
                                                   Chainer.ArgVal(() => variable, variable));
                root.TryThrow(exception, method);
            }

            if (root.VariableExists(variable) == false)
            {
                root.Throw(QueryTalkExceptionType.ParamOrVariableNotDeclared,
                           Chainer.ArgVal(() => variable, variable),
                           method);
            }
        }
Ejemplo n.º 2
0
        internal static TableType TryDetectTableType(Designer root, string tableName, string method = null)
        {
            root.CheckNullAndThrow(Chainer.Arg(() => tableName, tableName), method);
            var identifier = Common.CheckIdentifier(tableName);

            if (identifier == IdentifierValidity.Variable)
            {
                return(TableType.Variable);
            }
            else if (identifier == IdentifierValidity.TempTable)
            {
                root.TryAddTempTable(tableName);
                return(TableType.TempTable);
            }
            else
            {
                root.Throw(QueryTalkExceptionType.InvalidTableIdentifier,
                           String.Format("identifier = {0}", tableName), method);
            }

            return(TableType.None);
        }