本文整理汇总了C#中System.Collections.Generic.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.Generic.ToArray方法的具体用法?C# System.Collections.Generic.ToArray怎么用?C# System.Collections.Generic.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Generic
的用法示例。
在下文中一共展示了System.Collections.Generic.ToArray方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetIdentityMappings
/// <summary>
/// Gets a mapping that can be used with NHibernate.
/// </summary>
/// <param name="additionalTypes">Additional Types that are to be added to the mapping, this is useful for adding your ApplicationUser class</param>
/// <returns></returns>
public static HbmMapping GetIdentityMappings(System.Type[] additionalTypes)
{
var baseEntityToIgnore = new[]
{
typeof(EntityWithTypedId<int>),
typeof(EntityWithTypedId<string>)
};
// Modified for NS: PIMS.Infrastructure.NHibernate.NHAspNetIdentity
var allEntities = new List<System.Type> {
typeof(IdentityUser),
typeof(IdentityRole),
typeof(IdentityUserLogin),
typeof(IdentityUserClaim),
};
allEntities.AddRange(additionalTypes);
var mapper = new ConventionModelMapper();
DefineBaseClass(mapper, baseEntityToIgnore.ToArray());
mapper.IsComponent((type, declared) => typeof(ValueObject).IsAssignableFrom(type));
// Modified for NS: PIMS.Infrastructure.NHibernate.NHAspNetIdentity
mapper.AddMapping<IdentityUserMap>();
mapper.AddMapping<IdentityRoleMap>();
mapper.AddMapping<IdentityUserClaimMap>();
return mapper.CompileMappingFor(allEntities);
}
示例2: IterationTest
public void IterationTest()
{
var testValues = new[] {1, 2, 3};
var enumerator = new List<int>(testValues.ToArray()).GetEnumerator();
using(var enumeratorWrapper = new EnumeratorWrapper<string>(enumerator, value => value.ToString()))
{
foreach(var testValue in testValues)
{
enumeratorWrapper.MoveNext();
Assert.AreEqual(testValue.ToString(CultureInfo.InvariantCulture), enumeratorWrapper.Current);
}
}
}
示例3: FindMinimumLatency_Case9
public void FindMinimumLatency_Case9()
{
// Assign
var gamsrv = new Gamsrv();
var lines = new[]
{
"25 40", "1 2 3 4 5 6 10 11 15 16 20 21 22 23 24 25",
"1 2 10", "2 3 10", "3 4 10", "4 5 10", "1 6 10", "2 7 10", "6 7 10",
"3 8 10", "7 8 10", "4 9 10", "8 9 10", "5 10 10", "9 10 10", "6 11 10",
"7 12 10", "11 12 10", "8 13 10", "12 13 10", "9 14 10", "13 14 10",
"10 15 10", "14 15 10", "11 16 10", "12 17 10", "16 17 10", "13 18 10",
"17 18 10", "14 19 10", "18 19 10", "15 20 10", "19 20 10", "16 21 10",
"17 22 10", "21 22 10", "18 23 10", "22 23 10", "19 24 10", "23 24 10",
"20 25 10", "24 25 10"
};
long expected = 40;
// Act
var actual = gamsrv.FindMinimumLatency(lines.ToArray());
// Assert
Assert.AreEqual(expected, actual);
}
示例4: can_except
public void can_except()
{
var x = new[] { 1, 2 }.Except(new[] { 2 });
Assert.AreEqual(1, x.ToArray()[0]);
}
示例5: cant_edit_IEnumerable_int
public void cant_edit_IEnumerable_int()
{
IEnumerable<int> sut = new [] {1};
sut.ToArray()[0] = 2;
Assert.IsFalse(sut.SequenceEqual(new []{2}));
}
示例6: SimulateKeyPress
/// <summary>
/// Simulate that a given key is pressed. (Down and up)
/// </summary>
public static void SimulateKeyPress( Key key )
{
var virtualKey = (ushort)KeyInterop.VirtualKeyFromKey( key );
var keyPress = new []
{
new User32.Input
{
Type = User32.InputEventType.Keyboard,
InputInformation = new User32.InputUnion
{
KeyboardInput = new User32.KeyboardInput
{
VirtualKey = virtualKey,
}
}
},
new User32.Input
{
Type = User32.InputEventType.Keyboard,
InputInformation = new User32.InputUnion
{
KeyboardInput = new User32.KeyboardInput
{
VirtualKey = virtualKey,
Flags = User32.KeyboardInputFlags.KeyUp
}
}
}
};
uint succeededEvents = User32.SendInput( (uint)keyPress.Length, keyPress.ToArray(), User32.Input.Size );
if ( keyPress.Length != 0 && succeededEvents != keyPress.Length )
{
MarshalHelper.ThrowLastWin32ErrorException();
}
}