CCM.Driver.PathShouldBeExcluded C# (CSharp) Method

PathShouldBeExcluded() public method

public PathShouldBeExcluded ( string path ) : bool
path string
return bool
        public bool PathShouldBeExcluded(string path)
        {
            if (this.configFile != null)
              {
            string[] pathFolderNames = path
              .Split(new char[] { Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries);

            foreach (string pathToExclude in this.configFile.ExcludeFolders)
            {
              if (path.ToLower().StartsWith(pathToExclude.ToLower()))
            return true;

              if (pathFolderNames.Contains(pathToExclude, StringComparer.InvariantCultureIgnoreCase))
            return true;
            }
              }

              return false;
        }

Usage Example

Exemplo n.º 1
0
        public void ExcludedFolderOnlyExcludesWhereNameOfFolderIsExactMatch()
        {
            string config = "<ccm>" +
                      "  <exclude>" +
                      "    <folder>Foo</folder> " +
                      "    <folder>Bar</folder> " +
                      "  </exclude>" +
                      "</ccm>";

              XmlDocument doc = new XmlDocument();
              doc.LoadXml(config);

              ConfigurationFile file = new ConfigurationFile(doc);
              Driver driver = new Driver(file);

              Assert.IsTrue(driver.PathShouldBeExcluded("c:\\code\\Foo\\file.cpp"));
              Assert.IsTrue(driver.PathShouldBeExcluded("c:\\code\\bar\\file.cpp"));
              Assert.IsFalse(driver.PathShouldBeExcluded("c:\\code\\FooBar\\fileB.cs"));
              Assert.IsFalse(driver.PathShouldBeExcluded("c:\\code\\BarA\\fileB.cs"));
        }
All Usage Examples Of CCM.Driver::PathShouldBeExcluded