Ejemplo n.º 1
0
        protected string formatBeforeWriting(byte frameType, TagData tag, IDictionary <byte, string> map)
        {
            string value;
            string total;

            switch (frameType)
            {
            case TagData.TAG_FIELD_RATING: return(TrackUtils.EncodePopularity(map[frameType], ratingConvention).ToString());

            case TagData.TAG_FIELD_TRACK_NUMBER:
                value = map[TagData.TAG_FIELD_TRACK_NUMBER];
                map.TryGetValue(TagData.TAG_FIELD_TRACK_TOTAL, out total);
                return(TrackUtils.FormatWithLeadingZeroes(value, Settings.OverrideExistingLeadingZeroesFormat, tag.TrackDigitsForLeadingZeroes, Settings.UseLeadingZeroes, total));

            case TagData.TAG_FIELD_TRACK_TOTAL:
                value = map[TagData.TAG_FIELD_TRACK_TOTAL];
                total = value;
                return(TrackUtils.FormatWithLeadingZeroes(value, Settings.OverrideExistingLeadingZeroesFormat, tag.TrackDigitsForLeadingZeroes, Settings.UseLeadingZeroes, total));

            case TagData.TAG_FIELD_TRACK_NUMBER_TOTAL:
                value = map[TagData.TAG_FIELD_TRACK_NUMBER_TOTAL];
                total = value;
                return(TrackUtils.FormatWithLeadingZeroes(value, Settings.OverrideExistingLeadingZeroesFormat, tag.TrackDigitsForLeadingZeroes, Settings.UseLeadingZeroes, total));

            case TagData.TAG_FIELD_DISC_NUMBER:
                value = map[TagData.TAG_FIELD_DISC_NUMBER];
                map.TryGetValue(TagData.TAG_FIELD_DISC_TOTAL, out total);
                return(TrackUtils.FormatWithLeadingZeroes(value, Settings.OverrideExistingLeadingZeroesFormat, tag.DiscDigitsForLeadingZeroes, Settings.UseLeadingZeroes, total));

            case TagData.TAG_FIELD_DISC_TOTAL:
                value = map[TagData.TAG_FIELD_DISC_TOTAL];
                total = value;
                return(TrackUtils.FormatWithLeadingZeroes(value, Settings.OverrideExistingLeadingZeroesFormat, tag.DiscDigitsForLeadingZeroes, Settings.UseLeadingZeroes, total));

            case TagData.TAG_FIELD_DISC_NUMBER_TOTAL:
                value = map[TagData.TAG_FIELD_DISC_NUMBER_TOTAL];
                total = value;
                return(TrackUtils.FormatWithLeadingZeroes(value, Settings.OverrideExistingLeadingZeroesFormat, tag.DiscDigitsForLeadingZeroes, Settings.UseLeadingZeroes, total));

            default: return(map[frameType]);
            }
        }
Ejemplo n.º 2
0
        public void TrackUtils_ApplyLeadingZeroes()
        {
            // Use existing track format
            Assert.AreEqual("1", TrackUtils.FormatWithLeadingZeroes("1", false, 1, false, ""));
            Assert.AreEqual("1", TrackUtils.FormatWithLeadingZeroes("1", false, 1, false, "10"));
            Assert.AreEqual("1", TrackUtils.FormatWithLeadingZeroes("1", false, 1, true, "10"));
            Assert.AreEqual("01", TrackUtils.FormatWithLeadingZeroes("1", false, 2, true, "1"));
            Assert.AreEqual("01", TrackUtils.FormatWithLeadingZeroes("1", false, 2, false, "1"));
            Assert.AreEqual("01/01", TrackUtils.FormatWithLeadingZeroes("1/1", false, 2, false, "1"));
            Assert.AreEqual("01/01", TrackUtils.FormatWithLeadingZeroes("01/1", false, 2, false, "1"));

            // Override existing track format
            Assert.AreEqual("1", TrackUtils.FormatWithLeadingZeroes("1", true, 2, false, "10"));
            Assert.AreEqual("1", TrackUtils.FormatWithLeadingZeroes("1", true, 2, false, "1"));
            Assert.AreEqual("01", TrackUtils.FormatWithLeadingZeroes("1", true, 2, true, "1"));
            Assert.AreEqual("01", TrackUtils.FormatWithLeadingZeroes("1", true, 2, true, "10"));
            Assert.AreEqual("01", TrackUtils.FormatWithLeadingZeroes("1", true, 0, true, "1"));
            Assert.AreEqual("01/01", TrackUtils.FormatWithLeadingZeroes("1/1", true, 0, true, "1"));
            Assert.AreEqual("01/01", TrackUtils.FormatWithLeadingZeroes("1/01", true, 0, true, "1"));
            Assert.AreEqual("001", TrackUtils.FormatWithLeadingZeroes("1", true, 0, true, "100"));
        }