2025-03-19 23:18:26 +03:00
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace mROA.CodegenTools
|
|
|
|
|
{
|
2025-03-23 19:32:41 +03:00
|
|
|
public class LinkTemplateSection : ITemplateSection, IBaking
|
2025-03-19 23:18:26 +03:00
|
|
|
{
|
|
|
|
|
private readonly string _linkedTag;
|
2025-03-19 23:21:00 +03:00
|
|
|
|
2025-03-20 16:36:32 +03:00
|
|
|
public LinkTemplateSection(string linkedTag, TemplateDocument context)
|
2025-03-19 23:21:00 +03:00
|
|
|
{
|
|
|
|
|
_linkedTag = linkedTag;
|
|
|
|
|
Context = context;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-19 23:18:26 +03:00
|
|
|
public TemplateDocument Context { get; set; }
|
|
|
|
|
|
|
|
|
|
public string LinkedTag => _linkedTag;
|
|
|
|
|
|
2025-03-23 19:32:41 +03:00
|
|
|
public int TargetLength
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
var attached = Context[_linkedTag];
|
|
|
|
|
return attached?.TargetLength ?? 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-03-19 23:42:25 +03:00
|
|
|
|
2025-03-19 23:18:26 +03:00
|
|
|
public string Bake()
|
|
|
|
|
{
|
2025-03-23 19:32:41 +03:00
|
|
|
return Context[_linkedTag]?.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return $"{nameof(LinkedTag)}: {_linkedTag}";
|
2025-03-19 23:18:26 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|