WriteToFile() public method

public WriteToFile ( string path ) : void
path string
return void
Ejemplo n.º 1
0
        public override void Write()
        {
            Directory.CreateDirectory(m_Path);

            var doc = new JsonDocument();

            var info = WriteInfoToJson(doc);

            WriteODRTagsToJson(info);

            var data = doc.root.CreateArray("data");

            foreach (DataSetVariant item in m_Variants)
            {
                var filename = Path.GetFileName(item.path);
                File.Copy(item.path, Path.Combine(m_Path, filename));

                var docItem = data.AddDict();
                docItem.SetString("filename", filename);
                WriteRequirementsToJson(docItem, item.requirement);
                if (item.id != null)
                {
                    docItem.SetString("universal-type-identifier", item.id);
                }
            }
            doc.WriteToFile(Path.Combine(m_Path, "Contents.json"));
        }
Ejemplo n.º 2
0
        public override void Write(List <string> warnings)
        {
            Directory.CreateDirectory(this.m_Path);
            JsonDocument doc = new JsonDocument();

            this.WriteODRTagsToJson(this.WriteInfoToJson(doc));
            JsonElementArray array             = doc.root.CreateArray("images");
            HashSet <string> existingFilenames = new HashSet <string>();

            foreach (AssetImageSet.ImageSetVariant imageSetVariant in this.m_Variants)
            {
                string          val             = this.CopyFileToSet(imageSetVariant.path, existingFilenames, warnings);
                JsonElementDict jsonElementDict = array.AddDict();
                jsonElementDict.SetString("filename", val);
                this.WriteRequirementsToJson(jsonElementDict, imageSetVariant.requirement);
                if (imageSetVariant.alignment != null)
                {
                    this.WriteAlignmentToJson(jsonElementDict, imageSetVariant.alignment);
                }
                if (imageSetVariant.resizing != null)
                {
                    this.WriteResizingToJson(jsonElementDict, imageSetVariant.resizing);
                }
            }
            doc.WriteToFile(Path.Combine(this.m_Path, "Contents.json"));
        }
Ejemplo n.º 3
0
        public override void Write(List <string> warnings)
        {
            Directory.CreateDirectory(base.m_Path);
            JsonDocument    doc  = new JsonDocument();
            JsonElementDict info = base.WriteInfoToJson(doc);

            base.WriteODRTagsToJson(info);
            JsonElementArray array = doc.root.CreateArray("data");

            foreach (DataSetVariant variant in base.m_Variants)
            {
                string fileName = Path.GetFileName(variant.path);
                if (!File.Exists(variant.path))
                {
                    if (warnings != null)
                    {
                        warnings.Add("File not found: " + variant.path);
                    }
                }
                else
                {
                    File.Copy(variant.path, Path.Combine(base.m_Path, fileName));
                }
                JsonElementDict item = array.AddDict();
                item.SetString("filename", fileName);
                base.WriteRequirementsToJson(item, variant.requirement);
                if (variant.id != null)
                {
                    item.SetString("universal-type-identifier", variant.id);
                }
            }
            doc.WriteToFile(Path.Combine(base.m_Path, "Contents.json"));
        }
Ejemplo n.º 4
0
        public override void Write()
        {
            Directory.CreateDirectory(m_Path);
            var doc  = new JsonDocument();
            var info = WriteInfoToJson(doc);

            WriteODRTagsToJson(info);

            var images = doc.root.CreateArray("images");

            foreach (ImageSetVariant item in m_Variants)
            {
                var filename = Path.GetFileName(item.path);
                File.Copy(item.path, Path.Combine(m_Path, filename));

                var docItem = images.AddDict();
                docItem.SetString("filename", filename);
                WriteRequirementsToJson(docItem, item.requirement);
                if (item.alignment != null)
                {
                    WriteAlignmentToJson(docItem, item.alignment);
                }
                if (item.resizing != null)
                {
                    WriteResizingToJson(docItem, item.resizing);
                }
            }
            doc.WriteToFile(Path.Combine(m_Path, "Contents.json"));
        }
Ejemplo n.º 5
0
 public override void Write(List<string> warnings)
 {
     Directory.CreateDirectory(base.m_Path);
     JsonDocument doc = new JsonDocument();
     JsonElementDict info = base.WriteInfoToJson(doc);
     base.WriteODRTagsToJson(info);
     JsonElementArray array = doc.root.CreateArray("data");
     foreach (DataSetVariant variant in base.m_Variants)
     {
         string fileName = Path.GetFileName(variant.path);
         if (!File.Exists(variant.path))
         {
             if (warnings != null)
             {
                 warnings.Add("File not found: " + variant.path);
             }
         }
         else
         {
             File.Copy(variant.path, Path.Combine(base.m_Path, fileName));
         }
         JsonElementDict item = array.AddDict();
         item.SetString("filename", fileName);
         base.WriteRequirementsToJson(item, variant.requirement);
         if (variant.id != null)
         {
             item.SetString("universal-type-identifier", variant.id);
         }
     }
     doc.WriteToFile(Path.Combine(base.m_Path, "Contents.json"));
 }
Ejemplo n.º 6
0
 private void WriteJson()
 {
     if (this.providesNamespace)
     {
         JsonDocument doc = new JsonDocument();
         base.WriteInfoToJson(doc);
         doc.root.CreateDict("properties").SetBoolean("provides-namespace", this.providesNamespace);
         doc.WriteToFile(Path.Combine(base.m_Path, "Contents.json"));
     }
 }
Ejemplo n.º 7
0
 public override void Write(List<string> warnings)
 {
     Directory.CreateDirectory(base.m_Path);
     JsonDocument doc = new JsonDocument();
     base.WriteInfoToJson(doc);
     JsonElementArray array = doc.root.CreateArray("layers");
     foreach (AssetImageStackLayer layer in this.m_Layers)
     {
         layer.Write(warnings);
         array.AddDict().SetString("filename", Path.GetFileName(layer.path));
     }
     doc.WriteToFile(Path.Combine(base.m_Path, "Contents.json"));
 }
Ejemplo n.º 8
0
        void WriteJson()
        {
            if (!providesNamespace)
            {
                return; // json is optional when namespace is not provided
            }
            var doc = new JsonDocument();

            WriteInfoToJson(doc);

            var props = doc.root.CreateDict("properties");

            props.SetBoolean("provides-namespace", providesNamespace);
            doc.WriteToFile(Path.Combine(m_Path, "Contents.json"));
        }
Ejemplo n.º 9
0
        public override void Write(List <string> warnings)
        {
            Directory.CreateDirectory(base.m_Path);
            JsonDocument doc = new JsonDocument();

            base.WriteInfoToJson(doc);
            JsonElementArray array = doc.root.CreateArray("layers");

            foreach (AssetImageStackLayer layer in this.m_Layers)
            {
                layer.Write(warnings);
                array.AddDict().SetString("filename", Path.GetFileName(layer.path));
            }
            doc.WriteToFile(Path.Combine(base.m_Path, "Contents.json"));
        }
 public override void Write(List<string> warnings)
 {
     Directory.CreateDirectory(base.m_Path);
     JsonDocument doc = new JsonDocument();
     base.WriteInfoToJson(doc);
     JsonElementArray array = doc.root.CreateArray("assets");
     foreach (AssetBrandAssetItem item in this.m_Items)
     {
         JsonElementDict dict = array.AddDict();
         dict.SetString("size", string.Format("{0}x{1}", item.width, item.height));
         dict.SetString("idiom", item.idiom);
         dict.SetString("role", item.role);
         dict.SetString("filename", Path.GetFileName(item.item.path));
         item.item.Write(warnings);
     }
     doc.WriteToFile(Path.Combine(base.m_Path, "Contents.json"));
 }
 public override void Write(List<string> warnings)
 {
     Directory.CreateDirectory(base.m_Path);
     JsonDocument doc = new JsonDocument();
     base.WriteInfoToJson(doc);
     if (this.m_ReferencedName != null)
     {
         JsonElementDict dict2 = doc.root.CreateDict("properties").CreateDict("content-reference");
         dict2.SetString("type", "image-set");
         dict2.SetString("name", this.m_ReferencedName);
         dict2.SetString("matching-style", "fully-qualified-name");
     }
     if (this.m_Imageset != null)
     {
         this.m_Imageset.Write(warnings);
     }
     doc.WriteToFile(Path.Combine(base.m_Path, "Contents.json"));
 }
Ejemplo n.º 12
0
        public override void Write()
        {
            Directory.CreateDirectory(m_Path);
            var doc = new JsonDocument();

            WriteInfoToJson(doc);

            var docLayers = doc.root.CreateArray("layers");

            foreach (var layer in m_Layers)
            {
                layer.Write();

                var docLayer = docLayers.AddDict();
                docLayer.SetString("filename", Path.GetFileName(layer.path));
            }
            doc.WriteToFile(Path.Combine(m_Path, "Contents.json"));
        }
        public override void Write(List <string> warnings)
        {
            Directory.CreateDirectory(base.m_Path);
            JsonDocument doc = new JsonDocument();

            base.WriteInfoToJson(doc);
            JsonElementArray array = doc.root.CreateArray("assets");

            foreach (AssetBrandAssetItem item in this.m_Items)
            {
                JsonElementDict dict = array.AddDict();
                dict.SetString("size", $"{item.width}x{item.height}");
                dict.SetString("idiom", item.idiom);
                dict.SetString("role", item.role);
                dict.SetString("filename", Path.GetFileName(item.item.path));
                item.item.Write(warnings);
            }
            doc.WriteToFile(Path.Combine(base.m_Path, "Contents.json"));
        }
Ejemplo n.º 14
0
        public override void Write(List <string> warnings)
        {
            Directory.CreateDirectory(this.m_Path);
            JsonDocument doc = new JsonDocument();

            this.WriteInfoToJson(doc);
            JsonElementArray array = doc.root.CreateArray("assets");

            foreach (AssetBrandAssetGroup.AssetBrandAssetItem assetBrandAssetItem in this.m_Items)
            {
                JsonElementDict jsonElementDict = array.AddDict();
                jsonElementDict.SetString("size", string.Format("{0}x{1}", (object)assetBrandAssetItem.width, (object)assetBrandAssetItem.height));
                jsonElementDict.SetString("idiom", assetBrandAssetItem.idiom);
                jsonElementDict.SetString("role", assetBrandAssetItem.role);
                jsonElementDict.SetString("filename", Path.GetFileName(assetBrandAssetItem.item.path));
                assetBrandAssetItem.item.Write(warnings);
            }
            doc.WriteToFile(Path.Combine(this.m_Path, "Contents.json"));
        }
Ejemplo n.º 15
0
        public override void Write(List <string> warnings)
        {
            Directory.CreateDirectory(this.m_Path);
            JsonDocument doc = new JsonDocument();

            this.WriteInfoToJson(doc);
            if (this.m_ReferencedName != null)
            {
                JsonElementDict dict = doc.root.CreateDict("properties").CreateDict("content-reference");
                dict.SetString("type", "image-set");
                dict.SetString("name", this.m_ReferencedName);
                dict.SetString("matching-style", "fully-qualified-name");
            }
            if (this.m_Imageset != null)
            {
                this.m_Imageset.Write(warnings);
            }
            doc.WriteToFile(Path.Combine(this.m_Path, "Contents.json"));
        }
Ejemplo n.º 16
0
        public override void Write(List <string> warnings)
        {
            Directory.CreateDirectory(m_Path);
            var doc = new JsonDocument();

            WriteInfoToJson(doc);

            var docAssets = doc.root.CreateArray("assets");

            foreach (var item in m_Items)
            {
                var docAsset = docAssets.AddDict();
                docAsset.SetString("size", String.Format("{0}x{1}", item.width, item.height));
                docAsset.SetString("idiom", item.idiom);
                docAsset.SetString("role", item.role);
                docAsset.SetString("filename", Path.GetFileName(item.item.path));

                item.item.Write(warnings);
            }
            doc.WriteToFile(Path.Combine(m_Path, "Contents.json"));
        }
Ejemplo n.º 17
0
        public override void Write(List <string> warnings)
        {
            Directory.CreateDirectory(this.m_Path);
            JsonDocument doc = new JsonDocument();

            this.WriteODRTagsToJson(this.WriteInfoToJson(doc));
            JsonElementArray array             = doc.root.CreateArray("data");
            HashSet <string> existingFilenames = new HashSet <string>();

            foreach (AssetDataSet.DataSetVariant dataSetVariant in this.m_Variants)
            {
                string          val             = this.CopyFileToSet(dataSetVariant.path, existingFilenames, warnings);
                JsonElementDict jsonElementDict = array.AddDict();
                jsonElementDict.SetString("filename", val);
                this.WriteRequirementsToJson(jsonElementDict, dataSetVariant.requirement);
                if (dataSetVariant.id != null)
                {
                    jsonElementDict.SetString("universal-type-identifier", dataSetVariant.id);
                }
            }
            doc.WriteToFile(Path.Combine(this.m_Path, "Contents.json"));
        }
Ejemplo n.º 18
0
        public override void Write()
        {
            Directory.CreateDirectory(m_Path);
            var doc = new JsonDocument();

            WriteInfoToJson(doc);

            if (m_ReferencedName != null)
            {
                var props     = doc.root.CreateDict("properties");
                var reference = props.CreateDict("content-reference");
                reference.SetString("type", "image-set");
                reference.SetString("name", m_ReferencedName);
                reference.SetString("matching-style", "fully-qualified-name");
            }
            if (m_Imageset != null)
            {
                m_Imageset.Write();
            }

            doc.WriteToFile(Path.Combine(m_Path, "Contents.json"));
        }