public NameScopeTests() { var topDownValueContext = new TopDownValueContext(); sut = new ObjectAssembler(RuntimeTypeSource, new ValueContext(RuntimeTypeSource, topDownValueContext)); source = new InstructionResources(this); }
public void GivenChildWithPreviousName_LatestNameIsRegisteredInParent() { var runtimeTypeSource = CreateRuntimeTypeSource(); var x = CreateBuilder(runtimeTypeSource); var topDownValueContext = new TopDownValueContext(); var valueConnectionContext = new ValueContext(runtimeTypeSource, topDownValueContext); var sut = new ObjectAssembler(runtimeTypeSource, valueConnectionContext); var batch = new Collection<Instruction> { x.StartObject<DummyClass>(), x.StartMember<DummyClass>(d => d.Child), x.StartObject<ChildClass>(), x.StartMember<ChildClass>(c => c.Name), x.Value("OuterName"), x.EndMember(), x.EndObject(), x.EndMember(), x.EndObject(), }; sut.Process(batch); var result = (DummyClass)sut.Result; var childClass = result.Find("OuterName"); Assert.NotNull(childClass); }
public void MultinameRegistrationGivesSameObjectTwoSubsequentNames() { var runtimeTypeSource = CreateRuntimeTypeSource(); var x = CreateBuilder(runtimeTypeSource); var topDownValueContext = new TopDownValueContext(); var valueConnectionContext = new ValueContext(runtimeTypeSource, topDownValueContext, new Dictionary <string, object>()); var sut = new ObjectAssembler(runtimeTypeSource, valueConnectionContext); var batch = new Collection <Instruction> { x.StartObject <DummyClass>(), x.StartMember <DummyClass>(d => d.Child), x.StartObject <ChildClass>(), x.StartMember <ChildClass>(c => c.Name), x.Value("OuterName"), x.EndMember(), x.EndObject(), x.EndMember(), x.EndObject(), }; sut.Process(batch); var result = (DummyClass)sut.Result; var child = (DummyObject)result.Child; Assert.Equal("InnerName", child.NamesHistory[0]); Assert.Equal("OuterName", child.NamesHistory[1]); }
public void GivenChildWithPreviousName_LatestNameIsRegisteredInParent() { var runtimeTypeSource = CreateRuntimeTypeSource(); var x = CreateBuilder(runtimeTypeSource); var topDownValueContext = new TopDownValueContext(); var valueConnectionContext = new ValueContext(runtimeTypeSource, topDownValueContext, new Dictionary <string, object>()); var sut = new ObjectAssembler(runtimeTypeSource, valueConnectionContext); var batch = new Collection <Instruction> { x.StartObject <DummyClass>(), x.StartMember <DummyClass>(d => d.Child), x.StartObject <ChildClass>(), x.StartMember <ChildClass>(c => c.Name), x.Value("OuterName"), x.EndMember(), x.EndObject(), x.EndMember(), x.EndObject(), }; sut.Process(batch); var result = (DummyClass)sut.Result; var childClass = result.Find("OuterName"); Assert.NotNull(childClass); }
public void MultinameRegistrationGivesSameObjectTwoSubsequentNames() { var runtimeTypeSource = CreateRuntimeTypeSource(); var x = CreateBuilder(runtimeTypeSource); var topDownValueContext = new TopDownValueContext(); var valueConnectionContext = new ValueContext(runtimeTypeSource, topDownValueContext); var sut = new ObjectAssembler(runtimeTypeSource, valueConnectionContext); var batch = new Collection<Instruction> { x.StartObject<DummyClass>(), x.StartMember<DummyClass>(d => d.Child), x.StartObject<ChildClass>(), x.StartMember<ChildClass>(c => c.Name), x.Value("OuterName"), x.EndMember(), x.EndObject(), x.EndMember(), x.EndObject(), }; sut.Process(batch); var result = (DummyClass)sut.Result; var child = (DummyObject)result.Child; Assert.Equal("InnerName", child.NamesHistory[0]); Assert.Equal("OuterName", child.NamesHistory[1]); }
public void EndMemberAssignsInstanceToParentProperty() { var state = new StackingLinkedList <Level>(); var dummyClass = new DummyClass(); var xamlType = WiringContext.TypeContext.GetXamlType(dummyClass.GetType()); state.Push( new Level { Instance = dummyClass, XamlMember = xamlType.GetMember("Child"), }); var childClass = new ChildClass(); state.Push( new Level { XamlType = xamlType, Instance = childClass, }); var sut = new ObjectAssembler(state, WiringContext, new TopDownValueContext()); sut.Process(X.EndObject()); Assert.AreEqual(1, state.Count); var expectedInstance = state.CurrentValue.Instance; Assert.AreSame(expectedInstance, dummyClass); Assert.AreSame(((DummyClass)expectedInstance).Child, childClass); }
public void GivenCtorArguments_WritingEndObjectMakesResultTheProvidedValueOfTheMarkupExtension() { var state = new StackingLinkedList <Level>(); var xamlType = WiringContext.TypeContext.GetXamlType(typeof(DummyClass)); state.Push( new Level { XamlType = xamlType, Instance = new DummyClass(), XamlMember = xamlType.GetMember("SampleProperty") }); var constructionArguments = new Collection <ConstructionArgument> { new ConstructionArgument("Value", "Value") }; state.Push( new Level { XamlType = WiringContext.TypeContext.GetXamlType(typeof(DummyExtension)), CtorArguments = constructionArguments, }); var sut = new ObjectAssembler(state, WiringContext, new TopDownValueContext()); sut.Process(X.EndObject()); Assert.AreEqual("Value", sut.Result); }
protected IObjectAssembler CreateObjectAssembler() { var topDownValueContext = new TopDownValueContext(); var objectAssembler = new ObjectAssembler(RuntimeTypeSource, new ValueContext(RuntimeTypeSource, topDownValueContext, new Dictionary <string, object>())); return(objectAssembler); }
public void EndMemberAssignsInstanceToParentProperty() { var state = new StackingLinkedList<Level>(); var dummyClass = new DummyClass(); var xamlType = WiringContext.TypeContext.GetXamlType(dummyClass.GetType()); state.Push( new Level { Instance = dummyClass, XamlMember = xamlType.GetMember("Child"), }); var childClass = new ChildClass(); state.Push( new Level { XamlType = xamlType, Instance = childClass, }); var sut = new ObjectAssembler(state, WiringContext, new TopDownValueContext()); sut.Process(X.EndObject()); Assert.AreEqual(1, state.Count); var expectedInstance = state.CurrentValue.Instance; Assert.AreSame(expectedInstance, dummyClass); Assert.AreSame(((DummyClass)expectedInstance).Child, childClass); }
public IObjectAssembler CreateAssembler(Settings settings) { var mapping = new DeferredLoaderMapping(); mapping.Map<DataTemplate>(template => template.Content, new DummyDeferredLoader()); var objectAssembler = new ObjectAssembler(runtimeTypeSource, new TopDownValueContext(), settings); return new TemplateHostingObjectAssembler(objectAssembler, mapping); }
private ObjectAssembler CreateAssemblerToReadSpecificInstance(object instance) { var settings = new ObjectAssemblerSettings { RootInstance = instance }; var assembler = new ObjectAssembler(WiringContext, topDownValueContext, settings); return(assembler); }
public IRepository PopulatedXmlRepository() { ObjectAssembler assembler = new ObjectAssembler(_create); IRepository repository = new XmlRepository(assembler); _populateRepository(repository); return(repository); }
private IObjectAssembler GetObjectAssemblerForSpecificRoot(object rootInstance) { var objectAssembler = new ObjectAssembler(wiringContext, new TopDownValueContext(), new ObjectAssemblerSettings { RootInstance = rootInstance }); var mapping = new DeferredLoaderMapping(); mapping.Map<DataTemplate>(template => template.Content, new DummyDeferredLoader()); var templateAwareObjectAssembler = new TemplateHostingObjectAssembler(objectAssembler, mapping); return templateAwareObjectAssembler; }
public IObjectAssembler CreateAssembler(ObjectAssemblerSettings settings) { var mapping = new DeferredLoaderMapping(); mapping.Map <DataTemplate>(template => template.Content, new DummyDeferredLoader()); var objectAssembler = new ObjectAssembler(wiringContext, new TopDownValueContext(), settings); return(new TemplateHostingObjectAssembler(objectAssembler, mapping)); }
public PerspexObjectAssembler(IWiringContext wiringContext, ObjectAssemblerSettings objectAssemblerSettings = null) { var mapping = new DeferredLoaderMapping(); mapping.Map <XamlDataTemplate>(template => template.Content, new TemplateLoader()); var assembler = new ObjectAssembler(wiringContext, new TopDownMemberValueContext(), objectAssemblerSettings); _objectAssembler = new TemplateHostingObjectAssembler(assembler, mapping); }
public IObjectAssembler CreateAssembler(Settings settings) { var mapping = new DeferredLoaderMapping(); mapping.Map <DataTemplate>(template => template.Content, new DummyDeferredLoader()); var topDownValueContext = new TopDownValueContext(); var valueConnectionContext = new ValueContext(runtimeTypeSource, topDownValueContext, settings.ParsingContext); var objectAssembler = new ObjectAssembler(runtimeTypeSource, valueConnectionContext, settings); return(new TemplateHostingObjectAssembler(objectAssembler, mapping)); }
private IObjectAssembler CreateObjectAssembler(Settings settings) { var topDownValueContext = new TopDownValueContext(); var objectAssembler = new ObjectAssembler(runtimeTypeSource, new ValueContext(runtimeTypeSource, topDownValueContext, new Dictionary<string, object>()), settings); var mapping = new DeferredLoaderMapping(); mapping.Map<DataTemplate>(template => template.Content, new DummyDeferredLoader()); var templateAwareObjectAssembler = new TemplateHostingObjectAssembler(objectAssembler, mapping); return templateAwareObjectAssembler; }
public PerspexObjectAssembler(IRuntimeTypeSource runtimeTypeSource, Settings objectAssemblerSettings = null) { var mapping = new DeferredLoaderMapping(); mapping.Map <ControlTemplate>(x => x.Content, new TemplateLoader()); mapping.Map <DataTemplate>(x => x.Content, new TemplateLoader()); mapping.Map <FocusAdornerTemplate>(x => x.Content, new TemplateLoader()); mapping.Map <TreeDataTemplate>(x => x.Content, new TemplateLoader()); mapping.Map <ItemsPanelTemplate>(x => x.Content, new TemplateLoader()); assembler = new ObjectAssembler(runtimeTypeSource, new TopDownValueContext(), objectAssemblerSettings); objectAssembler = new TemplateHostingObjectAssembler(assembler, mapping); }
public IObjectAssembler CreateSutForLoadingSpecificInstance(object instance) { var topDownValueContext = new TopDownValueContext(); var valueConnectionContext = new ValueContext(RuntimeTypeSource, topDownValueContext); var settings = new Settings { RootInstance = instance }; var assembler = new ObjectAssembler(RuntimeTypeSource, valueConnectionContext, settings); return(assembler); }
public PerspexObjectAssembler(IWiringContext wiringContext, ObjectAssemblerSettings objectAssemblerSettings = null) { var mapping = new DeferredLoaderMapping(); mapping.Map <ControlTemplate>(x => x.Content, new TemplateLoader()); mapping.Map <DataTemplate>(x => x.Content, new TemplateLoader()); mapping.Map <FocusAdornerTemplate>(x => x.Content, new TemplateLoader()); mapping.Map <TreeDataTemplate>(x => x.Content, new TemplateLoader()); mapping.Map <ItemsPanelTemplate>(x => x.Content, new TemplateLoader()); var assembler = new ObjectAssembler(wiringContext, new TopDownValueContext(), objectAssemblerSettings); _objectAssembler = new TemplateHostingObjectAssembler(assembler, mapping); }
private IObjectAssembler GetObjectAssemblerForSpecificRoot(object rootInstance) { var objectAssembler = new ObjectAssembler(wiringContext, new TopDownValueContext(), new ObjectAssemblerSettings { RootInstance = rootInstance }); var mapping = new DeferredLoaderMapping(); mapping.Map <DataTemplate>(template => template.Content, new DummyDeferredLoader()); var templateAwareObjectAssembler = new TemplateHostingObjectAssembler(objectAssembler, mapping); return(templateAwareObjectAssembler); }
private IObjectAssembler CreateObjectAssembler(Settings settings) { var topDownValueContext = new TopDownValueContext(); var objectAssembler = new ObjectAssembler(runtimeTypeSource, new ValueContext(runtimeTypeSource, topDownValueContext, new Dictionary <string, object>()), settings); var mapping = new DeferredLoaderMapping(); mapping.Map <DataTemplate>(template => template.Content, new DummyDeferredLoader()); var templateAwareObjectAssembler = new TemplateHostingObjectAssembler(objectAssembler, mapping); return(templateAwareObjectAssembler); }
public XamlXmlLoader Build() { var wiringContextBuilder = new WiringContextBuilder(); wiringContextBuilder .WithContentPropertiesFromAssemblies(lookupAssemblies) .WithNsPrefixes(prefixes) .WithConverters(Converters.FromAssemblies(lookupAssemblies)); RegisterNamespaces(wiringContextBuilder); RegisterContentProperties(wiringContextBuilder); var wiringContext = wiringContextBuilder.Build(); var assembler = new ObjectAssembler(wiringContext); return new XamlXmlLoader(assembler, wiringContext); }
public void StartObjectShouldSetTheXamlType() { var state = new StackingLinkedList <Level>(); state.Push(new Level()); var type = typeof(DummyClass); var sut = new ObjectAssembler(state, WiringContext, new TopDownValueContext()); sut.Process(X.StartObject(type)); var actualType = sut.StateCommuter.Current.XamlType; var expectedType = WiringContext.TypeContext.GetXamlType(type); Assert.AreEqual(expectedType, actualType); }
public AvaloniaObjectAssembler( IRuntimeTypeSource typeSource, ITopDownValueContext topDownValueContext, Settings settings = null) { var mapping = new DeferredLoaderMapping(); mapping.Map <ControlTemplate>(x => x.Content, new TemplateLoader()); mapping.Map <DataTemplate>(x => x.Content, new TemplateLoader()); mapping.Map <FocusAdornerTemplate>(x => x.Content, new TemplateLoader()); mapping.Map <TreeDataTemplate>(x => x.Content, new TemplateLoader()); mapping.Map <ItemsPanelTemplate>(x => x.Content, new TemplateLoader()); var parsingDictionary = GetDictionary(settings); var valueContext = new ValueContext(typeSource, topDownValueContext, parsingDictionary); assembler = new ObjectAssembler(typeSource, valueContext, settings); objectAssembler = new TemplateHostingObjectAssembler(assembler, mapping); }
public void SimpleTest() { var input = new Collection <Instruction> { X.StartObject <Item>(), X.StartMember <Item>(i => i.Template), X.StartObject <Template>(), X.StartMember <Template>(i => i.Content), X.StartObject <Grid>(), X.EndObject(), X.EndMember(), X.EndObject(), X.EndMember(), X.EndObject(), }; var mapping = new DeferredLoaderMapping(); var assembler = new DummyDeferredLoader(); mapping.Map <Template>(t => t.Content, assembler); var topDownValueContext = new TopDownValueContext(); var objectAssembler = new ObjectAssembler(RuntimeTypeSource, new ValueContext(RuntimeTypeSource, topDownValueContext)); var sut = new TemplateHostingObjectAssembler(objectAssembler, mapping); foreach (var instruction in input) { sut.Process(instruction); } var actualNodes = sut.NodeList; var expectedInstructions = new List <Instruction> { X.StartObject <Grid>(), X.EndObject(), }.AsReadOnly(); Assert.Equal(expectedInstructions, actualNodes); Assert.NotNull(((Item)sut.Result).Template.Content); }
public void SimpleTest() { var input = new Collection<Instruction> { X.StartObject<Item>(), X.StartMember<Item>(i => i.Template), X.StartObject<Template>(), X.StartMember<Template>(i => i.Content), X.StartObject<Grid>(), X.EndObject(), X.EndMember(), X.EndObject(), X.EndMember(), X.EndObject(), }; var mapping = new DeferredLoaderMapping(); var assembler = new DummyDeferredLoader(); mapping.Map<Template>(t => t.Content, assembler); var topDownValueContext = new TopDownValueContext(); var objectAssembler = new ObjectAssembler(RuntimeTypeSource, new ValueContext(RuntimeTypeSource, topDownValueContext)); var sut = new TemplateHostingObjectAssembler(objectAssembler, mapping); foreach (var instruction in input) { sut.Process(instruction); } var actualNodes = sut.NodeList; var expectedInstructions = new List<Instruction> { X.StartObject<Grid>(), X.EndObject(), }.AsReadOnly(); Assert.Equal(expectedInstructions, actualNodes); Assert.NotNull(((Item) sut.Result).Template.Content); }
public void GivenConfigurationOfCollection_GetObjectConfiguresTheLevel() { var state = new StackingLinkedList <Level>(); var type = typeof(DummyClass); var xamlMember = WiringContext.TypeContext.GetXamlType(type).GetMember("Items"); state.Push( new Level { Instance = new DummyClass(), XamlMember = xamlMember, }); var sut = new ObjectAssembler(state, WiringContext, new TopDownValueContext()); sut.Process(X.GetObject()); Assert.AreEqual(2, state.Count); Assert.IsTrue(state.CurrentValue.Collection != null); Assert.IsTrue(state.CurrentValue.IsGetObject); }
public void GivenConfigurationOfCollection_GetObjectConfiguresTheLevel() { var state = new StackingLinkedList<Level>(); var type = typeof(DummyClass); var xamlMember = WiringContext.TypeContext.GetXamlType(type).GetMember("Items"); state.Push( new Level { Instance = new DummyClass(), XamlMember = xamlMember, }); var sut = new ObjectAssembler(state, WiringContext, new TopDownValueContext()); sut.Process(X.GetObject()); Assert.AreEqual(2, state.Count); Assert.IsTrue(state.CurrentValue.Collection != null); Assert.IsTrue(state.CurrentValue.IsGetObject); }
public void GivenStateAfterGetObject_WritingObjectAssignsItToTheCollection() { var state = new StackingLinkedList <Level>(); var collection = new Collection <Item>(); state.Push( new Level { Collection = collection, IsGetObject = true, XamlMember = WiringContext.TypeContext.GetXamlType(typeof(DummyClass)).GetMember("Items"), }); state.Push(new Level()); var sut = new ObjectAssembler(state, WiringContext, new TopDownValueContext()); sut.Process(X.StartObject <Item>()); sut.Process(X.EndObject()); Assert.AreEqual(1, collection.Count); }
public void GivenConfiguredXamlType_StartMemberInstantiatesItSetsTheMember() { var state = new StackingLinkedList <Level>(); var type = typeof(DummyClass); state.Push( new Level { XamlType = WiringContext.TypeContext.GetXamlType(type) }); var xamlMember = WiringContext.TypeContext.GetXamlType(type).GetMember("Items"); var sut = new ObjectAssembler(state, WiringContext, new TopDownValueContext()); sut.Process(X.StartMember <DummyClass>(d => d.Items)); Assert.AreEqual(1, state.Count); Assert.IsInstanceOfType(state.CurrentValue.Instance, type); Assert.AreEqual(state.CurrentValue.XamlMember, xamlMember); }
public void GivenConfiguredInstance_StartMemberSetsTheMember() { var state = new StackingLinkedList <Level>(); var dummyClass = new DummyClass(); var xamlType = WiringContext.TypeContext.GetXamlType(dummyClass.GetType()); state.Push( new Level { Instance = dummyClass, XamlType = xamlType, }); var xamlMember = xamlType.GetMember("Items"); var sut = new ObjectAssembler(state, WiringContext, new TopDownValueContext()); sut.Process(X.StartMember <DummyClass>(d => d.Items)); Assert.AreEqual(1, state.Count); Assert.AreEqual(state.CurrentValue.XamlMember, xamlMember); }
public void GivenStateAfterGetObject_NeedsTwoEndObjectsToConsumeAllTheLevels() { var state = new StackingLinkedList <Level>(); var collection = new Collection <Item>(); state.Push( new Level { Collection = collection, XamlMember = WiringContext.TypeContext.GetXamlType(typeof(DummyClass)).GetMember("Items"), IsGetObject = true, }); state.Push(new Level { XamlType = WiringContext.TypeContext.GetXamlType(typeof(Item)) }); var sut = new ObjectAssembler(state, WiringContext, new TopDownValueContext()); sut.Process(X.EndObject()); sut.Process(X.EndObject()); Assert.AreEqual(0, state.Count); }
public EndMemberCommand(ObjectAssembler assembler, ITopDownValueContext topDownValueContext) : base(assembler) { this.topDownValueContext = topDownValueContext; typeContext = Assembler.WiringContext.TypeContext; }
public ValueCommand(ObjectAssembler objectAssembler, ITopDownValueContext topDownValueContext, string value) : base(objectAssembler) { this.value = value; ValuePipeLine = new ValuePipeline(objectAssembler.WiringContext.TypeContext, topDownValueContext); }
public void StartObjectShouldSetTheXamlType() { var state = new StackingLinkedList<Level>(); state.Push(new Level()); var type = typeof(DummyClass); var sut = new ObjectAssembler(state, WiringContext, new TopDownValueContext()); sut.Process(X.StartObject(type)); var actualType = sut.StateCommuter.Current.XamlType; var expectedType = WiringContext.TypeContext.GetXamlType(type); Assert.AreEqual(expectedType, actualType); }
public void GivenStateAfterGetObject_NeedsTwoEndObjectsToConsumeAllTheLevels() { var state = new StackingLinkedList<Level>(); var collection = new Collection<Item>(); state.Push( new Level { Collection = collection, XamlMember = WiringContext.TypeContext.GetXamlType(typeof(DummyClass)).GetMember("Items"), IsGetObject = true, }); state.Push(new Level { XamlType = WiringContext.TypeContext.GetXamlType(typeof(Item)) }); var sut = new ObjectAssembler(state, WiringContext, new TopDownValueContext()); sut.Process(X.EndObject()); sut.Process(X.EndObject()); Assert.AreEqual(0, state.Count); }
public void GivenConfiguredXamlType_StartMemberInstantiatesItSetsTheMember() { var state = new StackingLinkedList<Level>(); var type = typeof(DummyClass); state.Push( new Level { XamlType = WiringContext.TypeContext.GetXamlType(type) }); var xamlMember = WiringContext.TypeContext.GetXamlType(type).GetMember("Items"); var sut = new ObjectAssembler(state, WiringContext, new TopDownValueContext()); sut.Process(X.StartMember<DummyClass>(d => d.Items)); Assert.AreEqual(1, state.Count); Assert.IsInstanceOfType(state.CurrentValue.Instance, type); Assert.AreEqual(state.CurrentValue.XamlMember, xamlMember); }
public EndObjectCommand(ObjectAssembler assembler) : base(assembler) { }
public IObjectAssembler CreateSutForLoadingSpecificInstance(object instance) { var settings = new Settings { RootInstance = instance }; var assembler = new ObjectAssembler(TypeRuntimeTypeSource, new TopDownValueContext(), settings); return assembler; }
public StartMemberCommand(ObjectAssembler assembler, XamlMemberBase member) : base(assembler) { this.member = member; }
public NameScopeTests() { sut = new ObjectAssembler(TypeRuntimeTypeSource, new TopDownValueContext()); source = new InstructionResources(this); }
public StartObjectCommand(ObjectAssembler assembler, XamlType xamlType, object rootInstance) : base(assembler) { this.xamlType = xamlType; this.rootInstance = rootInstance; }
public void MixedCollectionWithRootInstance() { var root = new ArrayList(); var settings = new ObjectAssemblerSettings { RootInstance = root }; var assembler = new ObjectAssembler(WiringContext, topDownValueContext, settings); assembler.PumpNodes(source.MixedCollection); var result = assembler.Result; Assert.IsInstanceOfType(result, typeof(ArrayList)); var arrayList = (ArrayList)result; Assert.IsTrue(arrayList.Count > 0); }
public NameScopeTests() { sut = new ObjectAssembler(WiringContext, new TopDownValueContext()); source = new XamlInstructionResources(this); }
public GetObjectCommand(ObjectAssembler objectAssembler) : base(objectAssembler) { }
public void GivenCtorArguments_WritingEndObjectMakesResultTheProvidedValueOfTheMarkupExtension() { var state = new StackingLinkedList<Level>(); var xamlType = WiringContext.TypeContext.GetXamlType(typeof(DummyClass)); state.Push( new Level { XamlType = xamlType, Instance = new DummyClass(), XamlMember = xamlType.GetMember("SampleProperty") }); var constructionArguments = new Collection<ConstructionArgument> { new ConstructionArgument("Value", "Value") }; state.Push( new Level { XamlType = WiringContext.TypeContext.GetXamlType(typeof(DummyExtension)), CtorArguments = constructionArguments, }); var sut = new ObjectAssembler(state, WiringContext, new TopDownValueContext()); sut.Process(X.EndObject()); Assert.AreEqual("Value", sut.Result); }
public void GivenStateAfterGetObject_WritingObjectAssignsItToTheCollection() { var state = new StackingLinkedList<Level>(); var collection = new Collection<Item>(); state.Push( new Level { Collection = collection, IsGetObject = true, XamlMember = WiringContext.TypeContext.GetXamlType(typeof(DummyClass)).GetMember("Items"), }); state.Push(new Level()); var sut = new ObjectAssembler(state, WiringContext, new TopDownValueContext()); sut.Process(X.StartObject<Item>()); sut.Process(X.EndObject()); Assert.AreEqual(1, collection.Count); }
private ObjectAssembler CreateAssemblerToReadSpecificInstance(object instance) { var settings = new ObjectAssemblerSettings {RootInstance = instance}; var assembler = new ObjectAssembler(WiringContext, topDownValueContext, settings); return assembler; }
protected Command(ObjectAssembler assembler) { Assembler = assembler; }
public GetObjectWriter(ObjectAssembler objectAssembler) { this.objectAssembler = objectAssembler; bag = objectAssembler.Bag; }
public void GivenConfiguredInstance_StartMemberSetsTheMember() { var state = new StackingLinkedList<Level>(); var dummyClass = new DummyClass(); var xamlType = WiringContext.TypeContext.GetXamlType(dummyClass.GetType()); state.Push( new Level { Instance = dummyClass, XamlType = xamlType, }); var xamlMember = xamlType.GetMember("Items"); var sut = new ObjectAssembler(state, WiringContext, new TopDownValueContext()); sut.Process(X.StartMember<DummyClass>(d => d.Items)); Assert.AreEqual(1, state.Count); Assert.AreEqual(state.CurrentValue.XamlMember, xamlMember); }
public StartMemberWriter(ObjectAssembler objectAssembler) { this.objectAssembler = objectAssembler; bag = objectAssembler.Bag; }
public IParser Create(Settings settings) { var objectAssemblerForUndefinedRoot = new ObjectAssembler(runtimeTypeSource, new TopDownValueContext(), settings); return CreateParser(objectAssemblerForUndefinedRoot); }
public StartObjectWriter(ObjectAssembler objectAssembler, object rootInstance = null) { this.objectAssembler = objectAssembler; this.rootInstance = rootInstance; bag = objectAssembler.Bag; }