From f4504ab36e459e40d4dff028a8f2448fb3ad21f3 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Fri, 24 Jun 2011 17:50:16 +0200 Subject: [PATCH] move NodesCollection to a separate file --- .../ILSpy.BamlDecompiler.csproj | 1 + .../NodesCollection.cs | 68 +++++++++++++++++++ .../XmlBamlReader.cs | 63 +---------------- 3 files changed, 71 insertions(+), 61 deletions(-) create mode 100644 ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/NodesCollection.cs diff --git a/ILSpy.BamlDecompiler/ILSpy.BamlDecompiler.csproj b/ILSpy.BamlDecompiler/ILSpy.BamlDecompiler.csproj index 8e2f0c90b..26b25f1d3 100644 --- a/ILSpy.BamlDecompiler/ILSpy.BamlDecompiler.csproj +++ b/ILSpy.BamlDecompiler/ILSpy.BamlDecompiler.csproj @@ -87,6 +87,7 @@ + diff --git a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/NodesCollection.cs b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/NodesCollection.cs new file mode 100644 index 000000000..c2170b71c --- /dev/null +++ b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/NodesCollection.cs @@ -0,0 +1,68 @@ +// Copyright (c) Cristian Civera (cristian@aspitalia.com) +// This code is distributed under the MS-PL (for details please see \doc\MS-PL.txt) + +using System; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Xml; +using System.Windows.Media; + +namespace Ricciolo.StylesExplorer.MarkupReflection +{ + class NodesCollection : List + { + public XmlBamlNode Last + { + get + { + if (this.Count > 0) + { + int i = this.Count - 1; + return this[i]; + } + return null; + } + } + + public void RemoveLast() + { + if (this.Count > 0) + this.Remove(this.Last); + } + + public XmlBamlNode Dequeue() + { + return DequeueInternal(true); + } + + public XmlBamlNode Peek() + { + return DequeueInternal(false); + } + + XmlBamlNode DequeueInternal(bool remove) + { + if (this.Count > 0) + { + XmlBamlNode node = this[0]; + if (remove) + this.RemoveAt(0); + return node; + } + else + return null; + } + + public void Enqueue(XmlBamlNode node) + { + this.Add(node); + } + } +} diff --git a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs index e2d1e7e25..0c1ec8712 100644 --- a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs +++ b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs @@ -1334,9 +1334,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection CloseElement(); complexPropertyOpened--; - if (complexPropertyOpened == 0) - { - + if (complexPropertyOpened == 0) { int start = nodes.IndexOf(propertyElement); StringBuilder sb = new StringBuilder(); @@ -1465,8 +1463,6 @@ namespace Ricciolo.StylesExplorer.MarkupReflection return String.Format("{0}:{1}", prefix, name); } - - string FormatPropertyDeclaration(PropertyDeclaration propertyDeclaration, bool withPrefix, bool useReading, bool checkType) { StringBuilder sb = new StringBuilder(); @@ -1522,7 +1518,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection if (identifier < keys[currentKey - 1].StaticResources.Count) return keys[currentKey - 1].StaticResources[(int)identifier]; -// return "???" + identifier +"???"; +// return "???" + identifier + "???"; throw new ArgumentException("Cannot find StaticResource", "identifier"); } @@ -1889,60 +1885,5 @@ namespace Ricciolo.StylesExplorer.MarkupReflection } #endregion - - #region NodesCollection - - internal class NodesCollection : List - { - public XmlBamlNode Last - { - get - { - if (this.Count > 0) - { - int i = this.Count - 1; - return this[i]; - } - return null; - } - } - - public void RemoveLast() - { - if (this.Count > 0) - this.Remove(this.Last); - } - - public XmlBamlNode Dequeue() - { - return DequeueInternal(true); - } - - public XmlBamlNode Peek() - { - return DequeueInternal(false); - } - - XmlBamlNode DequeueInternal(bool remove) - { - if (this.Count > 0) - { - XmlBamlNode node = this[0]; - if (remove) - this.RemoveAt(0); - return node; - } - else - return null; - } - - - public void Enqueue(XmlBamlNode node) - { - this.Add(node); - } - } - - #endregion } } \ No newline at end of file