Код компиляции документа
This commit is contained in:
@@ -5,8 +5,7 @@ namespace mROA.CodegenTools
|
||||
{
|
||||
public class InsertTemplatePart : ITemplatePart, ITagged
|
||||
{
|
||||
private string _insertedText;
|
||||
private ITemplatePart _insertedPart;
|
||||
private object _insertedValue;
|
||||
private string _tag;
|
||||
public string Tag => _tag;
|
||||
public TemplateDocument Context { get; set; }
|
||||
@@ -21,9 +20,6 @@ namespace mROA.CodegenTools
|
||||
|
||||
private bool IsInserted(object value)
|
||||
{
|
||||
if (!(value is string) && !(value is ITemplatePart) )
|
||||
return false;
|
||||
|
||||
if (Parameters.IndexOf("R") == 0) return false;
|
||||
|
||||
ProduceInserted(value);
|
||||
@@ -36,39 +32,37 @@ namespace mROA.CodegenTools
|
||||
var currentIndex = Context.Parts.IndexOf(this);
|
||||
var clone = (InsertTemplatePart)MemberwiseClone();
|
||||
clone._tag += "+";
|
||||
|
||||
if (value is string s)
|
||||
{
|
||||
clone.Setup(s);
|
||||
}else
|
||||
clone.Setup((ITemplatePart)value);
|
||||
|
||||
clone._insertedValue = value;
|
||||
|
||||
Context.Parts.Insert(currentIndex, clone);
|
||||
}
|
||||
|
||||
|
||||
public void Setup(string inside)
|
||||
public void Setup(object value)
|
||||
{
|
||||
if (IsInserted(inside))
|
||||
if (!(value is string) && !(value is ITemplatePart) )
|
||||
return;
|
||||
_insertedText = inside;
|
||||
if (IsInserted(value))
|
||||
return;
|
||||
|
||||
_insertedValue = value;
|
||||
}
|
||||
|
||||
public void Setup(ITemplatePart part)
|
||||
{
|
||||
if (IsInserted(part))
|
||||
return;
|
||||
_insertedPart = part;
|
||||
}
|
||||
|
||||
|
||||
public int TargetLength => 0;
|
||||
|
||||
public string Bake()
|
||||
{
|
||||
if (_insertedText != null)
|
||||
switch (_insertedValue)
|
||||
{
|
||||
return _insertedText;
|
||||
case null:
|
||||
return string.Empty;
|
||||
case string s:
|
||||
return s;
|
||||
default:
|
||||
return ((ITemplatePart)_insertedValue).Bake();
|
||||
}
|
||||
|
||||
return _insertedPart.Bake();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user