ContainsFodyChecker.Check C# (CSharp) Method

Check() public method

public Check ( System.Xml.Linq.XDocument xDocument ) : bool
xDocument System.Xml.Linq.XDocument
return bool
    public bool Check(XDocument xDocument)
    {
        try
        {
            if (xDocument.BuildDescendants("Fody.WeavingTask").Any())
            {
                return true;
            }
            return xDocument.BuildDescendants("Import")
                .Any(x =>
                         {
                             var xAttribute = x.Attribute("Project");
                             return xAttribute != null && xAttribute.Value.EndsWith("Fody.targets");
                         });
        }
        catch (Exception exception)
        {
            throw new Exception("Could not check project for weaving task.", exception);
        }
    }

Usage Example

コード例 #1
0
ファイル: MenuStatusChecker.cs プロジェクト: yanglee/Fody
 public void DisableCommandStatusCheck(OleMenuCommand disableCommand)
 {
     try
     {
         disableCommand.Enabled = false;
         foreach (var project in currentProjectFinder.GetCurrentProjects())
         {
             var xmlForProject = LoadXmlForProject(project);
             if (xmlForProject != null)
             {
                 if (containsFodyChecker.Check(xmlForProject))
                 {
                     disableCommand.Enabled = true;
                     return;
                 }
             }
         }
     }
     catch (COMException exception)
     {
         exceptionDialog.HandleException(exception);
     }
     catch (Exception exception)
     {
         exceptionDialog.HandleException(exception);
     }
 }
ContainsFodyChecker