Skip to content

Commit 114f61e

Browse files
authored
Merge pull request #62 from Flamifly/rtf-remove-streamreader
removed unused StreamReader
2 parents 9c98f4b + 4509812 commit 114f61e

File tree

1 file changed

+8
-22
lines changed

1 file changed

+8
-22
lines changed
Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,24 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.IO;
4-
using System.Text.RegularExpressions;
5-
using Toxy;
1+
using System.IO;
62

73
namespace Toxy.Parsers
84
{
95
public class RTFTextParser : ITextParser
106
{
117
public RTFTextParser(ParserContext context)
128
{
13-
this.Context = context;
14-
}
15-
public virtual ParserContext Context
16-
{
17-
get; set;
9+
Context = context;
1810
}
11+
public virtual ParserContext Context { get; set; }
1912
public string Parse()
2013
{
2114
if (!File.Exists(Context.Path))
22-
throw new FileNotFoundException("File " + Context.Path + " is not found");
23-
24-
StreamReader sr = null;
25-
try
2615
{
27-
ReasonableRTF.RtfToTextConverter converter = new ReasonableRTF.RtfToTextConverter();
28-
ReasonableRTF.Models.RtfResult result = converter.Convert(File.ReadAllBytes(Context.Path));
29-
return result.Text;
30-
}
31-
finally
32-
{
33-
if (sr != null)
34-
sr.Close();
16+
throw new FileNotFoundException("File " + Context.Path + " is not found");
3517
}
18+
19+
ReasonableRTF.RtfToTextConverter converter = new ReasonableRTF.RtfToTextConverter();
20+
ReasonableRTF.Models.RtfResult result = converter.Convert(File.ReadAllBytes(Context.Path));
21+
return result.Text;
3622
}
3723
}
3824
}

0 commit comments

Comments
 (0)