本文整理汇总了C#中RubyArray.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# RubyArray.Contains方法的具体用法?C# RubyArray.Contains怎么用?C# RubyArray.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RubyArray
的用法示例。
在下文中一共展示了RubyArray.Contains方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RubyArray_Basic
public void RubyArray_Basic() {
RubyArray a;
a = new RubyArray(new object[] { 1, 2, 8 });
Assert(!a.IsTainted && !a.IsFrozen && !a.IsReadOnly && !((IList)a).IsFixedSize && !((ICollection)a).IsSynchronized);
Assert(ReferenceEquals(((ICollection)a).SyncRoot, a));
a.IsTainted = true;
Assert(a.IsTainted);
a.IsTainted = false;
Assert(!a.IsTainted);
a[1] = 5;
Assert((int)a[0] == 1 && (int)a[1] == 5 && (int)a[2] == 8);
((IRubyObjectState)a).Freeze();
Assert(a.IsFrozen);
AssertExceptionThrown<RuntimeError>(() => a.IsTainted = true);
Assert(!a.IsTainted);
AssertExceptionThrown<RuntimeError>(() => a[1] = 1);
Assert((int)a[0] == 1 && (int)a[1] == 5 && (int)a[2] == 8);
var values = new object[] { 1, 5, 8 };
int i = 0;
foreach (object item in a) {
Assert(item.Equals(values[i]));
i++;
}
Assert(i == values.Length);
Assert(((IEnumerable)a).GetEnumerator() != null);
AssertValueEquals(a, values);
object[] array = new object[4];
((ICollection)a).CopyTo(array, 1);
Assert(ArrayUtils.ValueEquals(ArrayUtils.ShiftLeft(array, 1), values));
Assert(a.Contains(5));
Assert(a.IndexOf(5) == 1);
Assert(a.IndexOf(5, 2) == -1);
Assert(a.IndexOf(5, 0, 1) == -1);
Assert(a.FindIndex((x) => (int)x == 8) == 2);
Assert(a.FindIndex(2, (x) => (int)x == 8) == 2);
Assert(a.FindIndex(0, 2, (x) => (int)x == 8) == -1);
}
示例2: GetIncludedModules
public static RubyArray/*!*/ GetIncludedModules(RubyModule/*!*/ self) {
RubyArray ancestorModules = new RubyArray();
self.ForEachAncestor(true, delegate(RubyModule/*!*/ module) {
if (module != self && !module.IsClass && !ancestorModules.Contains(module)) {
ancestorModules.Add(module);
}
return false;
});
return ancestorModules;
}
示例3: GetIncludedModules
public static RubyArray GetIncludedModules(RubyModule/*!*/ self)
{
RubyArray ancestorModules = new RubyArray();
using (self.Context.ClassHierarchyLocker()) {
self.ForEachAncestor(true, delegate(RubyModule/*!*/ module) {
if (module != self && !module.IsClass && !ancestorModules.Contains(module)) {
ancestorModules.Add(module);
}
return false;
});
}
return ancestorModules;
}