Exemplo n.º 1
0
    public async Task ParseAsync(XmlReader reader, IParsingContext parsingContext, IParentParsingContext parentParsingContext)
    {
        var context = new BackgroundContext();
        await elementParser.ParseAsync(reader, parsingContext, context, Settings);

        if (!string.IsNullOrWhiteSpace(context.ParsedText))
        {
            var state = new BackgroundState(context.ParsedText, BackgroundType.Image, BackgroundPosition.Left);
            var block = parsingContext.BlockFactory.Create(
                new BackgroundNode(state, null),
                new ScrollNode(null)
                );
            parentParsingContext.AddNode(new BlockNode(block, context.When));
            parsingContext.RegisterDismissNode(DismissNode);
            return;
        }

        if (context.Nodes.Count == 0)
        {
            parsingContext.LogError(reader, "Nome de imagem ou elemento filho era esperado.");
            return;
        }

        {
            var block = parsingContext.BlockFactory.Create(context.Nodes);
            parentParsingContext.AddNode(new BlockNode(block, context.When));
            parsingContext.RegisterDismissNode(DismissNode);
        }
    }
Exemplo n.º 2
0
    public StoryboardParserTests()
    {
        blockFactory = new FakeBlockFactory();
        dismissNodes = new();
        parsingContext = A.Fake<IParsingContext>(i => i.Strict());
        A.CallTo(() => parsingContext.RegisterDismissNode(A<INode>.Ignored))
            .Invokes(i => dismissNodes.Add(i.Arguments.Get<INode>(0)));
        A.CallTo(() => parsingContext.BlockFactory).Returns(blockFactory);

        rootBlockParser = A.Fake<IRootBlockParser>(i => i.Strict());
        sceneNavigator = A.Fake<ISceneNavigator>(i => i.Strict());
        eventManager = A.Fake<IEventManager>(i => i.Strict());
        randomizer = A.Fake<IRandomizer>(i => i.Strict());
        navigationState = A.Fake<INavigationState>(i => i.Strict());
        variableDictionary = A.Fake<IVariableDictionary>(i => i.Strict());
        blockState = A.Fake<IBlockState>(i => i.Strict());

        var serviceProvider = A.Fake<IServiceProvider>(i => i.Strict());
        A.CallTo(() => serviceProvider.GetService(typeof(IParsingContext))).Returns(parsingContext);
        A.CallTo(() => serviceProvider.GetService(typeof(IRootBlockParser))).Returns(rootBlockParser);
        A.CallTo(() => serviceProvider.GetService(typeof(ISceneNavigator))).Returns(sceneNavigator);
        A.CallTo(() => serviceProvider.GetService(typeof(IEventManager))).Returns(eventManager);
        A.CallTo(() => serviceProvider.GetService(typeof(IRandomizer))).Returns(randomizer);
        A.CallTo(() => serviceProvider.GetService(typeof(INavigationState))).Returns(navigationState);
        A.CallTo(() => serviceProvider.GetService(typeof(IVariableDictionary))).Returns(variableDictionary);
        A.CallTo(() => serviceProvider.GetService(typeof(IBlockState))).Returns(blockState);
        sut = new StoryboardParser(serviceProvider);
    }
Exemplo n.º 3
0
    public async Task ParseAsync(XmlReader reader, IParsingContext parsingContext, IParentParsingContext parentParsingContext)
    {
        var myContext = new TextParentParsingContext();
        await elementParser.ParseAsync(reader, parsingContext, myContext, Settings);

        var parsedText = myContext.ParsedText;

        if (parsedText is null)
        {
            return;
        }

        var node = new ProtagonistNode(parsedText.Length == 0 ? null : parsedText, myContext.When);

        parentParsingContext.AddNode(node);
        parsingContext.RegisterDismissNode(DismissNode);
    }
Exemplo n.º 4
0
    public async Task ParseAsync(XmlReader reader, IParsingContext parsingContext, IParentParsingContext parentParsingContext)
    {
        var myContext = new TextParentParsingContext();
        await elementParser.ParseAsync(reader, parsingContext, myContext, Settings);

        var parsedText = myContext.ParsedText;

        if (parsedText is null)
        {
            return;
        }

        if (parsingContext.SceneContext.HasMusic)
        {
            parsingContext.LogError(reader, "Mais de uma definição de música para a mesma cena.");
            return;
        }
        parsingContext.SceneContext.HasMusic = true;

        var node = new MusicNode(parsedText.Length == 0 ? null : parsedText, myContext.When);

        parentParsingContext.AddNode(node);
        parsingContext.RegisterDismissNode(DismissNode);
    }