本文整理汇总了C#中System.Collections.Specialized.StringCollection.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# StringCollection.Contains方法的具体用法?C# StringCollection.Contains怎么用?C# StringCollection.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Specialized.StringCollection
的用法示例。
在下文中一共展示了StringCollection.Contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddAssemblyReference
private static void AddAssemblyReference(Assembly referencedAssembly, StringCollection referencedAssemblies)
{
string path = Path.GetFullPath(referencedAssembly.Location);
string name = Path.GetFileName(path);
if (!(referencedAssemblies.Contains(name) || referencedAssemblies.Contains(path)))
{
referencedAssemblies.Add(path);
}
}
示例2: GetLinksFromHTML
public static StringCollection GetLinksFromHTML(string HtmlContent)
{
StringCollection links = new StringCollection();
MatchCollection AnchorTags = Regex.Matches(HtmlContent.ToLower(), @"(<a.*?>.*?</a>)", RegexOptions.Singleline);
MatchCollection ImageTags = Regex.Matches(HtmlContent.ToLower(), @"(<img.*?>)", RegexOptions.Singleline);
foreach (Match AnchorTag in AnchorTags)
{
string value = AnchorTag.Groups[1].Value;
Match HrefAttribute = Regex.Match(value, @"href=\""(.*?)\""",
RegexOptions.Singleline);
if (HrefAttribute.Success)
{
string HrefValue = HrefAttribute.Groups[1].Value;
HrefValue = HrefValue.Replace(@"\0026", "&");
var ascii = Regex.Match(HrefValue, @"?\d\d;", RegexOptions.Singleline);
if (ascii.Success)
{
string chr = ascii.Groups[0].ToString().Remove(0, 2);
chr = chr.Remove(chr.Length-1);
int ichr = int.Parse(chr);
char decodedChar = (char)ichr;
HrefValue = HrefValue.Replace(ascii.Groups[0].ToString(), decodedChar.ToString());
}
HrefValue = HrefValue.Replace(":", ":");
if (!links.Contains(HrefValue))
{
links.Add(HrefValue);
}
}
}
foreach (Match ImageTag in ImageTags)
{
string value = ImageTag.Groups[1].Value;
Match SrcAttribute = Regex.Match(value, @"src=\""(.*?)\""",
RegexOptions.Singleline);
if (SrcAttribute .Success)
{
string SrcValue = SrcAttribute.Groups[1].Value;
if (!links.Contains(SrcValue))
{
links.Add(SrcValue);
}
}
}
return links;
}
示例3: Test_04_GetUserRoles
[Test] public void Test_04_GetUserRoles()
{
Proxy.AdminRef.Admin admin = new Proxy.AdminRef.Admin( );
admin.Url = Globals.AdminUrl();
admin.Credentials = System.Net.CredentialCache.DefaultCredentials.GetCredential(new Uri(Globals.SharePointTestServer), "");
string[] roles = admin.GetUserRoles(Globals.SiteCollectionForCreationTests(), @"WSDEV\lnpair");
Assert.IsTrue(roles.Length == 2, "The user is both a Reader and a Contributor");
StringCollection roleList = new StringCollection();
roleList.AddRange(roles);
Assert.IsTrue(roleList.Contains("Read"), @"WSDEV\lnpair is a Reader on this site. Really!");
Assert.IsTrue(roleList.Contains("Contribute"), @"WSDEV\lnpair is a Contributor on this site. Really!");
}
示例4: Test_03_ListUsers
[Test] public void Test_03_ListUsers()
{
Proxy.AdminRef.Admin admin = new Proxy.AdminRef.Admin( );
admin.Url = Globals.AdminUrl();
admin.Credentials = System.Net.CredentialCache.DefaultCredentials.GetCredential(new Uri(Globals.SharePointTestServer), "");
string[] users = admin.ListUsers(Globals.SiteCollectionForCreationTests());
Assert.IsTrue(users.Length == 2, "There are two users in the list.");
StringCollection userList = new StringCollection();
for(int i = 0; i < users.Length; ++i)
{
userList.Add(users[i]);
}
Assert.IsTrue(userList.Contains(@"WSDEV\lnpair"), "Contributor user is missing.");
Assert.IsTrue(userList.Contains(@"UK\iainb"), "Contributor user is missing.");
}
示例5: Copy
public static void Copy(StringCollection frList, StringCollection toList)
{
if (frList == null) return;
for (int idx = 0; idx < frList.Count; idx++)
{
if (toList.Contains(frList[idx]) == false) toList.Add(frList[idx]);
}
}
示例6: EvaluatePath
/// <summary>
/// Evaulate the path string in relation to the current item
/// </summary>
/// <param name="context">The Revolver context to evaluate the path against</param>
/// <param name="path">The path to evaulate. Can either be absolute or relative</param>
/// <returns>The full sitecore path to the target item</returns>
public static string EvaluatePath(Context context, string path)
{
if (ID.IsID(path))
return path;
string workingPath = string.Empty;
if (!path.StartsWith("/"))
workingPath = context.CurrentItem.Paths.FullPath + "/" + path;
else
workingPath = path;
// Strip any language and version tags
if (workingPath.IndexOf(':') >= 0)
workingPath = workingPath.Substring(0, workingPath.IndexOf(':'));
// Make relative paths absolute
string[] parts = workingPath.Split('/');
StringCollection targetParts = new StringCollection();
targetParts.AddRange(parts);
while (targetParts.Contains(".."))
{
int ind = targetParts.IndexOf("..");
targetParts.RemoveAt(ind);
if (ind > 0)
{
targetParts.RemoveAt(ind - 1);
}
}
if (targetParts[targetParts.Count - 1] == ".")
targetParts.RemoveAt(targetParts.Count - 1);
// Remove empty elements
while (targetParts.Contains(""))
{
targetParts.RemoveAt(targetParts.IndexOf(""));
}
string[] toRet = new string[targetParts.Count];
targetParts.CopyTo(toRet, 0);
return "/" + string.Join("/", toRet);
}
示例7: Clone
public static StringCollection Clone(StringCollection list)
{
if (list == null) return null;
StringCollection retList = new StringCollection();
for (int idx = 0; idx < list.Count; idx++)
{
if (retList.Contains(list[idx]) == false) retList.Add(list[idx]);
}
return retList;
}
示例8: Convert
private static TheBox.Data.Facet Convert( LocationsList list )
{
TheBox.Data.Facet f = new TheBox.Data.Facet();
StringCollection categories = new StringCollection();
foreach( Location loc in list.Places )
{
if ( ! categories.Contains( loc.Category ) )
{
categories.Add( loc.Category );
}
}
foreach( string cat in categories )
{
TheBox.Common.GenericNode g = new TheBox.Common.GenericNode( cat );
f.Nodes.Add( g );
}
foreach( TheBox.Common.GenericNode g in f.Nodes )
{
StringCollection sub = new StringCollection();
foreach( Location loc in list.Places )
{
if ( loc.Category == g.Name && ! sub.Contains( loc.Subsection ) )
{
sub.Add( loc.Subsection );
}
}
foreach( string s in sub )
{
TheBox.Common.GenericNode gSub = new TheBox.Common.GenericNode( s );
g.Elements.Add( gSub );
}
}
foreach( TheBox.Common.GenericNode gCat in f.Nodes )
{
foreach( TheBox.Common.GenericNode gSub in gCat.Elements )
{
foreach( Location loc in list.Places )
{
if ( loc.Category == gCat.Name && loc.Subsection == gSub.Name )
{
gSub.Elements.Add( Convert( loc ) );
}
}
}
}
return f;
}
示例9: CompareColumns
private static bool CompareColumns(DataTable source, DataRow sourcerow, DataRow destrow, StringCollection ignorecolumns)
{
foreach(DataColumn column in source.Columns) {
// Not in ignored columns?
if(ignorecolumns == null || !ignorecolumns.Contains(column.ColumnName)) {
if(sourcerow[column.ColumnName].ToString() != destrow[column.ColumnName].ToString())
return false;
}
}
return true; // All columns matching
}
示例10: HasHorizontalVisibility
public bool HasHorizontalVisibility(StringCollection activeAgentFacets)
{
char[] lDelimiter = { ',' };
string[] lAgents = EmptyHorizontalVisibility.Split(lDelimiter);
for (int i = 0; i < lAgents.Length; i++)
{
if (activeAgentFacets.Contains(lAgents[i].Trim()))
return false;
}
lAgents = HorizontalVisibility.Split(lDelimiter);
for (int i = 0; i < lAgents.Length; i++)
{
if (activeAgentFacets.Contains(lAgents[i].Trim()))
return true;
}
return false;
}
示例11: GetDepartmentCostCentre
private static ACostCentreRow GetDepartmentCostCentre(ACostCentreTable ACostCentres,
ACostCentreRow ACostCentreToInvestigate,
StringCollection ADepartmentCodes)
{
if (ADepartmentCodes.Contains(ACostCentreToInvestigate.CostCentreCode))
{
return ACostCentreToInvestigate;
}
ACostCentreRow row = (ACostCentreRow)ACostCentres.DefaultView.FindRows(ACostCentreToInvestigate.CostCentreToReportTo)[0].Row;
return GetDepartmentCostCentre(ACostCentres, row, ADepartmentCodes);
}
示例12: AddAssemblyToStringCollection
internal static void AddAssemblyToStringCollection(Assembly assembly, StringCollection toList)
{
string path = null;
if (!MultiTargetingUtil.EnableReferenceAssemblyResolution)
{
path = GetAssemblyCodeBase(assembly);
}
else if (AssemblyResolver.GetPathToReferenceAssembly(assembly, out path) == ReferenceAssemblyType.FrameworkAssemblyOnlyPresentInHigherVersion)
{
return;
}
if (!toList.Contains(path))
{
toList.Add(path);
}
}
示例13: Test_01_ListAvailableSiteTemplates
[Test] public void Test_01_ListAvailableSiteTemplates()
{
Proxy.AdminRef.Admin admin = new Proxy.AdminRef.Admin( );
admin.Url = Globals.AdminUrl();
admin.Credentials = System.Net.CredentialCache.DefaultCredentials.GetCredential(new Uri(Globals.SharePointTestServer), "");
string[] templates = admin.ListAvailableSiteTemplates(Globals.SiteCollectionForTests());
StringCollection tpls = new StringCollection();
tpls.AddRange(templates);
Assert.IsTrue(tpls.Contains("Team Site"), "Template is missing: Team Site");
Assert.IsTrue(tpls.Contains("Blank Site"), "Template is missing: Blank Site");
Assert.IsTrue(tpls.Contains("Document Workspace"), "Template is missing: Document Workspace");
Assert.IsTrue(tpls.Contains("Basic Meeting Workspace"), "Template is missing: Basic Meeting Workspace");
Assert.IsTrue(tpls.Contains("Blank Meeting Workspace"), "Template is missing: Blank Meeting Workspace");
Assert.IsTrue(tpls.Contains("Decision Meeting Workspace"), "Template is missing: Decision Meeting Workspace");
Assert.IsTrue(tpls.Contains("Social Meeting Workspace"), "Template is missing: Social Meeting Workspace");
Assert.IsTrue(tpls.Contains("Multipage Meeting Workspace"), "Template is missing: Multipage Meeting Workspace");
}
示例14: LoadPingServices
// Loads the ping services into a StringCollection
public override StringCollection LoadPingServices()
{
string fileName = _Folder + "PingServices.xml";
if (!File.Exists(fileName))
return new StringCollection();
StringCollection col = new StringCollection();
XmlDocument doc = new XmlDocument();
doc.Load(fileName);
foreach (XmlNode node in doc.SelectNodes("services/service"))
{
if (!col.Contains(node.InnerText))
col.Add(node.InnerText);
}
return col;
}
示例15: DisabledKey
/// <summary>
/// The disabled key.
/// </summary>
/// <param name="disabledKey">
/// The the key that will be used to maanage the disabled field.
/// </param>
/// <param name="fieldName">
/// The field name.
/// </param>
public void DisabledKey(string disabledKey, string fieldName)
{
var currentDisabledKeys = new StringCollection();
if (this.disabledKeys.ContainsKey(fieldName))
{
currentDisabledKeys = this.disabledKeys[fieldName] as StringCollection;
this.disabledKeys.Remove(fieldName);
}
if (currentDisabledKeys != null && !currentDisabledKeys.Contains(disabledKey))
{
currentDisabledKeys.Add(disabledKey);
}
this.disabledKeys.Add(fieldName, currentDisabledKeys);
}