private static IEnumerable <string> TryParseFromOneItem(IEnumerable <string> source)
 {
     // The WinRT API does not support some of the multiple tags for MP3 files.
     if (source.Count() == 1)
     {
         return(StringListConverter.FromString(source.First()));
     }
     return(source.ToArray());
 }
        public void ConvertBackTest()
        {
            var nl = Environment.NewLine;
            var ls = CultureInfo.CurrentCulture.TextInfo.ListSeparator;

            Assert.IsTrue((new string[0]).SequenceEqual(StringListConverter.FromString("")));

            Assert.IsTrue((new[] { "Pop" }).SequenceEqual(StringListConverter.FromString("Pop")));
            Assert.IsTrue((new[] { "Pop", "Rock" }).SequenceEqual(StringListConverter.FromString("Pop" + nl + "Rock", nl)));
            Assert.IsTrue((new[] { "Pop", "Rock" }).SequenceEqual(StringListConverter.FromString(" Pop" + nl + " Rock", nl)));
            Assert.IsTrue((new[] { "Pop", "Rock" }).SequenceEqual(StringListConverter.FromString("Pop " + nl + "Rock ", nl)));

            Assert.IsTrue((new[] { "Pop", "Rock" }).SequenceEqual(StringListConverter.FromString("Pop" + ls + "Rock")));
            Assert.IsTrue((new[] { "Pop", "Rock" }).SequenceEqual(StringListConverter.FromString(" Pop" + ls + " Rock")));
            Assert.IsTrue((new[] { "Pop", "Rock" }).SequenceEqual(StringListConverter.FromString("Pop " + ls + "Rock ")));

            Assert.IsTrue((new[] { "Pop" }).SequenceEqual(StringListConverter.FromString("Pop" + ls)));
            Assert.IsTrue((new[] { "Pop" }).SequenceEqual(StringListConverter.FromString("Pop" + ls + " ")));
        }
Esempio n. 3
0
        public void ConvertBackTest()
        {
            var nl = Environment.NewLine;
            var ls = CultureInfo.CurrentCulture.TextInfo.ListSeparator;

            AssertHelper.SequenceEqual(Array.Empty <string>(), StringListConverter.FromString(""));

            AssertHelper.SequenceEqual(new[] { "Pop" }, StringListConverter.FromString("Pop"));
            AssertHelper.SequenceEqual(new[] { "Pop", "Rock" }, StringListConverter.FromString("Pop" + nl + "Rock", nl));
            AssertHelper.SequenceEqual(new[] { "Pop", "Rock" }, StringListConverter.FromString(" Pop" + nl + " Rock", nl));
            AssertHelper.SequenceEqual(new[] { "Pop", "Rock" }, StringListConverter.FromString("Pop " + nl + "Rock ", nl));

            AssertHelper.SequenceEqual(new[] { "Pop", "Rock" }, StringListConverter.FromString("Pop" + ls + "Rock"));
            AssertHelper.SequenceEqual(new[] { "Pop", "Rock" }, StringListConverter.FromString(" Pop" + ls + " Rock"));
            AssertHelper.SequenceEqual(new[] { "Pop", "Rock" }, StringListConverter.FromString("Pop " + ls + "Rock "));

            AssertHelper.SequenceEqual(new[] { "Pop" }, StringListConverter.FromString("Pop" + ls));
            AssertHelper.SequenceEqual(new[] { "Pop" }, StringListConverter.FromString("Pop" + ls + " "));
        }
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string text = (string)value;

            return(StringListConverter.FromString(text, GetSeparator(parameter)));
        }
 public object ConvertBack(object _value, Type _targetType, object _parameter, CultureInfo _culture)
 => StringListConverter.FromString((string)_value, GetSeparator(_parameter));