HAhaaaaha, good luck debugging this future-self, replace it with someone elses yeah?
상속: IDisposable
예제 #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();
     }
 }
예제 #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;
         }
     }
 }
예제 #4
0
 private void ParseDocument(JsonWriter writer)
 {
     ParseContent(writer);
 }
예제 #5
0
 private void ParseElementChildren(JsonWriter writer)
 {
     if (current.IsEmptyElement) return;
     writer.StartArray("$Elements");
     Descend();
     Next();
     ParseContent(writer);
     Ascend();
     Next();
     writer.EndArray();
 }
예제 #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();
        }
예제 #7
0
        private void ParseElement(JsonWriter writer)
        {
            writer.StartBlock();
            writer.WriteProperty("$ElementType", current.LocalName);

            ParseElementAttributes(writer);
            ParseElementChildren(writer);

            writer.EndBlock();
        }