Esempio n. 1
0
        public void ConvertToFlattenedFileData()
        {
            Dictionary <string, FileOutput> flattenedFiles = new Dictionary <string, FileOutput>();

            foreach (FileOutput txtResource in this.TextResources)
            {
                flattenedFiles["res/" + txtResource.CanonicalFileName] = txtResource;
            }
            foreach (FileOutput sndResource in this.AudioResources)
            {
                flattenedFiles["res/" + sndResource.CanonicalFileName] = sndResource;
            }
            foreach (FileOutput fontResource in this.FontResources)
            {
                flattenedFiles["res/" + fontResource.CanonicalFileName] = fontResource;
            }
            foreach (FileOutput binResource in this.BinaryResources)
            {
                flattenedFiles["res/" + binResource.CanonicalFileName] = binResource;
            }
            foreach (string name in this.ImageResourceFiles.Keys)
            {
                FileOutput imgResource = this.ImageResourceFiles[name];
                flattenedFiles["res/" + name] = imgResource;
            }

            string[]     keys  = flattenedFiles.Keys.OrderBy(k => k).ToArray();
            FileOutput[] files = keys.Select(k => flattenedFiles[k]).ToArray();
            this.FlatFileNames = keys;
            this.FlatFiles     = files;

            this.IsFlattenedMode = true;

            this.TextResources      = null;
            this.AudioResources     = null;
            this.FontResources      = null;
            this.BinaryResources    = null;
            this.ImageResourceFiles = null;
        }
Esempio n. 2
0
        private void ExportFile(string path, FileOutput file)
        {
            string absolutePath = FileUtil.JoinPath(this.targetDirectory, path);

            FileUtil.EnsureParentFolderExists(absolutePath);

            switch (file.Type)
            {
            case FileOutputType.Binary:
                this.ExportBinaryFile(absolutePath, file.BinaryContent);
                break;

            case FileOutputType.Copy:
                this.ExportCopiedFile(absolutePath, file.AbsoluteInputPath, false);
                break;

            case FileOutputType.Image:
                if (file.BinaryContent != null)
                {
                    this.ExportBinaryFile(absolutePath, file.BinaryContent);
                }
                else if (file.BinaryContentB64 != null)
                {
                    this.ExportBinaryFile(absolutePath, file.GetFinalBinaryContent());
                }
                else
                {
                    this.ExportImageFile(absolutePath, file.Bitmap);
                }
                break;

            case FileOutputType.Text:
                this.ExportTextFile(absolutePath, file.TextContent, file.TrimBomIfPresent);
                break;

            default:
                throw new NotImplementedException();
            }
        }