protected IObjectAssembler CreateObjectAssembler() { var topDownValueContext = new TopDownValueContext(); var objectAssembler = new ObjectAssembler(RuntimeTypeSource, new ValueContext(RuntimeTypeSource, topDownValueContext, new Dictionary <string, object>())); return(objectAssembler); }
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 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); 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 IParser Create(Settings settings) { var topDownValueContext = new TopDownValueContext(); var objectAssemblerForUndefinedRoot = new ObjectAssembler.ObjectAssembler(runtimeTypeSource, new ValueContext(runtimeTypeSource, topDownValueContext), settings); return(CreateParser(objectAssemblerForUndefinedRoot)); }
public IParser Create(Settings settings) { var topDownValueContext = new TopDownValueContext(); var objectAssemblerForUndefinedRoot = new ObjectAssembler.ObjectAssembler(runtimeTypeSource,new ValueContext(runtimeTypeSource, topDownValueContext, new Dictionary<string, object>()), settings); return CreateParser(objectAssemblerForUndefinedRoot); }
private ObjectAssembler CreateSut() { var topDownValueContext = new TopDownValueContext(); var valueConnectionContext = new ValueContext(RuntimeTypeSource, topDownValueContext); return(new ObjectAssembler(RuntimeTypeSource, valueConnectionContext, new Settings { InstanceLifeCycleListener = new TestListener() })); }
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 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)); }
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); }
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 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 IObjectAssembler CreateAssembler(Settings settings) { var topDownValueContext = new TopDownValueContext(); return(new ObjectAssembler.ObjectAssembler(typeSource, new ValueContext(typeSource, topDownValueContext), settings)); }
public void Initialize() { topDownValueContext = new TopDownValueContext(); sut = new ObjectAssembler(WiringContext, topDownValueContext); }
private ObjectAssembler CreateSut() { var topDownValueContext = new TopDownValueContext(); var valueConnectionContext = new ValueContext(RuntimeTypeSource, topDownValueContext, new Dictionary<string, object>()); return new ObjectAssembler(RuntimeTypeSource, valueConnectionContext, new Settings {InstanceLifeCycleListener = new TestListener()}); }
private IObjectAssembler CreateSutForLoadingSpecificInstance(object instance) { var topDownValueContext = new TopDownValueContext(); var valueConnectionContext = new ValueContext(RuntimeTypeSource, topDownValueContext, new Dictionary<string, object>()); var settings = new Settings {RootInstance = instance}; var assembler = new ObjectAssembler(RuntimeTypeSource, valueConnectionContext, settings); return assembler; }
public IObjectAssembler CreateAssembler(Settings settings) { var topDownValueContext = new TopDownValueContext(); return new ObjectAssembler.ObjectAssembler(typeSource, new ValueContext(typeSource, topDownValueContext, new Dictionary<string, object>()), settings); }
public IObjectAssembler CreateAssembler(Settings settings) { var topDownValueContext = new TopDownValueContext(); return new ObjectAssembler.ObjectAssembler(typeSource, new ValueContext(typeSource, topDownValueContext), settings); }
protected IObjectAssembler CreateObjectAssembler() { var topDownValueContext = new TopDownValueContext(); var objectAssembler = new ObjectAssembler(RuntimeTypeSource, new ValueContext(RuntimeTypeSource, topDownValueContext, new Dictionary<string, object>())); return objectAssembler; }
public IObjectAssembler CreateAssembler(Settings settings) { var topDownValueContext = new TopDownValueContext(); return(new ObjectAssembler.ObjectAssembler(typeSource, new ValueContext(typeSource, topDownValueContext, new Dictionary <string, object>()), settings)); }