diff --git a/csharp/Platform.Data.Doublets.Xml/DefaultXmlStorage.cs b/csharp/Platform.Data.Doublets.Xml/DefaultXmlStorage.cs
index 3c7a526..17f98cb 100644
--- a/csharp/Platform.Data.Doublets.Xml/DefaultXmlStorage.cs
+++ b/csharp/Platform.Data.Doublets.Xml/DefaultXmlStorage.cs
@@ -4,6 +4,7 @@
using Platform.Data.Doublets;
using Platform.Data.Doublets.Sequences.Converters;
using Platform.Data.Doublets.Sequences.Frequencies.Cache;
+using Platform.Data.Doublets.Sequences.Frequencies.Counters;
using Platform.Data.Doublets.Sequences.Indexes;
using Platform.Data.Doublets.Unicode;
@@ -20,78 +21,16 @@ namespace Platform.Data.Doublets.Xml
///
public class DefaultXmlStorage : IXmlStorage
{
- ///
- ///
- /// The zero.
- ///
- ///
- ///
private static readonly TLink _zero = default;
- ///
- ///
- /// The zero.
- ///
- ///
- ///
private static readonly TLink _one = Arithmetic.Increment(_zero);
-
- ///
- ///
- /// The string to unicode sequence converter.
- ///
- ///
- ///
private readonly StringToUnicodeSequenceConverter _stringToUnicodeSequenceConverter;
- ///
- ///
- /// The links.
- ///
- ///
- ///
private readonly ILinks _links;
- ///
- ///
- /// The unicode symbol marker.
- ///
- ///
- ///
private TLink _unicodeSymbolMarker;
- ///
- ///
- /// The unicode sequence marker.
- ///
- ///
- ///
private TLink _unicodeSequenceMarker;
- ///
- ///
- /// The element marker.
- ///
- ///
- ///
private TLink _elementMarker;
- ///
- ///
- /// The text element marker.
- ///
- ///
- ///
private TLink _textElementMarker;
- ///
- ///
- /// The document marker.
- ///
- ///
- ///
private TLink _documentMarker;
-
- ///
- ///
- /// Represents the unindex.
- ///
- ///
- ///
- ///
+
private class Unindex : ISequenceIndex
{
///
@@ -109,6 +48,7 @@ private class Unindex : ISequenceIndex
///
///
public bool Add(IList sequence) => true;
+
///
///
/// Determines whether this instance might contain.
@@ -156,16 +96,11 @@ public DefaultXmlStorage(ILinks links, bool indexSequenceBeforeCreation,
_links = links;
}
- ///
- ///
- /// Inits the constants using the specified links.
- ///
- ///
- ///
- ///
- /// The links.
- ///
- ///
+ public DefaultXmlStorage(ILinks links, bool indexSequenceBeforeCreation = false) :
+ this(links, indexSequenceBeforeCreation,
+ new LinkFrequenciesCache(links,
+ new TotalSequenceSymbolFrequencyCounter(links))) { }
+
private void InitConstants(ILinks links)
{
var markerIndex = _one;
@@ -176,6 +111,7 @@ private void InitConstants(ILinks links)
_textElementMarker = links.GetOrCreate(meaningRoot, Arithmetic.Increment(ref markerIndex));
_documentMarker = links.GetOrCreate(meaningRoot, Arithmetic.Increment(ref markerIndex));
}
+
///
///
/// Creates the document using the specified name.
@@ -191,6 +127,7 @@ private void InitConstants(ILinks links)
///
///
public TLink CreateDocument(string name) => Create(_documentMarker, name);
+
///
///
/// Creates the element using the specified name.
@@ -206,6 +143,7 @@ private void InitConstants(ILinks links)
///
///
public TLink CreateElement(string name) => Create(_elementMarker, name);
+
///
///
/// Creates the text element using the specified content.
@@ -221,25 +159,9 @@ private void InitConstants(ILinks links)
///
///
public TLink CreateTextElement(string content) => Create(_textElementMarker, content);
- ///
- ///
- /// Creates the marker.
- ///
- ///
- ///
- ///
- /// The marker.
- ///
- ///
- ///
- /// The content.
- ///
- ///
- ///
- /// The link
- ///
- ///
+
private TLink Create(TLink marker, string content) => _links.GetOrCreate(marker, _stringToUnicodeSequenceConverter.Convert(content));
+
///
///
/// Attaches the element to parent using the specified element to attach.
@@ -271,6 +193,7 @@ private void InitConstants(ILinks links)
///
///
public TLink GetDocument(string name) => Get(_documentMarker, name);
+
///
///
/// Gets the text element using the specified content.
@@ -301,25 +224,9 @@ private void InitConstants(ILinks links)
///
///
public TLink GetElement(string name) => Get(_elementMarker, name);
- ///
- ///
- /// Gets the marker.
- ///
- ///
- ///
- ///
- /// The marker.
- ///
- ///
- ///
- /// The content.
- ///
- ///
- ///
- /// The link
- ///
- ///
+
private TLink Get(TLink marker, string content) => _links.SearchOrDefault(marker, _stringToUnicodeSequenceConverter.Convert(content));
+
///
///
/// Gets the children using the specified parent.
@@ -335,7 +242,7 @@ private void InitConstants(ILinks links)
///
///
public IList GetChildren(TLink parent) {
- var childrens = new List();
+ List childrens = new List();
_links.Each((link) => {
childrens.Add(_links.GetTarget(link));
return this._links.Constants.Continue;
diff --git a/csharp/Platform.Data.Doublets.Xml/XmlExporter.cs b/csharp/Platform.Data.Doublets.Xml/XmlExporter.cs
index 67b189e..eb185c5 100644
--- a/csharp/Platform.Data.Doublets.Xml/XmlExporter.cs
+++ b/csharp/Platform.Data.Doublets.Xml/XmlExporter.cs
@@ -74,25 +74,7 @@ public Task Export(string documentName, string fileName, CancellationToken token
}
}, token);
}
-
- ///
- ///
- /// Writes the writer.
- ///
- ///
- ///
- ///
- /// The writer.
- ///
- ///
- ///
- /// The token.
- ///
- ///
- ///
- /// The context.
- ///
- ///
+
private void Write(XmlWriter writer, CancellationToken token, ElementContext context)
{
var parentContexts = new Stack();
@@ -104,33 +86,9 @@ private void Write(XmlWriter writer, CancellationToken token, ElementContext con
}
}
- ///
- ///
- /// Represents the element context.
- ///
- ///
- ///
- ///
private class ElementContext : XmlElementContext
{
- ///
- ///
- /// The parent.
- ///
- ///
- ///
public readonly TLink Parent;
-
- ///
- ///
- /// Initializes a new instance.
- ///
- ///
- ///
- ///
- /// A parent.
- ///
- ///
public ElementContext(TLink parent) => Parent = parent;
}
diff --git a/csharp/Platform.Data.Doublets.Xml/XmlExporterCLI.cs b/csharp/Platform.Data.Doublets.Xml/XmlExporterCLI.cs
new file mode 100644
index 0000000..534c5b8
--- /dev/null
+++ b/csharp/Platform.Data.Doublets.Xml/XmlExporterCLI.cs
@@ -0,0 +1,42 @@
+using System;
+using System.IO;
+using Platform.IO;
+using Platform.Data.Doublets.Memory.United.Generic;
+
+#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
+
+namespace Platform.Data.Doublets.Xml
+{
+ public class XmlExporterCLI : ICommandLineInterface
+ {
+ public void Run(params string[] args)
+ {
+ var linksFile = ConsoleHelpers.GetOrReadArgument(0, "Links file", args);
+ var exportFile = ConsoleHelpers.GetOrReadArgument(1, "Xml file", args);
+
+ if (File.Exists(exportFile))
+ {
+ Console.WriteLine("Entered xml file does already exists.");
+ }
+ else
+ {
+ using (var cancellation = new ConsoleCancellation())
+ {
+ using (var memoryAdapter = new UnitedMemoryLinks(linksFile))
+ {
+ {
+ Console.WriteLine("Press CTRL+C to stop.");
+ var links = memoryAdapter.DecorateWithAutomaticUniquenessAndUsagesResolution();
+ if (cancellation.NotRequested)
+ {
+ var storage = new DefaultXmlStorage(links);
+ var exporter = new XmlExporter(storage);
+ exporter.Export(linksFile, exportFile, cancellation.Token).Wait();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file