本文整理汇总了C#中Test.List.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# Test.List.Contains方法的具体用法?C# Test.List.Contains怎么用?C# Test.List.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Test.List
的用法示例。
在下文中一共展示了Test.List.Contains方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetLanguageScriptList
/// <summary>
/// Returns language Script(font-name) used in dictionary
/// </summary>
/// <returns></returns>
public static string GetLanguageScriptList(string xhtmlFileNameWithPath, string projectInputType)
{
if (Path.GetFileName(xhtmlFileNameWithPath).IndexOf("Preserve") == 0)
{
xhtmlFileNameWithPath = xhtmlFileNameWithPath.Replace(Path.GetFileName(xhtmlFileNameWithPath),
Path.GetFileName(xhtmlFileNameWithPath).Replace(
"Preserve", ""));
}
string languageCode = string.Empty;
if (projectInputType.ToLower() == "dictionary")
{
List<string> langCodeList = new List<string>();
XmlDocument xDoc = Common.DeclareXMLDocument(true);
XmlNamespaceManager namespaceManager = new XmlNamespaceManager(xDoc.NameTable);
namespaceManager.AddNamespace("xhtml", "http://www.w3.org/1999/xhtml");
xDoc.Load(xhtmlFileNameWithPath);
XmlNodeList fontList = xDoc.GetElementsByTagName("meta");
for (int i = 0; i < fontList.Count; i++)
{
string langName = fontList[i].Attributes["name"].Value;
string langContent = fontList[i].Attributes["content"].Value;
if (langName.ToLower().IndexOf("dc.language") != 0)
continue;
if (langContent.IndexOf(':') > 0 && langContent.IndexOf('-') > 0)
{
if (!langCodeList.Contains(langContent))
{
langCodeList.Add(langContent);
languageCode = languageCode + langContent;
if (i < fontList.Count)
{
languageCode = languageCode + ",";
}
}
}
}
}
else
{
languageCode = Common.ParaTextEthnologueCodeName();
if (languageCode.Length > 0 && languageCode.IndexOf('-') > 0)
{
string[] val = languageCode.Split('-');
languageCode = val[1];
}
}
return languageCode;
}
示例2: GetFontList
public static string GetFontList(string xhtmlFileNameWithPath, string projectInputType, string finalOutput)
{
if (Path.GetFileName(xhtmlFileNameWithPath).IndexOf("Preserve") == 0)
{
xhtmlFileNameWithPath = xhtmlFileNameWithPath.Replace(Path.GetFileName(xhtmlFileNameWithPath),
Path.GetFileName(xhtmlFileNameWithPath).Replace(
"Preserve", ""));
}
string fontList = string.Empty;
if (finalOutput == ".epub")
{
List<string> langCodeList = new List<string>();
string[] epubFile = Directory.GetFiles(Path.GetDirectoryName(xhtmlFileNameWithPath), "*.epub");
string epubFileName = epubFile[0];
string extractFolder = Common.PathCombine(Path.GetDirectoryName(epubFileName), "Test");
if (File.Exists(epubFileName))
{
ZipUtil.UnZipFiles(epubFileName, extractFolder, "", false);
if (Directory.Exists(Common.PathCombine(extractFolder, "OEBPS")))
{
string[] ttfFiles = Directory.GetFiles(Common.PathCombine(extractFolder, "OEBPS"), "*.ttf");
if (ttfFiles.Length > 0)
{
for (int i = 0; i < ttfFiles.Length; i++)
{
string filename = Path.GetFileNameWithoutExtension(ttfFiles[i]);
if (filename.IndexOf('-') > 0)
{
filename = filename.Substring(0, filename.IndexOf('-'));
}
if (!langCodeList.Contains(filename))
{
langCodeList.Add(filename);
fontList = fontList + filename;
if (i < ttfFiles.Length - 1)
{
fontList = fontList + ";";
}
}
}
}
}
}
if (Directory.Exists(extractFolder))
{
DirectoryInfo di = new DirectoryInfo(extractFolder);
Common.CleanDirectory(di);
}
}
else
{
List<string> langCodeList = new List<string>();
XmlDocument xDoc = Common.DeclareXMLDocument(true);
XmlNamespaceManager namespaceManager = new XmlNamespaceManager(xDoc.NameTable);
namespaceManager.AddNamespace("xhtml", "http://www.w3.org/1999/xhtml");
xDoc.Load(xhtmlFileNameWithPath);
XmlNodeList fontNodeList = xDoc.GetElementsByTagName("meta");
for (int i = 0; i < fontNodeList.Count; i++)
{
if (fontNodeList[i].Attributes["scheme"] == null)
continue;
string langScheme = fontNodeList[i].Attributes["scheme"].Value;
string langContent = fontNodeList[i].Attributes["content"].Value;
if (langScheme.ToLower().IndexOf("language to font") != 0)
continue;
if (!langCodeList.Contains(langContent))
{
langCodeList.Add(langContent);
fontList = fontList + langContent;
if (i < fontNodeList.Count - 1)
{
fontList = fontList + ";";
}
}
}
}
return fontList;
}
示例3: GetLanguageCode
public static string GetLanguageCode(string xhtmlFileNameWithPath, string projectInputType, bool vernagular)
{
string languageCode = string.Empty;
if (File.Exists(xhtmlFileNameWithPath))
{
if (Path.GetFileName(xhtmlFileNameWithPath).IndexOf("Preserve") == 0)
{
xhtmlFileNameWithPath = xhtmlFileNameWithPath.Replace(Path.GetFileName(xhtmlFileNameWithPath),
Path.GetFileName(xhtmlFileNameWithPath)
.Replace(
"Preserve", ""));
}
List<string> langCodeList = new List<string>();
XmlDocument xDoc = Common.DeclareXMLDocument(true);
XmlNamespaceManager namespaceManager = new XmlNamespaceManager(xDoc.NameTable);
namespaceManager.AddNamespace("x", "http://www.w3.org/1999/xhtml");
xDoc.Load(xhtmlFileNameWithPath);
XmlNode node;
var vernacularLang = string.Empty;
if (vernagular)
{
node = xDoc.SelectSingleNode("//*[@class='headword']/@*[local-name()='lang']");
if (node != null)
{
vernacularLang = node.InnerText;
}
else
{
node = xDoc.SelectSingleNode("//*[@class='headref']/@*[local-name()='lang']");
if (node != null)
{
vernacularLang = node.InnerText;
}
else
{
node = xDoc.SelectSingleNode("//*[@class='Paragraph']//@*[local-name()='lang']");
if (node != null)
{
vernacularLang = node.InnerText;
}
}
}
}
XmlNodeList fontList = xDoc.GetElementsByTagName("meta");
for (int i = 0; i < fontList.Count; i++)
{
string langName = fontList[i].Attributes["name"].Value;
string langContent = fontList[i].Attributes["content"].Value;
if (langName.ToLower() == "dc.language")
{
if (vernagular)
{
if (langContent.Length < vernacularLang.Length ||
langContent.Substring(0, vernacularLang.Length) != vernacularLang)
{
continue;
}
if (langContent.Length >= vernacularLang.Length &&
langContent.Substring(vernacularLang.Length, 1) != ":")
{
continue;
}
}
if (!langCodeList.Contains(langContent))
{
langCodeList.Add(langContent);
languageCode = languageCode + langContent;
if (i < fontList.Count - 1)
{
languageCode = languageCode + ";";
}
}
}
}
}
else
{
languageCode = "eng";
}
return languageCode;
}
示例4: GetnamespacestoLocalize
public static string[] GetnamespacestoLocalize()
{
var namespacestoLocalize = new List<string>();
var pathwayDirectory = PathwayPath.GetPathwayDir();
if (pathwayDirectory == null || !Directory.Exists(pathwayDirectory))
return new[] { "SIL.PublishingSolution" };
foreach (var file in Directory.GetFiles(pathwayDirectory, "*.*").Where(f => Regex.IsMatch(f, @"^.+\.(dll|exe)$"))
)
{
var fileInfo = new FileInfo(file);
if ((fileInfo.Name == "PsTool.dll") || (fileInfo.Name.Contains("Convert")) ||
(fileInfo.Name.Contains("Writer")) || (fileInfo.Name.Contains("Validator")))
{
using (var epubinstalleddirectory = File.OpenRead(Common.FromRegistry(fileInfo.FullName)))
{
var sAssembly = Assembly.LoadFrom(epubinstalleddirectory.Name);
foreach (
var stype in
sAssembly.GetTypes()
.Where(type => type.GetConstructors().Any(s => s.GetParameters().Length == 0)))
{
if (!namespacestoLocalize.Contains(stype.Namespace))
namespacestoLocalize.Add(stype.Namespace);
}
}
}
}
return namespacestoLocalize.Distinct().ToArray();
}
示例5: CleanupExportFolder
/// <summary>
/// Delete all files in the folder except output
/// </summary>
/// <param name="outputFolder">Export folder path</param>
/// <param name="extension"> </param>
/// <param name="nameLike"> </param>
/// <param name="directory"> </param>
public static void CleanupExportFolder(string outputFolder, string extension, string nameLike, string directory)
{
//#if (DEBUG)
// return;
//#endif
List<string> lstExtn = new List<string>();
List<string> lstNamelike = new List<string>();
List<string> lstDirecorylike = new List<string>();
if (extension.Trim().Length > 0)
{
string[] extn = extension.Split(',');
lstExtn.AddRange(extn);
}
if (nameLike.Trim().Length > 0)
{
string[] name = nameLike.Split(',');
lstNamelike.AddRange(name);
}
if (directory.Trim().Length > 0)
{
string[] folder = directory.Split(',');
lstDirecorylike.AddRange(folder);
}
outputFolder = Path.GetDirectoryName(outputFolder);
string[] filePath = Directory.GetFiles(outputFolder);
foreach (string file in filePath)
{
try
{
string type = Path.GetExtension(file).ToLower();
if (lstExtn.Contains(type))
{
File.Delete(file);
}
string fi = Path.GetFileNameWithoutExtension(file).ToLower();
foreach (string filelike in lstNamelike)
{
if (fi.Contains(filelike.Trim().ToLower()))
{
File.Delete(file);
}
}
if (type == ".css" && !fi.ToLower().Contains("merged"))
{
File.Delete(file);
}
}
catch
{
}
}
string[] FolderList = Directory.GetDirectories(outputFolder);
foreach (string folderName in FolderList)
{
if (lstDirecorylike.Contains(Path.GetFileName(folderName)))
{
try
{
Directory.Delete(folderName, true);
}
catch
{
}
}
}
}
示例6: button5_Click
private void button5_Click(object sender, EventArgs e)
{
FileNames.Clear();
sourceFolder = "c:\\temp";
GetFilesFromFolder(sourceFolder);
// Get files from Xml
List<string> fileNamesXml = new List<string>();
XmlNode returnValue = null;
XmlDocument LoadedDoc = new XmlDocument();
LoadedDoc.Load("c:\\FileLibrary.xml");
const string xPath = "//FileLibrary";
XmlElement root = LoadedDoc.DocumentElement;
if (root != null)
{
returnValue = root.SelectSingleNode(xPath);
foreach (XmlNode xmlNode in returnValue.ChildNodes)
{
string path = xmlNode.Attributes.GetNamedItem("Path").Value;
fileNamesXml.Add(path);
}
}
//Find missing files in xml
foreach (string file in FileNames)
{
if (!fileNamesXml.Contains(file))
{
string newGuid = Guid.NewGuid().ToString();
//Add a File Node
XmlNode newNode = LoadedDoc.CreateNode("element", "File", "");
XmlAttribute xmlAttrib = LoadedDoc.CreateAttribute("Path");
xmlAttrib.Value = file;
newNode.Attributes.Append(xmlAttrib);
xmlAttrib = LoadedDoc.CreateAttribute("ComponentGuid");
xmlAttrib.Value = newGuid;
newNode.Attributes.Append(xmlAttrib);
root.LastChild.AppendChild(newNode);
}
}
LoadedDoc.Save("c:\\FileLibrary.xml");
}