зеркало из https://github.com/AvaloniaUI/OmniXAML.git
Making deps explicit
This commit is contained in:
Родитель
4a1edb2774
Коммит
9895ee5f13
|
@ -6,17 +6,15 @@
|
|||
|
||||
public class MarkupExtensionNodeToXamlNodesConverter
|
||||
{
|
||||
private readonly IWiringContext wiringContext;
|
||||
|
||||
public MarkupExtensionNodeToXamlNodesConverter(IWiringContext wiringContext)
|
||||
public MarkupExtensionNodeToXamlNodesConverter(ITypeContext typeContext)
|
||||
{
|
||||
this.wiringContext = wiringContext;
|
||||
TypeContext = typeContext;
|
||||
}
|
||||
|
||||
public IEnumerable<XamlInstruction> ParseMarkupExtensionNode(MarkupExtensionNode tree)
|
||||
{
|
||||
var identifierNode = tree.Identifier;
|
||||
var xamlType = wiringContext.TypeContext.GetByPrefix(identifierNode.Prefix, identifierNode.TypeName);
|
||||
var xamlType = TypeContext.GetByPrefix(identifierNode.Prefix, identifierNode.TypeName);
|
||||
yield return Inject.StartOfObject(xamlType);
|
||||
|
||||
foreach (var instruction in ParseArguments(tree.Options.OfType<PositionalOption>())) yield return instruction;
|
||||
|
@ -25,6 +23,8 @@
|
|||
yield return Inject.EndOfObject();
|
||||
}
|
||||
|
||||
private ITypeContext TypeContext { get; }
|
||||
|
||||
private static IEnumerable<XamlInstruction> ParseArguments(IEnumerable<PositionalOption> options)
|
||||
{
|
||||
var positionalOptions = options.ToList();
|
||||
|
|
|
@ -303,7 +303,7 @@
|
|||
private IEnumerable<XamlInstruction> ParseMarkupExtension(string valueOfMember)
|
||||
{
|
||||
var tree = MarkupExtensionParser.MarkupExtension.Parse(valueOfMember);
|
||||
var markupExtensionConverter = new MarkupExtensionNodeToXamlNodesConverter(wiringContext);
|
||||
var markupExtensionConverter = new MarkupExtensionNodeToXamlNodesConverter(wiringContext.TypeContext);
|
||||
return markupExtensionConverter.ParseMarkupExtensionNode(tree);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
public void NameOnly()
|
||||
{
|
||||
var tree = new MarkupExtensionNode(new IdentifierNode("DummyExtension"));
|
||||
var sut = new MarkupExtensionNodeToXamlNodesConverter(WiringContext);
|
||||
var sut = new MarkupExtensionNodeToXamlNodesConverter(WiringContext.TypeContext);
|
||||
var actualNodes = sut.ParseMarkupExtensionNode(tree).ToList();
|
||||
var expectedInstructions = new List<XamlInstruction>
|
||||
{
|
||||
|
@ -32,7 +32,7 @@
|
|||
public void NameAndAttribute()
|
||||
{
|
||||
var tree = new MarkupExtensionNode(new IdentifierNode("DummyExtension"), new OptionsCollection {new PropertyOption("Property", new StringNode("Value"))});
|
||||
var sut = new MarkupExtensionNodeToXamlNodesConverter(WiringContext);
|
||||
var sut = new MarkupExtensionNodeToXamlNodesConverter(WiringContext.TypeContext);
|
||||
var actualNodes = sut.ParseMarkupExtensionNode(tree).ToList();
|
||||
|
||||
var expectedInstructions = new List<XamlInstruction>
|
||||
|
@ -55,7 +55,7 @@
|
|||
new PropertyOption("Property", new StringNode("Value")),
|
||||
new PropertyOption("AnotherProperty", new StringNode("AnotherValue")),
|
||||
});
|
||||
var sut = new MarkupExtensionNodeToXamlNodesConverter(WiringContext);
|
||||
var sut = new MarkupExtensionNodeToXamlNodesConverter(WiringContext.TypeContext);
|
||||
var actualNodes = sut.ParseMarkupExtensionNode(tree).ToList();
|
||||
|
||||
var expectedInstructions = new List<XamlInstruction>
|
||||
|
@ -80,7 +80,7 @@
|
|||
{
|
||||
new PositionalOption("Option")
|
||||
});
|
||||
var sut = new MarkupExtensionNodeToXamlNodesConverter(WiringContext);
|
||||
var sut = new MarkupExtensionNodeToXamlNodesConverter(WiringContext.TypeContext);
|
||||
var actualNodes = sut.ParseMarkupExtensionNode(tree).ToList();
|
||||
|
||||
var expectedInstructions = new Collection<XamlInstruction>
|
||||
|
@ -99,7 +99,7 @@
|
|||
public void ComposedExtensionTemplateBindingWithConverter()
|
||||
{
|
||||
var tree = MarkupExtensionNodeResources.ComposedExtensionTemplateBindingWithConverter();
|
||||
var sut = new MarkupExtensionNodeToXamlNodesConverter(WiringContext);
|
||||
var sut = new MarkupExtensionNodeToXamlNodesConverter(WiringContext.TypeContext);
|
||||
var actualNodes = sut.ParseMarkupExtensionNode(tree).ToList();
|
||||
|
||||
var expectedInstructions = new Collection<XamlInstruction>
|
||||
|
|
Загрузка…
Ссылка в новой задаче