本文整理汇总了C#中Library.List.TrueForAll方法的典型用法代码示例。如果您正苦于以下问题:C# List.TrueForAll方法的具体用法?C# List.TrueForAll怎么用?C# List.TrueForAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Library.List
的用法示例。
在下文中一共展示了List.TrueForAll方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveProject
public bool RemoveProject(int projectId)
{
//throw new NotImplementedException();
Project project = GetProject(projectId);
if (project != null)
{
bool error = false;
try
{
var option = new TransactionOptions();
option.IsolationLevel = IsolationLevel.ReadCommitted;
using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, option))
{
project = GetProject(projectId);
List<bool> success = new List<bool>();
foreach (User user in project.ProjectAdministrators)
{
success.Add(RemovePersonFromProject(project, user));
}
foreach (User user in project.ProjectMembers)
{
success.Add(RemovePersonFromProject(project, user));
}
foreach (File file in dbFile.GetAllFilesForProject(project.Id))
{
success.Add(dbFile.RemoveFile(file));
}
//bool f = dbFile.RemoveAllFilesFromProject(projectId);
dbContext.Projects.DeleteOnSubmit(project);
if (success.TrueForAll(x => x.Equals(true))) //Checks if all values in the List matches true, and returns true if so.
{
dbContext.SubmitChanges();
scope.Complete();
}
else
{
scope.Dispose();
error = true;
}
}
}
catch (Exception e)
{
Console.WriteLine("Project could not be removed. Project id: " + projectId + "Error: \n" + e);
return false;
}
if (error != true)
{
return true;
}
else
{
return false;
}
}
return false;
}