Refactor collection initializers to use C# 12 collection expressions
This commit updates various files across the Core and WebApp projects to replace traditional collection initializers with C# 12 collection expressions. Changes include modifications to EventAssignment.cs, TeamScheduler_DecisionTree.cs, CareerField.cs, EventDefinition.cs, and several components in the WebApp. These updates enhance code readability and maintainability by adhering to modern C# syntax standards.
This commit is contained in:
@@ -254,7 +254,7 @@ namespace Core.Calculation
|
||||
private void AddStudentConstraint(CpModel model, BoolVar[,] x,
|
||||
Func<EventDefinition, bool> eventFilter, Action<CpModel, List<ILiteral>> constraintAction)
|
||||
{
|
||||
var buffer = new List<ILiteral>();
|
||||
List<ILiteral> buffer = [];
|
||||
foreach (var s in _allStudents)
|
||||
{
|
||||
buffer.Clear();
|
||||
@@ -273,7 +273,7 @@ namespace Core.Calculation
|
||||
/// </summary>
|
||||
private void IndividualEventsMustBeRanked(CpModel model, BoolVar[,] x)
|
||||
{
|
||||
var prohibitVar = new List<IntVar>(1);
|
||||
List<IntVar> prohibitVar = [];
|
||||
|
||||
foreach (var s in _allStudents)
|
||||
{
|
||||
@@ -328,7 +328,7 @@ namespace Core.Calculation
|
||||
/// </summary>
|
||||
private void LimitStudentAssignment(CpModel model, BoolVar[,] x)
|
||||
{
|
||||
var studentCapacity = new List<IntVar>();
|
||||
List<IntVar> studentCapacity = [];
|
||||
|
||||
foreach (var s in _allStudents)
|
||||
{
|
||||
@@ -418,7 +418,7 @@ namespace Core.Calculation
|
||||
/// </summary>
|
||||
private void AddEventConstraint(CpModel model, BoolVar[,] x, int eventIndex, int lb, int ub)
|
||||
{
|
||||
var eventCapacity = new List<IntVar>();
|
||||
List<IntVar> eventCapacity = [];
|
||||
foreach (var s in _allStudents)
|
||||
{
|
||||
eventCapacity.Add(x[eventIndex, s]);
|
||||
@@ -455,7 +455,7 @@ namespace Core.Calculation
|
||||
model.AddAssumption(x[e, s]);
|
||||
}
|
||||
|
||||
var prohibitVar = new List<IntVar>(1);
|
||||
List<IntVar> prohibitVar = [];
|
||||
foreach (var excludedAssignment in _assignmentRequirements.Where(a => a.Requirement == Requirement.Exclude))
|
||||
{
|
||||
var e = _events.IndexOf(excludedAssignment.EventDefinition);
|
||||
|
||||
Reference in New Issue
Block a user