2014-06-29 23:04:51 -05:00
|
|
|
|
namespace Ficdown.Parser
|
|
|
|
|
{
|
2014-07-01 01:51:08 -05:00
|
|
|
|
using System;
|
2014-06-29 23:04:51 -05:00
|
|
|
|
using Model.Story;
|
2014-07-02 23:11:36 -05:00
|
|
|
|
using Parser;
|
2014-06-29 23:04:51 -05:00
|
|
|
|
|
|
|
|
|
public class FicdownParser
|
|
|
|
|
{
|
|
|
|
|
private IBlockHandler _blockHandler;
|
|
|
|
|
public IBlockHandler BlockHandler
|
|
|
|
|
{
|
|
|
|
|
get { return _blockHandler ?? (_blockHandler = new BlockHandler()); }
|
|
|
|
|
set { _blockHandler = value; }
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-02 23:11:36 -05:00
|
|
|
|
private IStateResolver _stateResolver;
|
2014-06-30 11:59:56 -05:00
|
|
|
|
|
2014-07-02 23:11:36 -05:00
|
|
|
|
public IStateResolver StateResolver
|
2014-06-30 11:59:56 -05:00
|
|
|
|
{
|
2014-07-02 23:11:36 -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)
|
2014-06-29 23:04:51 -05:00
|
|
|
|
{
|
2014-07-01 01:51:08 -05:00
|
|
|
|
var lines = storyText.Split(new[] {"\n", "\r\n"}, StringSplitOptions.None);
|
2014-06-29 23:04:51 -05:00
|
|
|
|
var blocks = BlockHandler.ExtractBlocks(lines);
|
2014-06-30 16:57:14 -05:00
|
|
|
|
var story = BlockHandler.ParseBlocks(blocks);
|
|
|
|
|
return story;
|
2014-06-29 23:04:51 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|