예제 #1
0
        /// <inheritdoc />
        public void Import(List <Dictionary <string, string> > data)
        {
            var idList    = new List <string>();
            var groupList = new List <string>();
            var mapGroups = new Dictionary <string, List <string> >();
            var mapIds    = new Dictionary <string, List <string> >();

            foreach (var entry in data)
            {
                var groups = CsvParser.ArrayParse <string>(entry[_GROUPS_TAG]);
                var id     = GetCleanName(entry[_ID_TAG]);

                idList.Add(id);
                mapGroups.Add(id, groups);

                foreach (var group in groups)
                {
                    var groupName = GetCleanName(group);
                    if (!groupList.Contains(groupName))
                    {
                        groupList.Add(groupName);
                        mapIds.Add(groupName, new List <string>());
                    }

                    mapIds[groupName].Add(id);
                }
            }

            var script = GenerateScript(idList, groupList, mapGroups, mapIds);

            SaveScript(script);
            AssetDatabase.Refresh();
        }
예제 #2
0
        public void ArrayParsePair_Successfully()
        {
            var result    = CsvParser.ArrayParse <KeyValuePair <int, int> >("1:2,(3 < 4),[5 > 6],{7 = 8}");
            var pairArray = new[]
            {
                new KeyValuePair <int, int>(1, 2),
                new KeyValuePair <int, int>(3, 4),
                new KeyValuePair <int, int>(5, 6),
                new KeyValuePair <int, int>(7, 8),
            };

            Assert.AreEqual(pairArray, result);
        }
예제 #3
0
 public void ArrayParsePair_ElementOddAmount_ThrowsException()
 {
     Assert.Throws <IndexOutOfRangeException>(() => CsvParser.ArrayParse <KeyValuePair <int, int> >("1:2,(3 < 4),5"));
 }
예제 #4
0
        public void ArrayParse_Successfully()
        {
            var result = CsvParser.ArrayParse <int>("1,[2],{3,4},(5),6");

            Assert.AreEqual(new [] { 1, 2, 3, 4, 5, 6 }, result);
        }