|
|
|
@ -7,19 +7,20 @@
@@ -7,19 +7,20 @@
|
|
|
|
|
|
|
|
|
|
using System; |
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
using System.Linq; |
|
|
|
|
using System.Xml; |
|
|
|
|
|
|
|
|
|
namespace ICSharpCode.Core |
|
|
|
|
{ |
|
|
|
|
/// <summary>
|
|
|
|
|
/// Description of Path.
|
|
|
|
|
/// Represents all contributions to a Path in a single .addin file.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class ExtensionPath |
|
|
|
|
{ |
|
|
|
|
string name; |
|
|
|
|
AddIn addIn; |
|
|
|
|
List<Codon> codons = new List<Codon>(); |
|
|
|
|
|
|
|
|
|
string name; |
|
|
|
|
AddIn addIn; |
|
|
|
|
List<List<Codon>> codons = new List<List<Codon>>(); |
|
|
|
|
|
|
|
|
|
public AddIn AddIn { |
|
|
|
|
get { |
|
|
|
|
return addIn; |
|
|
|
@ -31,27 +32,45 @@ namespace ICSharpCode.Core
@@ -31,27 +32,45 @@ namespace ICSharpCode.Core
|
|
|
|
|
return name; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
public List<Codon> Codons { |
|
|
|
|
|
|
|
|
|
public IEnumerable<Codon> Codons { |
|
|
|
|
get { |
|
|
|
|
return codons; |
|
|
|
|
return |
|
|
|
|
from list in codons |
|
|
|
|
from c in list |
|
|
|
|
select c; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the codons separated by the groups they were created in.
|
|
|
|
|
/// i.e. if two addins add the codons to the same path they will be in diffrent group.
|
|
|
|
|
/// if the same addin adds the codon in diffrent path elements they will be in diffrent groups.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public IEnumerable<IEnumerable<Codon>> GroupedCodons { |
|
|
|
|
get { |
|
|
|
|
return codons.AsReadOnly(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public ExtensionPath(string name, AddIn addIn) |
|
|
|
|
{ |
|
|
|
|
this.addIn = addIn; |
|
|
|
|
this.name = name; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void SetUp(ExtensionPath extensionPath, XmlReader reader, string endElement) |
|
|
|
|
{ |
|
|
|
|
Stack<ICondition> conditionStack = new Stack<ICondition>(); |
|
|
|
|
List<Codon> innerCodons = new List<Codon>(); |
|
|
|
|
while (reader.Read()) { |
|
|
|
|
switch (reader.NodeType) { |
|
|
|
|
case XmlNodeType.EndElement: |
|
|
|
|
if (reader.LocalName == "Condition" || reader.LocalName == "ComplexCondition") { |
|
|
|
|
conditionStack.Pop(); |
|
|
|
|
} else if (reader.LocalName == endElement) { |
|
|
|
|
if (innerCodons.Count > 0) |
|
|
|
|
extensionPath.codons.Add(innerCodons); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
@ -63,7 +82,7 @@ namespace ICSharpCode.Core
@@ -63,7 +82,7 @@ namespace ICSharpCode.Core
|
|
|
|
|
conditionStack.Push(Condition.ReadComplexCondition(reader)); |
|
|
|
|
} else { |
|
|
|
|
Codon newCodon = new Codon(extensionPath.AddIn, elementName, Properties.ReadFromAttributes(reader), conditionStack.ToArray()); |
|
|
|
|
extensionPath.codons.Add(newCodon); |
|
|
|
|
innerCodons.Add(newCodon); |
|
|
|
|
if (!reader.IsEmptyElement) { |
|
|
|
|
ExtensionPath subPath = extensionPath.AddIn.GetExtensionPath(extensionPath.Name + "/" + newCodon.Id); |
|
|
|
|
//foreach (ICondition condition in extensionPath.conditionStack) {
|
|
|
|
@ -78,6 +97,8 @@ namespace ICSharpCode.Core
@@ -78,6 +97,8 @@ namespace ICSharpCode.Core
|
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (innerCodons.Count > 0) |
|
|
|
|
extensionPath.codons.Add(innerCodons); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|