Code Coverage Statistics for Source File
c:\Tools\SD3\src\Libraries\ICSharpCode.TextEditor\Project\Src\Document\HighlightingStrategy\SyntaxModes\SyntaxMode.cs
|
Sequence Point Coverage
N/A
0 of 0
|
Branch Coverage
N/A
0 of 0
|
Lines
96
|
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: 2533 $</version> |
|
6 |
// </file> |
|
7 |
||
8 |
using System; |
|
9 |
using System.Collections.Generic; |
|
10 |
using System.IO; |
|
11 |
using System.Windows.Forms; |
|
12 |
using System.Xml; |
|
13 |
||
14 |
namespace ICSharpCode.TextEditor.Document |
|
15 |
{ |
|
16 |
public class SyntaxMode |
|
17 |
{ |
|
18 |
string fileName; |
|
19 |
string name; |
|
20 |
string[] extensions; |
|
21 |
||
22 |
public string FileName { |
|
23 |
get { |
|
24 |
return fileName; |
|
25 |
} |
|
26 |
set { |
|
27 |
fileName = value; |
|
28 |
} |
|
29 |
} |
|
30 |
||
31 |
public string Name { |
|
32 |
get { |
|
33 |
return name; |
|
34 |
} |
|
35 |
set { |
|
36 |
name = value; |
|
37 |
} |
|
38 |
} |
|
39 |
||
40 |
public string[] Extensions { |
|
41 |
get { |
|
42 |
return extensions; |
|
43 |
} |
|
44 |
set { |
|
45 |
extensions = value; |
|
46 |
} |
|
47 |
} |
|
48 |
||
49 |
public SyntaxMode(string fileName, string name, string extensions) |
|
50 |
{ |
|
51 |
this.fileName = fileName; |
|
52 |
this.name = name; |
|
53 |
this.extensions = extensions.Split(';', '|', ','); |
|
54 |
} |
|
55 |
||
56 |
public SyntaxMode(string fileName, string name, string[] extensions) |
|
57 |
{ |
|
58 |
this.fileName = fileName; |
|
59 |
this.name = name; |
|
60 |
this.extensions = extensions; |
|
61 |
} |
|
62 |
||
63 |
public static List<SyntaxMode> GetSyntaxModes(Stream xmlSyntaxModeStream) |
|
64 |
{ |
|
65 |
XmlTextReader reader = new XmlTextReader(xmlSyntaxModeStream); |
|
66 |
List<SyntaxMode> syntaxModes = new List<SyntaxMode>(); |
|
67 |
while (reader.Read()) { |
|
68 |
switch (reader.NodeType) { |
|
69 |
case XmlNodeType.Element: |
|
70 |
switch (reader.Name) { |
|
71 |
case "SyntaxModes": |
|
72 |
string version = reader.GetAttribute("version"); |
|
73 |
if (version != "1.0") { |
|
74 |
throw new HighlightingDefinitionInvalidException("Unknown syntax mode file defininition with version " + version); |
|
75 |
} |
|
76 |
break; |
|
77 |
case "Mode": |
|
78 |
syntaxModes.Add(new SyntaxMode(reader.GetAttribute("file"), |
|
79 |
reader.GetAttribute("name"), |
|
80 |
reader.GetAttribute("extensions"))); |
|
81 |
break; |
|
82 |
default: |
|
83 |
throw new HighlightingDefinitionInvalidException("Unknown node in syntax mode file :" + reader.Name); |
|
84 |
} |
|
85 |
break; |
|
86 |
} |
|
87 |
} |
|
88 |
reader.Close(); |
|
89 |
return syntaxModes; |
|
90 |
} |
|
91 |
public override string ToString() |
|
92 |
{ |
|
93 |
return String.Format("[SyntaxMode: FileName={0}, Name={1}, Extensions=({2})]", fileName, name, String.Join(",", extensions)); |
|
94 |
} |
|
95 |
} |
|
96 |
} |