本文整理汇总了C#中ReadOnlyCollection.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# ReadOnlyCollection.Contains方法的具体用法?C# ReadOnlyCollection.Contains怎么用?C# ReadOnlyCollection.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReadOnlyCollection
的用法示例。
在下文中一共展示了ReadOnlyCollection.Contains方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestContains
public void TestContains() {
int[] integers = new int[] { 1234, 6789 };
ReadOnlyCollection<int> testCollection = new ReadOnlyCollection<int>(integers);
Assert.IsTrue(testCollection.Contains(1234));
Assert.IsFalse(testCollection.Contains(4321));
}
示例2: ProcessCommandLine
private void ProcessCommandLine(ReadOnlyCollection<string> commandLine)
{
if (commandLine.Count > 0)
{
if (commandLine.Contains("-nosplash"))
TabsterEnvironment.NoSplash = true;
if (commandLine.Contains("-safemode"))
TabsterEnvironment.SafeMode = true;
ProcessFirstArgForFile(commandLine[0]);
}
}
示例3: AddFormatSpecifier
internal static ReadOnlyCollection<string> AddFormatSpecifier(ReadOnlyCollection<string> formatSpecifiers, string formatSpecifier)
{
if (formatSpecifiers.Contains(formatSpecifier))
{
return formatSpecifiers;
}
var builder = ArrayBuilder<string>.GetInstance();
builder.AddRange(formatSpecifiers);
builder.Add(formatSpecifier);
return builder.ToImmutableAndFree();
}
示例4: FindFullMatchIndex
public override int FindFullMatchIndex(ReadOnlyCollection<int> matchIndexes)
{
var fullMatch = this.ComboBox.Items.OfType<DataItem>().FirstOrDefault(i => i.Title.Length == charLenght);
if (fullMatch == null)
{
return -1;
}
var fullMatchIndex = this.ComboBox.Items.IndexOf(fullMatch);
if (matchIndexes.Contains(fullMatchIndex))
{
return fullMatchIndex;
}
return -1;
}
示例5: AddressesChanged
public bool AddressesChanged(ReadOnlyCollection<IPAddress> addresses)
{
lock (this.ThisLock)
{
if (addresses.Count != this.localAddresses.Length)
{
return true;
}
foreach (IPAddress address in this.localAddresses)
{
if (!addresses.Contains(address))
{
return true;
}
}
}
return false;
}
示例6: InitializeViews
internal List<ILayoutPanelElement> InitializeViews()
{
ReadOnlyCollection<string> enabledWidgets = new ReadOnlyCollection<string>(SettingsManager.Instance.GetSetting("CustomOperationViewer", "WidgetConfiguration").GetValue<ExportConfiguration>().GetEnabledExports());
foreach (ExportedType export in ExportedTypeLibrary.GetExports(typeof(IUIWidget)).Where(j => enabledWidgets.Contains(j.Attribute.Alias)))
{
var iuiWidget = export.CreateInstance<IUIWidget>();
string jobName = iuiWidget.GetType().Name;
Logger.Instance.LogFormat(LogType.Info, this, "Initializing ViewPlugin type '{0}'...", jobName);
try
{
if (!iuiWidget.Initialize())
{
Logger.Instance.LogFormat(LogType.Warning, this, "ViewPlugin type '{0}' initialization failed. The ViewPlugin will not be executed.", jobName);
continue;
}
var pane =
new LayoutAnchorablePane(new LayoutAnchorable
{
Content = iuiWidget.UIElement,
ContentId = iuiWidget.ContentGuid,
Title = iuiWidget.Title,
CanClose = false,
CanHide = false
});
_PanelElements.Add(pane);
_Widgets.Add(iuiWidget);
Logger.Instance.LogFormat(LogType.Info, this, "ViewPlugin type '{0}' initialization successful.", jobName);
}
catch (Exception ex)
{
Logger.Instance.LogFormat(LogType.Error, this, "An error occurred while initializing ViewPlugin type '{0}'. The error message was: {1}", jobName, ex.Message);
}
}
return _PanelElements;
}
示例7: TestCollection
public void TestCollection()
{
// Default ctor.
var data = Enumerable.Range(1, 5).ToArray();
var col = new ReadOnlyCollection<int>(data);
Assert.AreEqual(5, col.Count);
Assert.IsTrue(col.IsReadOnly);
CollectionAssert.AreEqual(data, col);
Assert.IsTrue(col.GetEnumerator().MoveNext());
Assert.IsTrue(((IEnumerable) col).GetEnumerator().MoveNext());
Assert.IsTrue(col.Contains(4));
var arr = new int[5];
col.CopyTo(arr, 0);
CollectionAssert.AreEqual(data, arr);
Assert.Throws<NotSupportedException>(() => col.Add(1));
Assert.Throws<NotSupportedException>(() => col.Clear());
Assert.Throws<NotSupportedException>(() => col.Remove(1));
}
示例8: goToNewlyOpenedWindowhandle
private static void goToNewlyOpenedWindowhandle(
ReadOnlyCollection<string> currentWindowHandles)
{
if (null != CurrentData.CurrentWebDriver.WindowHandles &&
currentWindowHandles.Count < CurrentData.CurrentWebDriver.WindowHandles.Count) {
string newWindowhandle = string.Empty;
// go to a newly opened window handle
foreach (string windowhandle in CurrentData.CurrentWebDriver.WindowHandles) {
if (!currentWindowHandles.Contains(windowhandle)) {
newWindowhandle = windowhandle;
break;
}
}
currentWindowHandles = CurrentData.CurrentWebDriver.WindowHandles;
CurrentData.CurrentWebDriver.SwitchTo().Window(newWindowhandle);
}
}
示例9: TreeFile
public TreeFile(UpdateFile uf, ReadOnlyCollection<string> updateFiles, string newBasePath)
{
FullPath = uf.RelativePath.Replace('/', '\\');
Size = uf.Length;
if (!updateFiles.Contains(Path.Combine(newBasePath, uf.RelativePath), StringComparer.OrdinalIgnoreCase))
State = (int)FileState.Deleted;
else if (uf.Matches(newBasePath))
State = (int)FileState.Identical;
else
State = (int)FileState.Changed;
}
示例10: ContainsUsesEqualsMethod
public void ContainsUsesEqualsMethod() {
var l = new ReadOnlyCollection<C>(new[] { new C(1), new C(2), new C(3) });
Assert.IsTrue(l.Contains(new C(2)));
Assert.IsFalse(l.Contains(new C(4)));
}
示例11: ContainsWorks
public void ContainsWorks() {
var l = new ReadOnlyCollection<string>(new[] { "x", "y" });
Assert.IsTrue(l.Contains("x"));
Assert.IsFalse(l.Contains("z"));
}
示例12: ICollectionContainsWorks
public void ICollectionContainsWorks() {
IList<string> l = new ReadOnlyCollection<string>(new[] { "x", "y", "z" });
Assert.IsTrue(l.Contains("y"));
Assert.IsFalse(l.Contains("a"));
}
示例13: checkContains
private static int checkContains(ReadOnlyCollection<String> coll, String str)
{
if (!coll.Contains(str))
{
return -1;
}
else
{
return coll.IndexOf(str);
}
}
示例14: manager_RoleGrantsRefreshed
void manager_RoleGrantsRefreshed(ReadOnlyCollection<UserRole> affected)
{
if (affected.Contains(this))
{
privManager.DownloadPrivileges();
roleManager.DownloadData();
}
}