Microsoft.Zing.Checker.VisitForEach C# (CSharp) Méthode

VisitForEach() public méthode

public VisitForEach ( System.Compiler.ForEach forEach ) : System.Compiler.Statement
forEach System.Compiler.ForEach
Résultat System.Compiler.Statement
        public override Statement VisitForEach(ForEach forEach)
        {
            if (forEach == null) return null;
            forEach.TargetVariableType = this.VisitTypeReference(forEach.TargetVariableType);
            forEach.TargetVariable = this.VisitTargetExpression(forEach.TargetVariable);
            forEach.SourceEnumerable = this.VisitExpression(forEach.SourceEnumerable);
            if (forEach.TargetVariableType == null || forEach.TargetVariable == null || forEach.SourceEnumerable == null)
                return null;

            TypeNode collectionType = forEach.SourceEnumerable.Type;
            Set setCollection = collectionType as Set;
            ZArray arrayCollection = collectionType as ZArray;

            TypeNode memberType = null;
            if (setCollection != null)
                memberType = setCollection.SetType;
            if (arrayCollection != null)
                memberType = arrayCollection.ElementType;

            if (memberType == null)
            {
                this.HandleError(forEach.SourceEnumerable, Error.InvalidForeachSource);
                return null;
            }

            if (memberType != forEach.TargetVariableType)
            {
                this.HandleError(forEach.TargetVariable, Error.InvalidForeachTargetType);
                return null;
            }

            forEach.Body = this.VisitBlock(forEach.Body);
            return forEach;
        }