GetTags() public method

public GetTags ( ) : List
return List
Exemplo n.º 1
0
        private void ChangeTags()
        {
            var fileName = Path.GetFileNameWithoutExtension(File.FullName);

            if (!_maskParser.ValidateFileName(fileName))
            {
                throw new InvalidDataException("Mask doesn't match the file name.");
            }

            var tagPatternsInMask = _maskParser.GetTags();
            var splitsInMask      = _maskParser.GetSplits();

            fileName = fileName.Remove(0, splitsInMask[0].Length); // Remove first split
            for (var i = 0; i < splitsInMask.Count - 1; i++)
            {
                var indexOfSplit = splitsInMask[i + 1] != String.Empty
                    ? fileName.IndexOf(splitsInMask[i + 1], StringComparison.Ordinal)
                    : fileName.Length;
                var tagValueInFileName = fileName.Substring(0, indexOfSplit);

                ChangeTag(tagPatternsInMask[i], tagValueInFileName);

                fileName = fileName.Remove(0, indexOfSplit + splitsInMask[i + 1].Length);
            }
        }
Exemplo n.º 2
0
        public void CleanUp()
        {
            var parser = new MaskParser(_expectedMask);

            Assert.AreEqual(_expectedMask, parser.GetMaskFromTagsAndSplits());
            CollectionAssert.AreEqual(_expectedTags, parser.GetTags());
            CollectionAssert.AreEqual(_expectedSplits, parser.GetSplits());
        }
Exemplo n.º 3
0
        private string Analyse(IMp3File mp3File)
        {
            var fileName = Path.GetFileNameWithoutExtension(mp3File.FullName);

            if (!_maskParser.ValidateFileName(fileName))
            {
                throw new InvalidDataException("Mask doesn't match the file name.");
            }

            var resultMessage = new StringBuilder();

            var tagPatternsInMask = _maskParser.GetTags();
            var splitsInMask      = _maskParser.GetSplits();

            fileName = fileName.Remove(0, splitsInMask[0].Length);
            for (var i = 0; i < splitsInMask.Count - 1; i++)
            {
                var indexOfSplit = splitsInMask[i + 1] != String.Empty
                    ? fileName.IndexOf(splitsInMask[i + 1], StringComparison.Ordinal)
                    : fileName.Length;

                var tagValueInFileName = fileName.Substring(0, indexOfSplit);

                var tagValueInTags = GetTagValueByTagPattern(mp3File, tagPatternsInMask[i]);

                if (tagValueInFileName != tagValueInTags)
                {
                    resultMessage.Append(_maskParser.GetTags()[i] + " in file name: " + tagValueInFileName + "; ");
                    resultMessage.Append(_maskParser.GetTags()[i] + " in tags: " + tagValueInTags + "\n");
                }

                fileName = fileName.Remove(0, indexOfSplit + splitsInMask[i + 1].Length);
            }

            // Add file name to message
            if (resultMessage.Length > 0)
            {
                resultMessage.Insert(0, "File: " + mp3File.FullName + "\n");
                resultMessage.Append("\n");
            }

            return(resultMessage.ToString());
        }