ficdown/Ficdown.Parser/FicDownParser.cs

33 lines
912 B
C#
Raw Normal View History

namespace Ficdown.Parser
{
using System;
using Model.Story;
using Parser;
public class FicdownParser
{
private IBlockHandler _blockHandler;
public IBlockHandler BlockHandler
{
get { return _blockHandler ?? (_blockHandler = new BlockHandler()); }
set { _blockHandler = value; }
}
private IStateResolver _stateResolver;
2014-06-30 11:59:56 -05:00
public IStateResolver StateResolver
2014-06-30 11:59:56 -05:00
{
get { return _stateResolver ?? (_stateResolver = new StateResolver()); }
set { _stateResolver = value; }
2014-06-30 11:59:56 -05:00
}
2014-06-30 16:57:14 -05:00
public Story ParseStory(string storyText)
{
var lines = storyText.Split(new[] {"\n", "\r\n"}, StringSplitOptions.None);
var blocks = BlockHandler.ExtractBlocks(lines);
2014-06-30 16:57:14 -05:00
var story = BlockHandler.ParseBlocks(blocks);
return story;
}
}
}