示例#1
0
        public static StringBuilder ReadBinaryAndConvertToHexArr(ConvertedFile file, BinCompression compression)
        {
            byte[] rawBuffer = File.ReadAllBytes(file.itemSourceFile.AbsoluteFilename);
            file.OriginalFileLength = rawBuffer.Length;
            switch (compression)
            {
            case BinCompression.Deflate:
            {
                byte[] compressedData = DeflateCompressionUtils.Compress(rawBuffer);
                file.CompressedFileLength = compressedData.Length;
#if DEBUG
                byte[] decompressedData = DeflateCompressionUtils.Decompress(compressedData);
                if (decompressedData.Length != rawBuffer.Length)
                {
                    throw new NotSupportedException();
                }
#endif

                return(ReadBinaryAndConvertToHexArr(compressedData));
            }

            default:

                return(ReadBinaryAndConvertToHexArr(rawBuffer));
            }
        }
示例#2
0
        public static void BuildResources(AtlasProject atlasProj)
        {
            //1. load resouce
            //2. convert buffer to C# code
            List <ConvertedFile> selectedItems = new List <ConvertedFile>();

            foreach (AtlasItemSourceFile f in atlasProj.Items)
            {
                if (f.IsConfig)
                {
                    continue;
                }
                //------
                //load and convert
                ConvertedFile convertedFile = new ConvertedFile();
                convertedFile.Compression    = BinCompression.Deflate;
                convertedFile.itemSourceFile = f;
                convertedFile.Data           = BinToHexUtils.ReadBinaryAndConvertToHexArr(convertedFile, convertedFile.Compression);


                string url2 = f.Link.Replace("\\", "_");
                url2 = url2.Replace("//", "_");
                url2 = url2.Replace(".", "_");
                convertedFile.Name = url2;//field name
                selectedItems.Add(convertedFile);
            }
            BuildCsSource(atlasProj, selectedItems);
        }