/// <summary>
        /// Checks for errors before applying a rule.
        /// </summary>
        /// <param name="node">The node instance to check.</param>
        /// <param name="dataList">Optional data collected during inspection of sources.</param>
        /// <param name="data">Private data to give to Apply() upon return.</param>
        /// <returns>True if an error occured.</returns>
        public override bool CheckConsistency(IAttachmentInstruction node, IDictionary <ISourceTemplate, object> dataList, out object data)
        {
            data = null;
            bool Success = true;

            IExpression AttachmentSource = (IExpression)node.Source;
            IResultType SourceTypeList   = AttachmentSource.ResolvedResult.Item;
            IClass      EmbeddingClass   = node.EmbeddingClass;

            IList <IList <ITypeName> >     FullAttachmentTypeNameList = new List <IList <ITypeName> >();
            IList <IList <ICompiledType> > FullAttachmentTypeList     = new List <IList <ICompiledType> >();

            if (SourceTypeList.Count < node.EntityNameList.Count)
            {
                AddSourceError(new ErrorInvalidInstruction(node));
                Success = false;
            }
            else
            {
                for (int i = 0; i < node.EntityNameList.Count; i++)
                {
                    IList <ITypeName>     AttachmentTypeNameList = new List <ITypeName>();
                    IList <ICompiledType> AttachmentTypeList     = new List <ICompiledType>();

                    FullAttachmentTypeNameList.Add(AttachmentTypeNameList);
                    FullAttachmentTypeList.Add(AttachmentTypeList);
                }

                for (int i = 0; i < node.EntityNameList.Count; i++)
                {
                    IExpressionType       Item     = SourceTypeList.At(i);
                    IName                 ItemName = node.EntityNameList[i];
                    IList <ITypeName>     AttachmentTypeNameList = FullAttachmentTypeNameList[i];
                    IList <ICompiledType> AttachmentTypeList     = FullAttachmentTypeList[i];

                    foreach (IAttachment Attachment in node.AttachmentList)
                    {
                        IObjectType AttachedType = Attachment.AttachTypeList[i];
                        ISealableDictionary <string, IScopeAttributeFeature> CheckedScope = Attachment.FullScope;

                        IList <IClass> AssignedSingleClassList = new List <IClass>();
                        IErrorList     CheckErrorList          = new ErrorList();
                        if (ScopeHolder.HasConflictingSingleAttributes(CheckedScope, node.InnerScopes, AssignedSingleClassList, node, CheckErrorList))
                        {
                            AddSourceErrorList(CheckErrorList);
                            Success = false;
                        }

                        AttachmentTypeNameList.Add(AttachedType.ResolvedTypeName.Item);
                        AttachmentTypeList.Add(AttachedType.ResolvedType.Item);
                    }
                }

                data = new Tuple <IList <IList <ITypeName> >, IList <IList <ICompiledType> > >(FullAttachmentTypeNameList, FullAttachmentTypeList);
            }

            return(Success);
        }
        /// <summary>
        /// Checks for errors before applying a rule.
        /// </summary>
        /// <param name="node">The node instance to check.</param>
        /// <param name="dataList">Optional data collected during inspection of sources.</param>
        /// <param name="data">Private data to give to Apply() upon return.</param>
        /// <returns>True if an error occured.</returns>
        public override bool CheckConsistency(IForLoopInstruction node, IDictionary <ISourceTemplate, object> dataList, out object data)
        {
            bool Success = true;

            data = null;

            IClass EmbeddingClass = node.EmbeddingClass;
            ISealableDictionary <string, IScopeAttributeFeature> CheckedScope = new SealableDictionary <string, IScopeAttributeFeature>();

            foreach (IEntityDeclaration Item in node.EntityDeclarationList)
            {
                IScopeAttributeFeature LocalEntity = Item.ValidEntity.Item;
                string ValidFeatureName            = LocalEntity.ValidFeatureName.Item.Name;

                if (CheckedScope.ContainsKey(ValidFeatureName))
                {
                    AddSourceError(new ErrorVariableAlreadyDefined(Item, ValidFeatureName));
                    Success = false;
                }
                else
                {
                    CheckedScope.Add(ValidFeatureName, LocalEntity);
                }
            }

            IList <string> ConflictList = new List <string>();

            ScopeHolder.RecursiveCheck(CheckedScope, node.InnerScopes, ConflictList);

            foreach (IEntityDeclaration Item in node.EntityDeclarationList)
            {
                IScopeAttributeFeature LocalEntity = Item.ValidEntity.Item;
                string ValidFeatureName            = LocalEntity.ValidFeatureName.Item.Name;

                if (ConflictList.Contains(ValidFeatureName))
                {
                    AddSourceError(new ErrorVariableAlreadyDefined(Item, ValidFeatureName));
                    Success = false;
                }
            }

            IList <IClass> AssignedSingleClassList = new List <IClass>();
            IErrorList     CheckErrorList          = new ErrorList();

            if (ScopeHolder.HasConflictingSingleAttributes(CheckedScope, node.InnerScopes, AssignedSingleClassList, node, CheckErrorList))
            {
                AddSourceErrorList(CheckErrorList);
                Success = false;
            }

            if (Success)
            {
                data = CheckedScope;
            }

            return(Success);
        }