Exemple #1
0
        public bool Equals(NameParameterCountKey other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return(other.Count == Count && Equals(other.Name, Name));
        }
Exemple #2
0
        // All scripts get compiled/verfied - to ensure they are compiled once and not multiple times.
        public static void ValidateScripts(
            IList <ExpressionScriptProvided> scripts,
            ExpressionDeclDesc expressionDeclDesc,
            StatementCompileTimeServices compileTimeServices)
        {
            if (scripts == null)
            {
                return;
            }

            var defaultDialect = compileTimeServices.Configuration.Compiler.Scripts.DefaultDialect;
            var scriptsSet     = new HashSet <NameParameterCountKey>();

            foreach (var script in scripts)
            {
                ValidateScript(script, defaultDialect, compileTimeServices.ScriptCompiler);

                var key = new NameParameterCountKey(
                    script.Name,
                    script.ParameterNames.Length);
                if (scriptsSet.Contains(key))
                {
                    throw new ExprValidationException(
                              "Script name '" +
                              script.Name +
                              "' has already been defined with the same number of parameters");
                }

                scriptsSet.Add(key);
            }

            if (expressionDeclDesc != null)
            {
                foreach (var declItem in expressionDeclDesc.Expressions)
                {
                    if (scriptsSet.Contains(new NameParameterCountKey(declItem.Name, 0)))
                    {
                        throw new ExprValidationException(
                                  "Script name '" + declItem.Name + "' overlaps with another expression of the same name");
                    }
                }
            }
        }