HAhaaaaha, good luck debugging this future-self, replace it with someone elses yeah?
Inheritance: IDisposable
Exemple #1
0
 public void WriteTo(string jsonFilepath)
 {
     current = input;
     using (var writer = new JsonWriter(jsonFilepath))
     {
         ParseDocument(writer);
     }
 }
 private void ClumpJsonFromDirectoryIntoFile(string sourceDirectoryPath)
 {
     var clumpedFilepath = Path.Combine(configuration.OutputDirectory, "xaml.json");
     using (var clumpedWriter = new JsonWriter(clumpedFilepath))
     {
         clumpedWriter.StartBlock();
         foreach (var jsonFile in Directory.GetFiles(sourceDirectoryPath, "*.json"))
         {
             var propertyName = Path.GetFileName(jsonFile);
             clumpedWriter.WriteRawProperty(propertyName, File.ReadAllText(jsonFile));
         }
         clumpedWriter.EndBlock();
     }
 }
Exemple #3
0
 private void ParseContent(JsonWriter writer)
 {
     while (Next())
     {
         switch (current.NodeType)
         {
             case XmlNodeType.Element:
                 ParseElement(writer);
                 continue;
             case XmlNodeType.EndElement:
                 continue;
             default:
                 Console.WriteLine(current.NodeType);
                 break;
         }
     }
 }
Exemple #4
0
 private void ParseDocument(JsonWriter writer)
 {
     ParseContent(writer);
 }
Exemple #5
0
 private void ParseElementChildren(JsonWriter writer)
 {
     if (current.IsEmptyElement) return;
     writer.StartArray("$Elements");
     Descend();
     Next();
     ParseContent(writer);
     Ascend();
     Next();
     writer.EndArray();
 }
Exemple #6
0
        private void ParseElementAttributes(JsonWriter writer)
        {
            if (!current.HasAttributes) return;
            current.MoveToFirstAttribute();

            do
            {
                string attributeName = GetCurrentAttributeName();
                string attributeValue = current.Value;
                writer.WriteProperty(attributeName, attributeValue);

            } while (current.MoveToNextAttribute());
            current.MoveToElement();
        }
Exemple #7
0
        private void ParseElement(JsonWriter writer)
        {
            writer.StartBlock();
            writer.WriteProperty("$ElementType", current.LocalName);

            ParseElementAttributes(writer);
            ParseElementChildren(writer);

            writer.EndBlock();
        }