コード例 #1
0
ファイル: SetChainer.cs プロジェクト: amosvoron/querytalk
        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);
            }
        }