コード例 #1
0
        private static bool FailsToCallDispose(LanguageElement element)
        {
            LanguageElement parentElement = element.GetParentCodeBlock();
            IEnumerable     allStatements = GetAllStatements(parentElement);

            if (allStatements == null)
            {
                return(false);
            }
            foreach (Statement statement in allStatements)
            {
                if (statement is MethodCall)
                {
                    LanguageElement firstChild = statement.FirstChild;
                    if (firstChild is MethodReferenceExpression && firstChild.Name == "Dispose")
                    {
                        LanguageElement nextChild = firstChild.FirstChild;
                        if (nextChild is ElementReferenceExpression && nextChild.Name == element.Name)
                        {
                            return(false);  // We found a call to Dispose....
                        }
                    }
                }
            }
            return(true);
        }
 private static bool FailsToCallDispose(LanguageElement element) {
     LanguageElement parentElement = element.GetParentCodeBlock();
     IEnumerable allStatements = GetAllStatements(parentElement);
     if (allStatements == null)
         return false;
     foreach (Statement statement in allStatements)
         if (statement is MethodCall) {
             LanguageElement firstChild = statement.FirstChild;
             if (firstChild is MethodReferenceExpression && firstChild.Name == "Dispose") {
                 LanguageElement nextChild = firstChild.FirstChild;
                 if (nextChild is ElementReferenceExpression && nextChild.Name == element.Name)
                     return false;  // We found a call to Dispose....
             }
         }
     return true;
 }