Пример #1
0
        /// <summary>
        ///     Accept a visit from an implementor of <see cref="ILSLValidatorNodeVisitor{T}" />
        /// </summary>
        /// <typeparam name="T">The visitors return type.</typeparam>
        /// <param name="visitor">The visitor instance.</param>
        /// <returns>The value returned from this method in the visitor used to visit this node.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="visitor"/> is <c>null</c>.</exception>
        public T AcceptVisitor <T>(ILSLValidatorNodeVisitor <T> visitor)
        {
            if (visitor == null)
            {
                throw new ArgumentNullException("visitor");
            }

            if (IsGlobal)
            {
                return(visitor.VisitGlobalVariableReference(this));
            }
            if (IsLocal)
            {
                return(visitor.VisitLocalVariableReference(this));
            }
            if (IsParameter)
            {
                return(visitor.VisitParameterVariableReference(this));
            }
            if (IsLibraryConstant)
            {
                return(visitor.VisitLibraryConstantVariableReference(this));
            }

            throw new InvalidOperationException(typeof(LSLVariableNode).Name +
                                                " could not be visited, its state is invalid");
        }