This commit is contained in:
2024-03-13 00:33:46 +01:00
commit e124a47765
19374 changed files with 9806149 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
using System;
using System.Diagnostics;
using System.Linq;
using JetBrains.Annotations;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Sda.ModelIdUpdater;
namespace Sda.Build.Tasks
{
/// <summary>
/// Kiegészít egy <c>XMI</c> modellt úgy, hogy minden elemnek egyedi <c>ID</c>-ja legyen.
/// </summary>
public sealed class UpdateIds : Task
{
/// <summary>
/// A módosítandó <c>XML</c> modell állomány neve.
/// </summary>
[CanBeNull, Required]
public string Input { get; set; }
[CanBeNull]
public ITaskItem[] Packages { get; set; }
public override bool Execute()
{
Updater updater = new Updater();
updater.LogMessageHandler += (sender, e) =>
{
if (e == null
||
string.IsNullOrWhiteSpace(e.Message))
{
return;
}
if (Packages != null
&&
Packages.Length > 0
&&
!string.IsNullOrWhiteSpace(e.Package)
&&
!Packages.Any(p => string.Equals(p.ItemSpec, e.Package, StringComparison.OrdinalIgnoreCase)))
{
return;
}
switch (e.EventType)
{
case TraceEventType.Error:
this.LogError(e.Message);
break;
case TraceEventType.Warning:
this.LogWarning(e.Message);
break;
default:
this.LogInfo(e.Message);
break;
}
};
updater.UpdateIds(Input);
return true;
}
}
}