Exemplo n.º 1
0
        public void EmptySection()
        {
            XapFile file = new XapFile();

            file.Open(XactEmptySection);

            SectionElement root = file["Section"] as SectionElement;

            Assert.NotNull(root);
        }
Exemplo n.º 2
0
        public void EmptySectionWithEmptyChild()
        {
            XapFile file = new XapFile();

            file.Open(XactEmptySectionWithEmptyChild);

            SectionElement root  = file["Section"] as SectionElement;
            SectionElement child = root.Value["SubSection"] as SectionElement;

            Assert.NotNull(child);
        }
Exemplo n.º 3
0
        public void FileHeader()
        {
            XapFile file = new XapFile();

            file.Open(XactFileHeader);

            Assert.Equal("XACT2", file.Signature);
            Assert.Equal("16", file.Version);
            Assert.Equal("43", file.ContentVersion);
            Assert.Equal("August 2007", file.Release);
        }
Exemplo n.º 4
0
        public void SaveEmptySectionFile()
        {
            XapFile file = new XapFile();

            file.Open(XactEmptySection);

            MemoryStream stream = new MemoryStream();

            file.Save(stream);
            byte[] buffer  = stream.ToArray();
            char[] written = Encoding.ASCII.GetChars(buffer);
            Assert.Equal(XactEmptySection.ToCharArray(), written);
        }
Exemplo n.º 5
0
        public void SaveComplexSectionFile()
        {
            XapFile file = new XapFile();

            file.Open(XactSectionWithScalarsAndSubSections);

            MemoryStream stream = new MemoryStream();

            file.Save(stream);
            byte[] buffer  = stream.ToArray();
            char[] written = Encoding.ASCII.GetChars(buffer);
            Assert.Equal(XactSectionWithScalarsAndSubSections.ToCharArray(), written);
        }
Exemplo n.º 6
0
        public void SectionWithScalarsAndSubSections()
        {
            XapFile file = new XapFile();

            file.Open(XactSectionWithScalarsAndSubSections);

            SectionElement root = file["Section"] as SectionElement;

            Assert.NotNull(root);
            Assert.Equal(3, root.Value.ElementCount);

            Assert.IsType(typeof(ScalarElement), root.Value["Foo"]);
            Assert.IsType(typeof(ScalarElement), root.Value["Baz"]);
            Assert.IsType(typeof(SectionElement), root.Value["SubSection"]);
        }
Exemplo n.º 7
0
        static void ConvertProject(String input, String output)
        {
            XapFile xapFile = new XapFile();
            String  content = File.ReadAllText(input);

            xapFile.Open(content);
            xapFile.ContentVersion = "44";
            xapFile.Release        = "March 2008";

            ElementCollection presets = xapFile.GetElements("Compression Preset");

            if (presets.Count > 0)
            {
                /*
                 * Change
                 * Compression Preset
                 * {
                 *      Name = Compression Preset;
                 *      Xbox Format Tag = 357;
                 *      Target Sample Rate = 48000;
                 *      Quality = 65;
                 *      Find Best Quality = 0;
                 *      High Freq Cut = 0;
                 *      Loop = 0;
                 *      PC Format Tag = 2;
                 *      Samples Per Block = 128;
                 * }
                 * to
                 * Compression Preset
                 * {
                 *      Name = Compression Preset;
                 *      Xbox Format Tag = 357;
                 *      Target Sample Rate = 48000;
                 *      XMA Quality = 65;
                 *      Find Best Quality = 0;
                 *      High Freq Cut = 0;
                 *      Loop = 0;
                 *      PC Format Tag = 353;
                 *      WMA Quality = 65;
                 * }
                 */

                // Add WMA format to all compression presets that define XMA compression,
                // using the same quality setting
                for (int c = 0; c < presets.Count; c++)
                {
                    SectionElement preset             = presets[c] as SectionElement;
                    ScalarElement  xboxFormatTag      = preset.Value["Xbox Format Tag"] as ScalarElement;
                    int            xboxFormatTagValue = 0;
                    if (Int32.TryParse(xboxFormatTag.Value, out xboxFormatTagValue) == true &&
                        (CompressionFormat)xboxFormatTagValue == CompressionFormat.XMA)
                    {
                        preset.Value["PC Format Tag"].Value = String.Format("{0}", (int)CompressionFormat.WMA);
                        ScalarElement xmaQuality = preset.Value["Quality"] as ScalarElement;
                        preset.Value["Samples Per Block"] = null;
                        preset.Value.Add(new ScalarElement("WMA Quality", xmaQuality.Value));
                        //REVIEW: Check Wave size: file too small to encode, must have at least 352256 bytes of data
                        //REVIEW: Rename "Quality" element to "XMA Quality"?
                    }
                }
            }

            using (FileStream outputStream = new FileStream(output, FileMode.Create))
            {
                xapFile.Save(outputStream);
            }
        }