本文整理汇总了C#中Group.Select方法的典型用法代码示例。如果您正苦于以下问题:C# Group.Select方法的具体用法?C# Group.Select怎么用?C# Group.Select使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Group
的用法示例。
在下文中一共展示了Group.Select方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ICollectionOfT_CopyTo
public static void ICollectionOfT_CopyTo()
{
string[] expected = new[] { "212-555-6666", "212", "555-6666" };
ICollection<Group> collection = CreateCollection();
Group[] array = new Group[collection.Count];
collection.CopyTo(array, 0);
Assert.Equal(expected, array.Select(c => c.ToString()));
}
示例2: TestLinqueExpressionSelect
public void TestLinqueExpressionSelect()
{
var group1 = new Group(1, 1, new[]
{
new Student("Иван1", "Иванов", 9.0),
new Student("Иван2", "Иванов", 3.0),
new Student("Иван3", "Иванов", 2.0),
new Student("Иван4", "Иванов", 6.0),
new Student("Иван5", "Иванов", 10.0),
new Student("Иван6", "Иванов", 6.0)
});
var group2 = new Group(1, 1, new[]
{
new Student("Иван1", "Иванов", 9.0),
new Student("Иван5", "Иванов", 10.0),
});
var requestGroupSelect = group1.Select(student => new {student.Name, student.Surname});
foreach (var student in group2)
{
var first =
requestGroupSelect.FirstOrDefault(
student1 => student1.Name == student.Name && student1.Surname == student.Surname);
Assert.AreNotEqual(null, first);
}
}
示例3: XliffElement_SelectElement
public void XliffElement_SelectElement()
{
File file;
Group group;
Unit unit;
Segment segment;
Ignorable ignorable;
TestXliffElement element;
element = new TestXliffElement();
element.Document = new XliffDocument();
Console.WriteLine("Test with no items.");
Assert.IsNull(element.CallSelectElement("#/file"));
Console.WriteLine("Test with file items.");
file = new File("file");
element.Document.Files.Add(file);
Assert.AreEqual(file, element.CallSelectElement("#/f=file"));
Console.WriteLine("Test with relative path to file item.");
Assert.AreEqual(file, element.Document.Select("#f=file"));
Console.WriteLine("Test with many items.");
group = new Group("group");
file.Containers.Add(new Group());
file.Containers.Add(group);
unit = new Unit("unit");
group.Containers.Add(unit);
group.Containers.Add(new Group());
group.Containers.Add(new Unit());
Assert.AreEqual(unit, element.CallSelectElement("#/f=file/g=group/u=unit"));
Console.WriteLine("Test with segment.");
segment = new Segment("segment");
unit.Resources.Add(segment);
Assert.AreEqual(segment, element.CallSelectElement("#/f=file/g=group/u=unit/segment"));
Console.WriteLine("Test with relative path to segment.");
Assert.AreEqual(segment, group.Select("#u=unit/segment"));
Console.WriteLine("Test with invalid relative path to segment.");
try
{
group.Select("u=unit/segment");
Assert.Fail("Expected ArgumentException to be thrown.");
}
catch (ArgumentException)
{
}
Console.WriteLine("Test with ignorable.");
ignorable = new Ignorable("ignorable");
unit.Resources.Add(ignorable);
Assert.AreEqual(ignorable, element.CallSelectElement("#/f=file/g=group/u=unit/ignorable"));
Console.WriteLine("Test with data.");
unit.OriginalData = new OriginalData();
unit.OriginalData.AddData("data", "text");
Assert.AreEqual(unit.OriginalData.DataElements[0],
element.CallSelectElement("#/f=file/g=group/u=unit/d=data"));
Console.WriteLine("Test with note.");
file.AddNote("note").Id = "note";
Assert.AreEqual(file.Notes[0], element.CallSelectElement("#/f=file/n=note"));
//
// This test should still work even though it's an invalid document.
//
Console.WriteLine("Test with duplicate names.");
element.Document.Files.Add(new File("file"));
Assert.AreEqual(file, element.CallSelectElement("#/f=file"), "Found wrong item.");
Console.WriteLine("Test with bogus names.");
Assert.IsNull(element.CallSelectElement("#/f=foo"), "Item should not have been found.");
Console.WriteLine("Test with bogus path.");
Assert.IsNull(element.CallSelectElement("#/blah"), "Item should not have been found.");
Console.WriteLine("Test with empty string.");
// This returns null because SelectElement is called directly which doesn't search for the leading '#'.
Assert.IsNull(element.CallSelectElement(String.Empty));
Console.WriteLine("Test with empty path.");
Assert.IsNull(element.CallSelectElement("/"), "Item should not have been found.");
Console.WriteLine("Test with inline element.");
segment.Source = new Source();
segment.Source.Text.Add(new MarkedSpan("ms1"));
Assert.AreEqual(segment.Source.Text[0],
element.CallSelectElement("#/f=file/g=group/u=unit/ms1"),
"Item should have been found.");
Console.WriteLine("Test with inline element.");
segment.Target = new Target();
segment.Target.Text.Add(new MarkedSpan("ms2"));
Assert.AreEqual(segment.Target.Text[0],
element.CallSelectElement("#/f=file/g=group/u=unit/t=ms2"),
//.........这里部分代码省略.........