Exemplo n.º 1
0
    string RunWriter(int initialdepth, object o, int horizontalthreshold, IDictionary <Type, bool> bbt, Func <int, YNode, string> anno)
    {
        var w = new YAMLWriter(new StringWriter(), initialdepth, horizontalthreshold, bbt);

        w.Annotate = anno;
        return(w.Write(o).ToString());
    }
Exemplo n.º 2
0
Arquivo: tap.cs Projeto: am11/TAP.Net
 public static void Dump(string name, object o)
 {
     using (new WithInvariantCulture()) {
         lock (WriteLock) {
             Diag("dump of " + name + ": ");
             var yw = new YAMLWriter(Console.Out, 0, TAP.HorizontalThreshold, null);
             yw.Write(o);
         }
     }
 }
 public void Export(IExportContainer container, Object asset, string path)
 {
     using (FileStream fileStream = File.Open(path, FileMode.Create, FileAccess.Write))
     {
         using (StreamWriter streamWriter = new StreamWriter(fileStream))
         {
             YAMLWriter   writer = new YAMLWriter();
             YAMLDocument doc    = asset.ExportYAMLDocument(container);
             writer.AddDocument(doc);
             writer.Write(streamWriter);
         }
     }
 }
Exemplo n.º 4
0
 public void Export(IExportContainer container, Object asset, string path, Action <IExportContainer, Object, string> callback)
 {
     using (FileStream fileStream = FileUtils.Open(path, FileMode.Create, FileAccess.Write))
     {
         using (StreamWriter streamWriter = new InvariantStreamWriter(fileStream, Encoding.UTF8))
         {
             YAMLWriter   writer = new YAMLWriter();
             YAMLDocument doc    = asset.ExportYAMLDocument(container);
             writer.AddDocument(doc);
             writer.Write(streamWriter);
         }
     }
     callback?.Invoke(container, asset, path);
 }
Exemplo n.º 5
0
 public bool Export(IExportContainer container, Object asset, string path)
 {
     using (Stream fileStream = FileUtils.CreateVirtualFile(path))
     {
         using (StreamWriter streamWriter = new InvariantStreamWriter(fileStream, new UTF8Encoding(false)))
         {
             YAMLWriter   writer = new YAMLWriter();
             YAMLDocument doc    = asset.ExportYAMLDocument(container);
             writer.AddDocument(doc);
             writer.Write(streamWriter);
         }
     }
     return(true);
 }
Exemplo n.º 6
0
 public void Export(IExportContainer container, Object asset, string path, Action <IExportContainer, Object, string> callback)
 {
     using (Stream fileStream = FileUtils.CreateVirtualFile(path))
     {
         using (StreamWriter streamWriter = new InvariantStreamWriter(fileStream, new UTF8Encoding(false)))
         {
             YAMLWriter   writer = new YAMLWriter();
             YAMLDocument doc    = asset.ExportYAMLDocument(container);
             writer.AddDocument(doc);
             writer.Write(streamWriter);
         }
     }
     callback?.Invoke(container, asset, path);
 }
 private void ExportYAML(IAssetsExporter exporter, UtinyRipper.Classes.Object asset, string path)
 {
     using (FileStream fileStream = File.Open(path, FileMode.Create, FileAccess.Write))
     {
         using (StreamWriter streamWriter = new StreamWriter(fileStream))
         {
             YAMLWriter writer = new YAMLWriter();
             exporter.File = asset.File;
             YAMLDocument doc = asset.ExportYAMLDocument(exporter);
             writer.AddDocument(doc);
             writer.Write(streamWriter);
         }
     }
 }
Exemplo n.º 8
0
        protected void ExportMeta(ProjectAssetContainer container, Meta meta, string filePath)
        {
            string metaPath = $"{filePath}.meta";

            using (FileStream fileStream = System.IO.File.Open(metaPath, FileMode.Create, FileAccess.Write))
            {
                using (StreamWriter streamWriter = new StreamWriter(fileStream))
                {
                    YAMLWriter   writer = new YAMLWriter();
                    YAMLDocument doc    = meta.ExportYAMLDocument(container);
                    writer.IsWriteDefaultTag = false;
                    writer.IsWriteVersion    = false;
                    writer.AddDocument(doc);
                    writer.Write(streamWriter);
                }
            }
        }
Exemplo n.º 9
0
        protected void ExportMeta(IExportContainer container, Meta meta, string filePath)
        {
            string metaPath = $"{filePath}.meta";

            using (Stream fileStream = FileUtils.CreateVirtualFile(metaPath))
            {
                using (StreamWriter streamWriter = new InvariantStreamWriter(fileStream, new UTF8Encoding(false)))
                {
                    YAMLWriter   writer = new YAMLWriter();
                    YAMLDocument doc    = meta.ExportYAMLDocument(container);
                    writer.IsWriteDefaultTag = false;
                    writer.IsWriteVersion    = false;
                    writer.AddDocument(doc);
                    writer.Write(streamWriter);
                }
            }
        }
 private void ExportYAML(IAssetsExporter exporter, IEnumerable <UtinyRipper.Classes.Object> objects, string path)
 {
     using (FileStream fileStream = File.Open(path, FileMode.Create, FileAccess.Write))
     {
         using (StreamWriter streamWriter = new StreamWriter(fileStream))
         {
             YAMLWriter writer = new YAMLWriter();
             foreach (Object @object in objects)
             {
                 exporter.File = @object.File;
                 YAMLDocument doc = @object.ExportYAMLDocument(exporter);
                 writer.AddDocument(doc);
             }
             writer.Write(streamWriter);
         }
     }
 }
Exemplo n.º 11
0
        protected static void ExportMeta(IExportContainer container, Meta meta, string filePath)
        {
            string metaPath = $"{filePath}{MetaExtension}";

            using (var fileStream = FileUtils.CreateVirtualFile(metaPath))
                using (var stream = new BufferedStream(fileStream))
                    using (var streamWriter = new InvariantStreamWriter(stream, new UTF8Encoding(false)))
                    {
                        YAMLWriter writer = new YAMLWriter();
                        writer.IsWriteDefaultTag = false;
                        writer.IsWriteVersion    = false;
                        writer.IsFormatKeys      = true;
                        YAMLDocument doc = meta.ExportYAMLDocument(container);
                        writer.AddDocument(doc);
                        writer.Write(streamWriter);
                    }
        }
Exemplo n.º 12
0
 public void Export(ProjectAssetContainer container, IEnumerable <Object> assets, string path)
 {
     using (FileStream fileStream = File.Open(path, FileMode.Create, FileAccess.Write))
     {
         using (StreamWriter streamWriter = new StreamWriter(fileStream))
         {
             YAMLWriter writer = new YAMLWriter();
             foreach (Object asset in assets)
             {
                 container.File = asset.File;
                 YAMLDocument doc = asset.ExportYAMLDocument(container);
                 writer.AddDocument(doc);
             }
             writer.Write(streamWriter);
         }
     }
 }
Exemplo n.º 13
0
Arquivo: tap.cs Projeto: am11/TAP.Net
        void WriteIsVal(bool leaf, OrderedDictionary dic, string label, string key, List <PathEntry> path, int side)
        {
            var val = dic[key];

            if (leaf)
            {
                Tw.Write("{0}: '{1}'", label, SafeToString(val));
            }
            else
            {
                Tw.WriteLine("  {0}:", label);
                var yw = new YAMLWriter(Tw, 4, TAP.HorizontalThreshold, BBD);
                yw.Annotate = (i, n) => {
                    return(GetAnnotation(i, n, path, side, 0));
                };
                yw.Write(val);
            }
        }
Exemplo n.º 14
0
        protected void ExportMeta(IAssetsExporter exporter, IExportCollection collection, string filePath)
        {
            Meta   meta     = new Meta(collection);
            string metaPath = $"{filePath}.meta";

            using (FileStream fileStream = File.Open(metaPath, FileMode.Create, FileAccess.Write))
            {
                using (StreamWriter streamWriter = new StreamWriter(fileStream))
                {
                    YAMLWriter   writer = new YAMLWriter();
                    YAMLDocument doc    = meta.ExportYAMLDocument(exporter);
                    writer.IsWriteDefaultTag = false;
                    writer.IsWriteVersion    = false;
                    writer.AddDocument(doc);
                    writer.Write(streamWriter);
                }
            }
        }
Exemplo n.º 15
0
Arquivo: tap.cs Projeto: am11/TAP.Net
        public override void WriteComment(int nr, OrderedDictionary dic, List <PathEntry> path, string name)
        {
            if (path != null)
            {
                path.Insert(0, new PathEntry(-1));
            }
            var yw      = new YAMLWriter(Tw, 2, TAP.HorizontalThreshold, BBD);
            int rootidx = -1;
            int side    = 0;

            yw.Annotate = (i, n) => {
                int depth = n.Depth;
                if (depth == 1)
                {
                    var k = n.Key as string;
                    if (k != null)
                    {
                        if (k == "actual")
                        {
                            side    = 0;
                            rootidx = i;
                        }
                        else if (k == "expected")
                        {
                            side    = 1;
                            rootidx = i;
                        }
                    }
                    else
                    {
                        rootidx = -1;
                    }
                }
                if (rootidx != -1)
                {
                    return(GetAnnotation(i - rootidx, n, path, side, 1));
                }
                return(null);
            };
            yw.Write(dic);
        }