Code Coverage Statistics for Source File
c:\Tools\SD3\src\Libraries\ICSharpCode.TextEditor\Project\Src\Document\DocumentFactory.cs
|
Sequence Point Coverage
N/A
0 of 0
|
Branch Coverage
N/A
0 of 0
|
Lines
58
|
Highlight:
Uncovered Code
Covered Code
| L | V | Source |
|---|---|---|
1 |
// <file> |
|
2 |
// <copyright see="prj:///doc/copyright.txt"/> |
|
3 |
// <license see="prj:///doc/license.txt"/> |
|
4 |
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/> |
|
5 |
// <version>$Revision: 2691 $</version> |
|
6 |
// </file> |
|
7 |
||
8 |
using System; |
|
9 |
using System.Text; |
|
10 |
||
11 |
namespace ICSharpCode.TextEditor.Document |
|
12 |
{ |
|
13 |
/// <summary> |
|
14 |
/// This interface represents a container which holds a text sequence and |
|
15 |
/// all necessary information about it. It is used as the base for a text editor. |
|
16 |
/// </summary> |
|
17 |
public class DocumentFactory |
|
18 |
{ |
|
19 |
/// <remarks> |
|
20 |
/// Creates a new <see cref="IDocument"/> object. Only create |
|
21 |
/// <see cref="IDocument"/> with this method. |
|
22 |
/// </remarks> |
|
23 |
public IDocument CreateDocument() |
|
24 |
{ |
|
25 |
DefaultDocument doc = new DefaultDocument(); |
|
26 |
doc.TextBufferStrategy = new GapTextBufferStrategy(); |
|
27 |
doc.FormattingStrategy = new DefaultFormattingStrategy(); |
|
28 |
doc.LineManager = new LineManager(doc, null); |
|
29 |
doc.FoldingManager = new FoldingManager(doc, doc.LineManager); |
|
30 |
doc.FoldingManager.FoldingStrategy = null; //new ParserFoldingStrategy(); |
|
31 |
doc.MarkerStrategy = new MarkerStrategy(doc); |
|
32 |
doc.BookmarkManager = new BookmarkManager(doc, doc.LineManager); |
|
33 |
doc.CustomLineManager = new CustomLineManager(doc.LineManager); |
|
34 |
return doc; |
|
35 |
} |
|
36 |
||
37 |
/// <summary> |
|
38 |
/// Creates a new document and loads the given file |
|
39 |
/// </summary> |
|
40 |
public IDocument CreateFromTextBuffer(ITextBufferStrategy textBuffer) |
|
41 |
{ |
|
42 |
DefaultDocument doc = (DefaultDocument)CreateDocument(); |
|
43 |
doc.TextContent = textBuffer.GetText(0, textBuffer.Length); |
|
44 |
doc.TextBufferStrategy = textBuffer; |
|
45 |
return doc; |
|
46 |
} |
|
47 |
||
48 |
/// <summary> |
|
49 |
/// Creates a new document and loads the given file |
|
50 |
/// </summary> |
|
51 |
public IDocument CreateFromFile(string fileName) |
|
52 |
{ |
|
53 |
IDocument document = CreateDocument(); |
|
54 |
document.TextContent = Util.FileReader.ReadFileContent(fileName, Encoding.Default); |
|
55 |
return document; |
|
56 |
} |
|
57 |
} |
|
58 |
} |