本文整理汇总了C#中System.Collections.Generic.SelectMany方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.Generic.SelectMany方法的具体用法?C# System.Collections.Generic.SelectMany怎么用?C# System.Collections.Generic.SelectMany使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Generic
的用法示例。
在下文中一共展示了System.Collections.Generic.SelectMany方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LocalizedModelsDiscoveryTests
public LocalizedModelsDiscoveryTests()
{
var types = new[] { typeof(SampleViewModel), typeof(SubViewModel) };
var sut = new TypeDiscoveryHelper();
Assert.NotEmpty(types);
_properties = types.SelectMany(t => sut.ScanResources(t));
}
示例2: Combine
public IEnumerable<MorphAction> Combine()
{
var collections = new[]
{
PrepareCollectionFieldDefinitions,
PrepareWorkItemTypeDefinitions,
ProcessWorkItemData,
FinaliseWorkItemTypeDefinitions
};
return collections.SelectMany(collection => collection);
}
示例3: Should_match_parameterized_action_path_with_request_path
public void Should_match_parameterized_action_path_with_request_path()
{
// Given
var request = new Request("GET", "/fake/child/route", new Dictionary<string, IEnumerable<string>>(), new MemoryStream());
var modules = new[] { new FakeNancyModuleWithBasePath() };
var descriptions = modules.SelectMany(x => x.GetRouteDescription(request));
// When
var route = this.resolver.GetRoute(request, descriptions);
// Then
route.ShouldNotBeOfType<NoMatchingRouteFoundRoute>();
}
示例4: Should_be_case_insensitive_when_matching
public void Should_be_case_insensitive_when_matching(string path)
{
// Given
var request = new Request("GET", path, new Dictionary<string, IEnumerable<string>>(), new MemoryStream());
var modules = new[] { new FakeNancyModuleWithBasePath() };
var descriptions = modules.SelectMany(x => x.GetRouteDescription(request));
// When
var route = this.resolver.GetRoute(request, descriptions);
// Then
route.ShouldNotBeOfType<NoMatchingRouteFoundRoute>();
}
示例5: Should_match_on_combination_of_module_base_path_and_action_path_when_module_defines_base_path
public void Should_match_on_combination_of_module_base_path_and_action_path_when_module_defines_base_path()
{
// Given
var request = new Request("GET", "/fake/route/with/some/parts", new Dictionary<string, IEnumerable<string>>(), new MemoryStream());
var modules = new[] { new FakeNancyModuleWithBasePath() };
var descriptions = modules.SelectMany(x => x.GetRouteDescription(request));
// When
var route = this.resolver.GetRoute(request, descriptions);
// Then
route.ShouldNotBeOfType<NoMatchingRouteFoundRoute>();
}
示例6: CreateTreeNodeCore
TreeNode CreateTreeNodeCore()
{
var node = new TreeNode();
using (var stream = item.OpenStream())
{
var rawEMsg = PeekUInt(stream);
node.Nodes.Add(BuildInfoNode(rawEMsg));
var header = ReadHeader(rawEMsg, stream);
node.Nodes.Add(new TreeNodeObjectExplorer("Header", header).TreeNode);
var body = ReadBody(rawEMsg, stream, header);
var bodyNode = new TreeNodeObjectExplorer("Body", body).TreeNode;
node.Nodes.Add(bodyNode);
var payload = ReadPayload(stream);
if (payload != null && payload.Length > 0)
{
node.Nodes.Add(new TreeNodeObjectExplorer("Payload", payload).TreeNode);
}
if (Specializations != null)
{
var objectsToSpecialize = new[] { body };
while (objectsToSpecialize.Any())
{
var specializations = objectsToSpecialize.SelectMany(o => Specializations.SelectMany(x => x.ReadExtraObjects(o)));
if (!specializations.Any())
{
break;
}
bodyNode.Collapse(ignoreChildren: true);
var extraNodes = specializations.Select(x => new TreeNodeObjectExplorer(x.Key, x.Value).TreeNode).ToArray();
node.Nodes.AddRange(extraNodes);
// Let the specializers examine any new message objects.
objectsToSpecialize = specializations.Select(x => x.Value).ToArray();
}
}
}
return node;
}
示例7: WellKnownRetryStrategyElementCollectionCommand
/// <summary>
/// Initializes a new instance of the <see cref="WellKnownRetryStrategyElementCollectionCommand"/> class.
/// </summary>
/// <param name="collection">The collection that will be affected by the add command.</param>
/// <param name="uiService"><see cref="IUIServiceWpf"/> for displaying messages.</param>
public WellKnownRetryStrategyElementCollectionCommand(ElementCollectionViewModel collection, IUIServiceWpf uiService)
: base(collection, uiService)
{
this.section = collection.ContainingSection;
var knownTypes = new[]
{
typeof(IncrementalData), typeof(FixedIntervalData), typeof(ExponentialBackoffData),
typeof(CustomRetryStrategyData)
};
this.childCommands = knownTypes
.SelectMany(x => this.section.CreateCollectionElementAddCommand(x, collection))
.OrderBy(x => x.Title)
.ToArray();
}
示例8: GetEnumerator_returns_SimpleEnumerator_for_simple_CoordinatorFactory
private void GetEnumerator_returns_SimpleEnumerator_for_simple_CoordinatorFactory(Action<Mock<DbDataReader>, IEnumerator<object>> setupRead,
Func<IDbEnumerator<object>, List<object>> toList)
{
var sourceEnumerable = new[] { new object[] { 1 }, new object[] { 2 } };
var underlyingEnumerator = ((IEnumerable<object[]>)sourceEnumerable).GetEnumerator();
var dbDataReaderMock = new Mock<DbDataReader>();
setupRead(dbDataReaderMock, underlyingEnumerator);
dbDataReaderMock.Setup(m => m.GetValue(It.IsAny<int>())).Returns((int ordinal) => underlyingEnumerator.Current[ordinal]);
var coordinatorFactory = Objects.MockHelper.CreateCoordinatorFactory<object>(shaper => shaper.Reader.GetValue(0));
var shaperMock = new Mock<Shaper<object>>(dbDataReaderMock.Object, /*context*/ null, /*workspace*/ null,
MergeOption.AppendOnly, /*stateCount*/ 1, coordinatorFactory, /*checkPermissions*/ null,
/*readerOwned*/ false) { CallBase = true };
var actualEnumerator = shaperMock.Object.GetEnumerator();
Assert.Equal(sourceEnumerable.SelectMany(e => e).ToList(), toList(actualEnumerator));
}
示例9: Returns_SimpleEnumerator_for_simple_CoordinatorFactory
private void Returns_SimpleEnumerator_for_simple_CoordinatorFactory(
Func<IDbEnumerator<object>, List<object>> toList)
{
var sourceEnumerable = new[] { new object[] { 1 }, new object[] { 2 } };
var coordinatorFactory = Objects.MockHelper.CreateCoordinatorFactory(s => s.Reader.GetValue(0));
var shaper = new Shaper<object>(
MockHelper.CreateDbDataReader(sourceEnumerable),
/*context*/ null,
/*workspace*/ null,
MergeOption.AppendOnly,
/*stateCount*/ 1,
coordinatorFactory,
/*readerOwned*/ false,
/*useSpatialReader*/ false);
var actualEnumerator = shaper.GetEnumerator();
Assert.Equal(sourceEnumerable.SelectMany(e => e).ToList(), toList(actualEnumerator));
}
示例10: GetEnumerator_returns_SimpleEnumerator_for_simple_CoordinatorFactory
private void GetEnumerator_returns_SimpleEnumerator_for_simple_CoordinatorFactory(
Func<IDbEnumerator<object>, List<object>> toList)
{
var sourceEnumerable = new[] { new object[] { 1 }, new object[] { 2 } };
var coordinatorFactory = Objects.MockHelper.CreateCoordinatorFactory(shaper => shaper.Reader.GetValue(0));
var shaperMock = new Mock<Shaper<object>>(
MockHelper.CreateDbDataReader(sourceEnumerable),
/*context*/ null,
/*workspace*/ null,
MergeOption.AppendOnly,
/*stateCount*/ 1,
coordinatorFactory,
/*checkPermissions*/ null,
/*readerOwned*/ false)
{
CallBase = true
};
var actualEnumerator = shaperMock.Object.GetEnumerator();
Assert.Equal(sourceEnumerable.SelectMany(e => e).ToList(), toList(actualEnumerator));
}
示例11: FlattenWithProjection
public void FlattenWithProjection()
{
var source = new[] {"A,B,C", "Hello,World"};
var result = source.SelectMany(x => x.Split(','), (original, split) => split.ToUpper());
result.AssertSequenceEqual("A", "B", "C", "HELLO", "WORLD");
}
示例12: Should_set_parameters_on_route_when_match_was_made_for_parameterized_action_route
public void Should_set_parameters_on_route_when_match_was_made_for_parameterized_action_route()
{
// Given
var request = new Request("GET", "/fake/foo/some/stuff/not/in/route/bar/more/stuff/not/in/route", new Dictionary<string, IEnumerable<string>>(), new MemoryStream());
var modules = new[] { new FakeNancyModuleWithBasePath() };
var descriptions = modules.SelectMany(x => x.GetRouteDescription(request));
dynamic result;
// When
var route = this.resolver.GetRoute(request, descriptions);
// Then
Record.Exception(() => result = route.Parameters.value).ShouldBeNull();
Record.Exception(() => result = route.Parameters.capture).ShouldBeNull();
}
示例13: Should_return_no_matching_route_found_route_when_no_match_could_be_found
public void Should_return_no_matching_route_found_route_when_no_match_could_be_found()
{
// Given
var request = new Request("GET", "/invalid", new Dictionary<string, IEnumerable<string>>(), new MemoryStream());
var modules = new[] { new FakeNancyModuleWithBasePath() };
var descriptions = modules.SelectMany(x => x.GetRouteDescription(request));
// When
var route = this.resolver.GetRoute(request, descriptions);
// Then
route.ShouldBeOfType<NoMatchingRouteFoundRoute>();
}
示例14: ComplexValueTest
public void ComplexValueTest()
{
var injectedProperties = new[]
{
new
{
InjectedJSON = string.Empty,
ExpectedException = (ExpectedException)null
},
new
{
InjectedJSON = "\"@custom.annotation\": null",
ExpectedException = (ExpectedException)null
},
new
{
InjectedJSON = "\"" + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataAnnotationNamespacePrefix + "unknown\": { }",
ExpectedException = (ExpectedException)null
},
new
{
InjectedJSON = "\"" + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataContextAnnotationName + "\": { }",
ExpectedException = ODataExpectedExceptions.ODataException("ODataJsonLightPropertyAndValueDeserializer_UnexpectedAnnotationProperties", JsonLightConstants.ODataContextAnnotationName)
},
new
{
InjectedJSON = "\"@custom.annotation\": null, \"@custom.annotation\": 42",
ExpectedException = ODataExpectedExceptions.ODataException("DuplicatePropertyNamesChecker_DuplicateAnnotationNotAllowed", "custom.annotation")
},
};
var payloads = new[]
{
new
{
Json = "{{{0}}}",
ExpectedValue = (ComplexInstance)PayloadBuilder.ComplexValue("TestModel.ComplexType")
},
new
{
Json = "{{{0}{1} \"Name\": \"Value\"}}",
ExpectedValue = (ComplexInstance)PayloadBuilder.ComplexValue("TestModel.ComplexType")
.PrimitiveProperty("Name", "Value")
},
new
{
Json = "{{\"Name\": \"Value\"{1}{0}}}",
ExpectedValue = (ComplexInstance)PayloadBuilder.ComplexValue("TestModel.ComplexType")
.PrimitiveProperty("Name", "Value")
},
new
{
Json = "{{\"Name\":\"Value\",{0}{1}\"City\":\"Redmond\"}}",
ExpectedValue = (ComplexInstance)PayloadBuilder.ComplexValue("TestModel.ComplexType")
.PrimitiveProperty("Name", "Value")
.PrimitiveProperty("City", "Redmond")
},
};
EdmModel model = new EdmModel();
var addressType = new EdmComplexType("TestModel", "Address");
addressType.AddStructuralProperty("Street", EdmCoreModel.Instance.GetString(isNullable: false));
var complexType = new EdmComplexType("TestModel", "ComplexType");
complexType.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(isNullable: false));
complexType.AddStructuralProperty("City", EdmCoreModel.Instance.GetString(isNullable: false));
complexType.AddStructuralProperty("Address", new EdmComplexTypeReference(addressType, isNullable: false));
complexType.AddStructuralProperty("Location", EdmPrimitiveTypeKind.GeographyPoint);
var owningType = new EdmEntityType("TestModel", "OwningType");
owningType.AddKeys(owningType.AddStructuralProperty("ID", EdmCoreModel.Instance.GetInt32(isNullable: false)));
owningType.AddStructuralProperty("TopLevelProperty", new EdmComplexTypeReference(complexType, isNullable: true));
model.AddElement(owningType);
model.AddElement(addressType);
model.AddElement(complexType);
var container = new EdmEntityContainer("TestModel", "DefaultContainer");
container.AddEntitySet("OwningType", owningType);
model.AddElement(container);
IEnumerable<PayloadReaderTestDescriptor> testDescriptors = payloads.SelectMany(payload => injectedProperties.Select(injectedProperty =>
{
return new PayloadReaderTestDescriptor(this.Settings)
{
PayloadElement = PayloadBuilder.Property("TopLevelProperty", payload.ExpectedValue.DeepCopy()
.JsonRepresentation(string.Format(payload.Json, injectedProperty.InjectedJSON, string.IsNullOrEmpty(injectedProperty.InjectedJSON) ? string.Empty : ","))
// JSON Light payloads don't store complex type names since the type can be inferred from the context URI and or API.
.SetAnnotation(new SerializationTypeNameTestAnnotation() { TypeName = null }))
.ExpectedProperty(owningType, "TopLevelProperty"),
PayloadEdmModel = model,
ExpectedException = injectedProperty.ExpectedException,
ExpectedResultPayloadElement = tc => tc.IsRequest
? PayloadBuilder.Property(string.Empty, payload.ExpectedValue.DeepCopy()
.SetAnnotation(new SerializationTypeNameTestAnnotation() { TypeName = null }))
: PayloadBuilder.Property("TopLevelProperty", payload.ExpectedValue.DeepCopy()
.SetAnnotation(new SerializationTypeNameTestAnnotation() { TypeName = null }))
};
}));
//.........这里部分代码省略.........
示例15: Should_return_the_route_with_most_static_matches_when_multiple_matches_are_found
public void Should_return_the_route_with_most_static_matches_when_multiple_matches_are_found()
{
// Given
var request = new Request("GET", "/fake/child/route/foo", new Dictionary<string, IEnumerable<string>>(), new MemoryStream());
var modules = new[] { new FakeNancyModuleWithBasePath() };
var descriptions = modules.SelectMany(x => x.GetRouteDescription(request));
var route = this.resolver.GetRoute(request, descriptions);
var response = route.Invoke();
// When
var output = GetStringContentsFromResponse(response);
// Then
output.ShouldEqual("test");
}