本文整理汇总了C#中System.Collections.Generic.All方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.Generic.All方法的具体用法?C# System.Collections.Generic.All怎么用?C# System.Collections.Generic.All使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Generic
的用法示例。
在下文中一共展示了System.Collections.Generic.All方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: should_check_if_each_and_every_item_in_sequence_match_prediction
public void should_check_if_each_and_every_item_in_sequence_match_prediction()
{
var sequence = new[] { 2, 4, 6, 8, 10 };
bool allEvenNumbers = sequence.All(item => item % 2 == 0);
// please update variable value to fix the test.
const bool expectedAllEvenNumbers = false;
Assert.Equal(expectedAllEvenNumbers, allEvenNumbers);
}
示例2: Resolve_TwoGroups
public void Resolve_TwoGroups()
{
//Arrange
var group1 = new EasyADGroup { Id = 1, Name = "Group A", Sections = "content;media;", UserType = 1 };
var group2 = new EasyADGroup { Id = 2, Name = "Group B", Sections = "translation;", UserType = 3 };
var groups = new List<EasyADGroup> { group1, group2 };
var expected = new[] { "content", "media", "translation" };
//Act
var actual = SectionResolver.Resolve(groups);
//Assert
Assert.AreEqual(3, actual.Length);
Assert.IsTrue(expected.All(e => actual.Contains(e)));
}
示例3: WhenLevel1ThenMatch
public void WhenLevel1ThenMatch()
{
var lelev0 = new PropertyPath(null, ForClass<MyClassWithComponent>.Property(x => x.Component1));
var deppLevels = new[]
{
new PropertyPath(lelev0, ForClass<MyComponent>.Property(x => x.Prop1)),
new PropertyPath(lelev0, ForClass<MyComponent>.Property(x => x.Prop2)),
new PropertyPath(lelev0, ForClass<MyComponent>.Property(x => x.MyNested)),
new PropertyPath(lelev0, ForClass<MyComponent>.Property(x => x.Collection)),
new PropertyPath(lelev0, ForClass<MyComponent>.Property(x => x.ManyToOne)),
new PropertyPath(lelev0, ForClass<MyComponent>.Property(x => x.OneToOne)),
new PropertyPath(lelev0, ForClass<MyComponent>.Property(x => x.Any)),
};
var pattern = new ComponentMemberDeepPathPattern();
deppLevels.All(pp => pp.Satisfy(x => pattern.Match(x)));
}
示例4: Should_get_located_views_from_view_location_provider_with_distinct_available_extensions_when_created
public void Should_get_located_views_from_view_location_provider_with_distinct_available_extensions_when_created()
{
// Given
var viewEngine1 = A.Fake<IViewEngine>();
A.CallTo(() => viewEngine1.Extensions).Returns(new[] { "html" });
var viewEngine2 = A.Fake<IViewEngine>();
A.CallTo(() => viewEngine2.Extensions).Returns(new[] { "spark", "html" });
var viewLocationProvider = A.Fake<IViewLocationProvider>();
var expectedViewEngineExtensions = new[] { "html", "spark" };
// When
CreateViewLocationCache(
viewLocationProvider,
new[] { viewEngine1, viewEngine2 });
// Then
A.CallTo(() => viewLocationProvider.GetLocatedViews(A<IEnumerable<string>>.That.Matches(
x => expectedViewEngineExtensions.All(y => x.Where(z => z.Equals(y)).Count() == 1)))).MustHaveHappened();
}
示例5: BindData
/* Methods */
/// <summary>
/// The bind data.
/// </summary>
private void BindData()
{
bool found = false;
if (this.Request.QueryString.GetFirstOrDefault("u") != null)
{
// Load the page access list.
DataTable dt = LegacyDb.adminpageaccess_list(
this.Request.QueryString.GetFirstOrDefault("u"), null);
// Get admin pages by page prefixes.
var listPages = Enum.GetNames(typeof(ForumPages)).Where(
e => e.IndexOf("admin_", System.StringComparison.Ordinal) >= 0);
// Initialize list with a helper class.
var adminPageAccesses = new List<AdminPageAccess>();
// Protected hostadmin pages
var hostPages = new[] { "admin_boards", "admin_hostsettings", "admin_pageaccesslist", "admin_pageaccessedit", "admin_eventloggroups", "admin_eventloggroupaccess" };
// Iterate thru all admin pages
foreach (var listPage in listPages.ToList())
{
if (dt != null && dt.Rows.Cast<DataRow>().Any(dr => dr["PageName"].ToString() == listPage && hostPages.All(s => s != dr["PageName"].ToString())))
{
found = true;
adminPageAccesses.Add(new AdminPageAccess
{
UserId = this.Request.QueryString.GetFirstOrDefault("u").ToType<int>(),
PageName = listPage,
ReadAccess = true
});
}
// If it doesn't contain page for the user add it.
if (!found && hostPages.All(s => s != listPage))
{
adminPageAccesses.Add(new AdminPageAccess
{
UserId = this.Request.QueryString.GetFirstOrDefault("u").ToType<int>(),
PageName = listPage,
ReadAccess = false
});
}
// Reset flag in the end of the outer loop
found = false;
}
this.UserName.Text = this.HtmlEncode(this.Get<IUserDisplayName>().GetName(this.Request.QueryString.GetFirstOrDefault("u").ToType<int>()));
// get admin pages list with access flags.
this.AccessList.DataSource = adminPageAccesses.AsEnumerable();
}
this.DataBind();
}
示例6: CaseThree
public static void CaseThree()
{
List<CardTemplate> HandCards_BoardCards = MainLists.HandCards_BoardCards;
if (ValueReader.ValueIgnorer.IgnoreValueIf_244_AndCoin &&
ValueReader.ValueIgnorer.HandContains224(HandCards_BoardCards) &&
!alreadyFoundOneCombo)
{
alreadyFoundOneCombo = true;
var best2Drop =
HandCards_BoardCards.Where(x => new NeutralMinion(x).minionBoardCard != null && x.Cost == 2).
OrderBy(x => new NeutralMinion(x).thisCardValue).Last();
var bestOther2Drop =
HandCards_BoardCards.Where(x => x.Id.ToString() != best2Drop.Id.ToString() &&
new NeutralMinion(x).minionBoardCard != null && x.Cost == 2).
OrderBy(x => new NeutralMinion(x).thisCardValue).Last();
var best4Drop =
HandCards_BoardCards.Where(x => new NeutralMinion(x).minionBoardCard != null && x.Cost == 4).
OrderBy(x => new NeutralMinion(x).thisCardValue).Last();
var bestDrops = new[] { best2Drop, bestOther2Drop, best4Drop };
if (ValueReader.ValueIgnorer.OnlyAddIfNoBadEffect && !bestDrops.All(CardEffects.HasBadEffect))
{
foreach (var drop in bestDrops.Where(x => !MainLists.chosenCards.Contains(BoardToMulliganCard(x))))
{
string dropAsString = drop.Id.ToString();
MainLists.chosenCards.Add(CardTemplate.StringToCard(dropAsString));
MainLists.blackList.Add(drop.Id.ToString());
}
}
}
}
示例7: ShowServicesAndCharacteristics
private void ShowServicesAndCharacteristics(BluetoothConnectionHandler connectionHandler)
{
var listView = FindViewById<ListView>(Resource.Id.ServiceList);
var filterUuid = new [] { UUID.FromString("00001800-0000-1000-8000-00805F9B34FB"),
UUID.FromString("00001801-0000-1000-8000-00805F9B34FB"), UUID.FromString("7905F431-B5CE-4E99-A40F-4B1E122D00D0") };
var serviceList = connectionHandler.GetServiceList().Where(s => filterUuid.All(uuid => !uuid.Equals(s.Uuid)));
listView.Adapter = _adapter = CreateServiceListAdapter(serviceList);
listView.ItemClick += OnItemClick;
}