本文整理汇总了C#中RepeatedField.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# RepeatedField.AddRange方法的具体用法?C# RepeatedField.AddRange怎么用?C# RepeatedField.AddRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RepeatedField
的用法示例。
在下文中一共展示了RepeatedField.AddRange方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddRange_SlowPath
public void AddRange_SlowPath()
{
var list = new RepeatedField<string>();
list.AddRange(new[] { "foo", "bar" }.Select(x => x));
Assert.AreEqual(2, list.Count);
Assert.AreEqual("foo", list[0]);
Assert.AreEqual("bar", list[1]);
}
示例2: AddRange_SlowPath_NullsProhibited_NullableValueType
public void AddRange_SlowPath_NullsProhibited_NullableValueType()
{
var list = new RepeatedField<int?>();
// It's okay for this to throw ArgumentNullException if necessary.
// It's not ideal, but not awful.
Assert.Catch<ArgumentException>(() => list.AddRange(new[] { 20, (int?)null }.Select(x => x)));
}
示例3: AddRange_SlowPath_NullsProhibited_ReferenceType
public void AddRange_SlowPath_NullsProhibited_ReferenceType()
{
var list = new RepeatedField<string>();
// It's okay for this to throw ArgumentNullException if necessary.
// It's not ideal, but not awful.
Assert.Catch<ArgumentException>(() => list.AddRange(new[] { "foo", null }.Select(x => x)));
}
示例4: AddRange_RepeatedField
public void AddRange_RepeatedField()
{
var list = new RepeatedField<string> { "original" };
list.AddRange(new RepeatedField<string> { "foo", "bar" });
Assert.AreEqual(3, list.Count);
Assert.AreEqual("original", list[0]);
Assert.AreEqual("foo", list[1]);
Assert.AreEqual("bar", list[2]);
}
示例5: AddRange_AlreadyNotEmpty
public void AddRange_AlreadyNotEmpty()
{
var list = new RepeatedField<int> { 1, 2, 3 };
list.AddRange(new List<int> { 4, 5, 6 });
CollectionAssert.AreEqual(new[] { 1, 2, 3, 4, 5, 6 }, list);
}
示例6: AddRange_Optimized_NullsProhibited_NullableValueType
public void AddRange_Optimized_NullsProhibited_NullableValueType()
{
// We don't just trust that a collection with a nullable element type doesn't contain nulls
var list = new RepeatedField<int?>();
// It's okay for this to throw ArgumentNullException if necessary.
// It's not ideal, but not awful.
Assert.Catch<ArgumentException>(() => list.AddRange(new List<int?> { 20, null }));
}
示例7: AddRange_Optimized_NullableValueType
public void AddRange_Optimized_NullableValueType()
{
var list = new RepeatedField<int?>();
list.AddRange(new List<int?> { 20, 30 });
Assert.AreEqual(2, list.Count);
Assert.AreEqual((int?) 20, list[0]);
Assert.AreEqual((int?) 30, list[1]);
}
示例8: AddRange_Optimized_ReferenceType
public void AddRange_Optimized_ReferenceType()
{
var list = new RepeatedField<string>();
list.AddRange(new List<string> { "foo", "bar" });
Assert.AreEqual(2, list.Count);
Assert.AreEqual("foo", list[0]);
Assert.AreEqual("bar", list[1]);
}