本文整理汇总了C#中System.Collections.Generic.Concat方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.Generic.Concat方法的具体用法?C# System.Collections.Generic.Concat怎么用?C# System.Collections.Generic.Concat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Generic
的用法示例。
在下文中一共展示了System.Collections.Generic.Concat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateXamlNamespaceRegistry
private static XamlNamespaceRegistry CreateXamlNamespaceRegistry()
{
var xamlNamespaceRegistry = new XamlNamespaceRegistry();
var forcedAssemblies = new[]
{
typeof (Control),
typeof(Style)
}.Select(t => t.GetTypeInfo().Assembly);
foreach (var nsa in
forcedAssemblies
.Concat(Locator.Current.GetService<IPclPlatformWrapper>().GetLoadedAssemblies())
.Distinct()
.SelectMany(asm
=> asm.GetCustomAttributes<XmlnsDefinitionAttribute>().Select(attr => new {asm, attr}))
.GroupBy(entry => entry.attr.XmlNamespace))
{
var def = XamlNamespace.Map(nsa.Key)
.With(nsa.GroupBy(x => x.asm).Select(
a => Route.Assembly(a.Key)
.WithNamespaces(a.Select(entry => entry.attr.ClrNamespace).ToList())
));
xamlNamespaceRegistry.AddNamespace(def);
}
xamlNamespaceRegistry.RegisterPrefix(new PrefixRegistration(string.Empty, PerspexNs));
return xamlNamespaceRegistry;
}
示例2: GetLibrariesScript
private static string[] GetLibrariesScript()
{
string[] libraries = new[]
{
"~/Scripts/jquery-1.9.1.js",
"~/Scripts/jquery.address.js",
"~/Scripts/jquery-ui.js",
"~/Scripts/jquery-timePicker/jquery.timepicker.js",
"~/Scripts/shortcut.js",
"~/Scripts/colorbox/jquery.colorbox.js",
"~/Scripts/jqueryNumber/jquery.number.js",
"~/Scripts/date.js",
"~/Scripts/chartjs/Chart.min.js",
"~/Scripts/chartjs/legend.js",
"~/Scripts/notify-combined.min.js",
"~/Scripts/semantic-ui/semantic.js",
"~/Scripts/jquery.signalR.js",
"~/Scripts/vakata-jstree/dist/jstree.min.js",
"~/Scripts/momentjs/moment-with-locales.js",
"~/Scripts/underscore/underscore-min.js",
"~/Scripts/angular/angular.min.js",
"~/Scripts/linq.js/linq.js"
};
libraries = libraries.Concat(GetMixERPCoreScript()).ToArray();
return libraries;
}
示例3: ProjectMessageCases
public static IEnumerable<TestCaseData> ProjectMessageCases()
{
//Match
var commands1 = new[] { CommandFactory(), CommandFactory() };
var handler1 = new SqlProjectionHandler(typeof(object), _ => commands1);
var resolver1 = new SqlProjectionHandlerResolver(message => new[] { handler1 });
yield return new TestCaseData(
resolver1,
new object(),
commands1);
//Mismatch
var resolver2 = new SqlProjectionHandlerResolver(message => new SqlProjectionHandler[0]);
yield return new TestCaseData(
resolver2,
new object(),
new SqlNonQueryCommand[0]);
//Multimatch
var commands3 = new[] { CommandFactory(), CommandFactory() };
var commands4 = new[] { CommandFactory(), CommandFactory() };
var handler3 = new SqlProjectionHandler(typeof(object), _ => commands3);
var handler4 = new SqlProjectionHandler(typeof(object), _ => commands4);
var resolver3 = new SqlProjectionHandlerResolver(message => new[] { handler3, handler4 });
yield return new TestCaseData(
resolver3,
new object(),
commands3.Concat(commands4).ToArray());
}
示例4: FindPath
public override IEnumerable<OperatorElement> FindPath(Element target)
{
var pathHere = new[] {this};
if (ReferenceEquals(Elements.Lhs, target) || ReferenceEquals(Elements.Rhs, target)) return pathHere;
var pathFromHere = Elements.Lhs.FindPath(target) ?? Elements.Rhs.FindPath(target);
return pathFromHere != null ? pathHere.Concat(pathFromHere) : null;
}
示例5: WithSupertypes
private static ImmutableArray<SymbolDisplayPart> WithSupertypes(ImmutableArray<SymbolDisplayPart> defaultParts, INamedTypeSymbol type)
{
if (type == null || !s_TypeKindsWithUserSpecifiedSuperTypes.Contains(type.TypeKind)) return defaultParts;
var baseTypes = new[] { type.BaseType }.Where(NonImpliedBaseType);
var inheritsFrom = baseTypes.Concat(GetInterfaces(type)).Select(GetSimpleTypeName).ToList();
var inheritanceSuffix = inheritsFrom.Any() ? s_InheritsFrom.Concat(CommaSeparate(inheritsFrom)) : new SymbolDisplayPart[0];
return WithInheritsFrom(defaultParts, inheritanceSuffix);
}
示例6: Concat
public void Concat()
{
var source = new[] {2, 3, 4};
var expected = new[] {2, 3, 4, 5};
CollectionAssert.AreEqual(
expected, source.Concat(5).ToArray());
}
示例7: ComplexValueTest
public void ComplexValueTest()
{
EdmModel model = new EdmModel();
var emptyComplexType = new EdmComplexType(DefaultNamespaceName, "EmptyComplexType");
model.AddElement(emptyComplexType);
var complexTypeWithStringProperty = new EdmComplexType(DefaultNamespaceName, "ComplexTypeWithStringProperty");
complexTypeWithStringProperty.AddStructuralProperty("stringProperty", EdmCoreModel.Instance.GetString(isNullable: true));
complexTypeWithStringProperty.AddStructuralProperty("numberProperty", EdmCoreModel.Instance.GetInt32(isNullable: false));
model.AddElement(complexTypeWithStringProperty);
model.Fixup();
IEnumerable<PayloadReaderTestDescriptor> testDescriptors = new[]
{
// Empty element is a valid complex value
new PayloadReaderTestDescriptor(this.Settings)
{
PayloadElement = PayloadBuilder.ComplexValue("TestModel.EmptyComplexType")
.XmlValueRepresentation(new XNode[0])
.WithTypeAnnotation(emptyComplexType),
PayloadEdmModel = model
},
};
testDescriptors = testDescriptors.Concat(
PropertiesElementAtomValues.CreatePropertiesElementPaddingPayloads<ComplexInstance>(
new PayloadReaderTestDescriptor(this.Settings)
{
PayloadElement = PayloadBuilder.ComplexValue("TestModel.ComplexTypeWithStringProperty")
.WithTypeAnnotation(complexTypeWithStringProperty),
PayloadEdmModel = model
},
(complexInstance, xmlValue) => complexInstance.XmlValueRepresentation(xmlValue)));
testDescriptors = testDescriptors.Select(td => td.InProperty());
testDescriptors = testDescriptors.Concat(new []
{
// Top-level property without expected type and no type name - this is read as primitive string!
new PayloadReaderTestDescriptor(this.Settings)
{
PayloadElement = PayloadBuilder.Property(null, PayloadBuilder.PrimitiveValue(string.Empty))
.XmlRepresentation("<m:value/>"),
PayloadEdmModel = model,
},
});
this.CombinatorialEngineProvider.RunCombinations(
testDescriptors,
this.ReaderTestConfigurationProvider.AtomFormatConfigurations,
(testDescriptor, testConfiguration) =>
{
testDescriptor.RunTest(testConfiguration);
});
}
示例8: MaxInt32
public void MaxInt32()
{
var ten = Enumerable.Range(1, 10).ToArray();
var minusTen = new[] { -100, -15, -50, -10 };
var thousand = new[] { -16, 0, 50, 100, 1000 };
Assert.Equal(10, ten.Max());
Assert.Equal(-10, minusTen.Max());
Assert.Equal(1000, thousand.Max());
Assert.Equal(int.MaxValue, thousand.Concat(Enumerable.Repeat(int.MaxValue, 1)).Max());
}
示例9: should_concat_sequences
public void should_concat_sequences()
{
var left = new[] {1, 2, 3};
var right = new[] {4, 5};
IEnumerable<int> concat = left.Concat(right);
// please update variable value to fix the test.
IEnumerable<int> expectedConcatResult = new[] {1, 2, 3};
Assert.Equal(expectedConcatResult, concat);
}
示例10: MaxInt32
public void MaxInt32()
{
var ten = Enumerable.Range(1, 10).ToArray();
var minusTen = new[] { -100, -15, -50, -10 };
var thousand = new[] { -16, 0, 50, 100, 1000 };
Assert.Equal(42, Enumerable.Repeat(42, 1).Max());
Assert.Equal(10, ten.Max());
Assert.Equal(-10, minusTen.Max());
Assert.Equal(1000, thousand.Max());
Assert.Equal(int.MaxValue, thousand.Concat(Enumerable.Repeat(int.MaxValue, 1)).Max());
Assert.Throws<InvalidOperationException>(() => Enumerable.Empty<int>().Max());
}
示例11: MaxInt64
public void MaxInt64()
{
var ten = Enumerable.Range(1, 10).Select(i => (long)i).ToArray();
var minusTen = new[] { -100L, -15, -50, -10 };
var thousand = new[] { -16L, 0, 50, 100, 1000 };
Assert.Equal(42, Enumerable.Repeat(42L, 1).Max());
Assert.Equal(10, ten.Max());
Assert.Equal(-10, minusTen.Max());
Assert.Equal(1000, thousand.Max());
Assert.Equal(long.MaxValue, thousand.Concat(Enumerable.Repeat(long.MaxValue, 1)).Max());
Assert.Throws<InvalidOperationException>(() => Enumerable.Empty<long>().Max());
}
示例12: ProjectMessagesCases
public static IEnumerable<TestCaseData> ProjectMessagesCases()
{
//Partial match
var commands1 = new[] { CommandFactory(), CommandFactory() };
var handler1 = new SqlProjectionHandler(typeof(string), _ => commands1);
var resolver1 = Resolve.WhenEqualToHandlerMessageType(new[] { handler1 });
yield return new TestCaseData(
resolver1,
new object[] { "123", 123 },
commands1);
//Mismatch
var resolver2 = Resolve.WhenEqualToHandlerMessageType(new SqlProjectionHandler[0]);
yield return new TestCaseData(
resolver2,
new object[] { new object(), 123 },
new SqlNonQueryCommand[0]);
//Multimatch
var commands3 = new[] { CommandFactory(), CommandFactory() };
var commands4 = new[] { CommandFactory(), CommandFactory() };
var handler3 = new SqlProjectionHandler(typeof(object), _ => commands3);
var handler4 = new SqlProjectionHandler(typeof(object), _ => commands4);
var resolver3 = Resolve.WhenEqualToHandlerMessageType(new[] { handler3, handler4 });
yield return new TestCaseData(
resolver3,
new object[] { new object(), new object() },
commands3.Concat(commands4).Concat(commands3).Concat(commands4).ToArray());
//Multitype Match
var commands5 = new[] { CommandFactory(), CommandFactory() };
var commands6 = new[] { CommandFactory(), CommandFactory() };
var handler5 = new SqlProjectionHandler(typeof(string), _ => commands5);
var handler6 = new SqlProjectionHandler(typeof(int), _ => commands6);
var resolver4 = Resolve.WhenEqualToHandlerMessageType(new[] { handler5, handler6 });
yield return new TestCaseData(
resolver4,
new object[] { "123", 123 },
commands5.Concat(commands6).ToArray());
//Match
var commands7 = new[] { CommandFactory(), CommandFactory() };
var commands8 = new[] { CommandFactory(), CommandFactory() };
var handler7 = new SqlProjectionHandler(typeof(object), _ => commands7);
var handler8 = new SqlProjectionHandler(typeof(object), _ => commands8);
var resolver5 = Resolve.WhenEqualToHandlerMessageType(new[] { handler7, handler8 });
yield return new TestCaseData(
resolver5,
new object[] { new object() },
commands7.Concat(commands8).ToArray());
}
示例13: WhenNewInstancesAdded_ShouldIncludeAllInstancesInDistribution
public void WhenNewInstancesAdded_ShouldIncludeAllInstancesInDistribution()
{
var strategy = new SingleInstanceRoundRobinDistributionStrategy("endpointA", DistributionStrategyScope.Send);
var instances = new []
{
"1",
"2",
};
var result = new List<string>();
result.Add(strategy.SelectReceiver(instances));
result.Add(strategy.SelectReceiver(instances));
instances = instances.Concat(new [] { "3" }).ToArray(); // add new instance
result.Add(strategy.SelectReceiver(instances));
Assert.That(result.Count, Is.EqualTo(3));
Assert.That(result, Has.Exactly(1).EqualTo(instances[0]));
Assert.That(result, Has.Exactly(1).EqualTo(instances[1]));
Assert.That(result, Has.Exactly(1).EqualTo(instances[2]));
}
示例14: MaxDateTime
public void MaxDateTime()
{
var ten = Enumerable.Range(1, 10).Select(i => new DateTime(2000, 1, i)).ToArray();
var newYearsEve = new[]
{
new DateTime(2000, 12, 1),
new DateTime(2000, 12, 31),
new DateTime(2000, 1, 12)
};
var threeThousand = new[]
{
new DateTime(3000, 1, 1),
new DateTime(100, 1, 1),
new DateTime(200, 1, 1),
new DateTime(1000, 1, 1)
};
Assert.Equal(new DateTime(2000, 1, 10), ten.Max());
Assert.Equal(new DateTime(2000, 12, 31), newYearsEve.Max());
Assert.Equal(new DateTime(3000, 1, 1), threeThousand.Max());
Assert.Equal(DateTime.MaxValue, threeThousand.Concat(Enumerable.Repeat(DateTime.MaxValue, 1)).Max());
}
示例15: MaxNullableDecimal
public void MaxNullableDecimal()
{
var ten = Enumerable.Range(1, 10).Select(i => (decimal?)i).ToArray();
var minusTen = new[] { default(decimal?), -100M, -15, -50, -10 };
var thousand = new[] { default(decimal?), -16M, 0, 50, 100, 1000 };
Assert.Equal(42M, Enumerable.Repeat((decimal?)42, 1).Max());
Assert.Equal(10M, ten.Max());
Assert.Equal(-10M, minusTen.Max());
Assert.Equal(1000M, thousand.Max());
Assert.Equal(decimal.MaxValue, thousand.Concat(Enumerable.Repeat((decimal?)decimal.MaxValue, 1)).Max());
}