GetTagsValue() public method

public GetTagsValue ( string fileName ) : string>.Dictionary
fileName string
return string>.Dictionary
Ejemplo n.º 1
0
 public bool RetagFile(string pattern)
 {
     var parser = new TagParser(pattern);
     var parsedTags = parser.GetTagsValue(_fileHandler.FileName);
     if (parsedTags == null)
         return false;
     _fileHandler.SetTags(parsedTags);
     return true;
 }
Ejemplo n.º 2
0
        public void FakeEndOfTagValueParsing()
        {
            var artist = "arti -st";
            var title = "title";
            var expect = artist + " - " + title;

            var parser = new TagParser("<ar> - <ti>");
            var frames = parser.GetTagsValue(expect);
            Assert.AreEqual(artist, frames[FrameType.Artist]);
            Assert.AreEqual(title, frames[FrameType.Title]);
        }
Ejemplo n.º 3
0
        public bool Synchronize(string pattern)
        {
            var parser = new TagParser(pattern);
            var pathTagsValue = parser.GetTagsValue(_fileHandler.FileName);

            var requringTags = new SortedSet<FrameType>(parser.GetTags());
            var fileTags = new SortedSet<FrameType>(_fileHandler.GetTags().Keys);

            var pathTagsIsBad = pathTagsValue == null;
            var fileTagsIsBad = !requringTags.IsSubsetOf(fileTags);

            if (pathTagsIsBad && !fileTagsIsBad)
                return RenameFile(pattern);

            if (!pathTagsIsBad && fileTagsIsBad)
                return RetagFile(pattern);

            return false;
        }
Ejemplo n.º 4
0
        public Dictionary<FrameType, TagDifference> Difference(string pattern)
        {
            var parser = new TagParser(pattern);
            var pathTags = parser.GetTagsValue(_fileHandler.FileName);
            if (pathTags == null)
                return null;

            var fileTags = _fileHandler.GetTags(GetTagsOption.DontRemoveEmptyTags);

            var tagDifference = new Dictionary<FrameType,TagDifference>();

            foreach (var pathTag in pathTags)
            {
                if (pathTag.Value != fileTags[pathTag.Key])
                    tagDifference.Add(pathTag.Key, new TagDifference(fileTags[pathTag.Key], pathTag.Value));
            }

            return tagDifference.Count != 0 ? tagDifference : null;
        }
Ejemplo n.º 5
0
        public void TwoTagValueParsing()
        {
            var artist = "artist";
            var title = "title";

            // TODO :: this is not 'expect' - 'input'
            var expect = artist + " - " + title;

            var parser = new TagParser("<ar> - <ti>");
            var frames = parser.GetTagsValue(expect);

            Assert.AreEqual(artist, frames[FrameType.Artist]);
            Assert.AreEqual(title, frames[FrameType.Title]);
        }
Ejemplo n.º 6
0
        public void OneTagValueParsing()
        {
            var expect = "artist";

            var parser = new TagParser("<ar>");
            var frames = parser.GetTagsValue(expect);

            Assert.AreEqual(1, frames.Count);
            Assert.AreEqual(expect, frames[FrameType.Artist]);
        }
Ejemplo n.º 7
0
 public void NotExistingTagValueParsingException()
 {
     var parser = new TagParser("<a>");
     var frames = parser.GetTagsValue("msg");
 }
Ejemplo n.º 8
0
 public void NotCorrectPatternValueParsing()
 {
     var parser = new TagParser("<ar><al>");
     Assert.AreEqual(null, parser.GetTagsValue("msg"));
 }
Ejemplo n.º 9
0
 public void NotCompleteTagValueParsing()
 {
     var parser = new TagParser("<ar");
     parser.GetTagsValue("msg");
 }