Exemplo n.º 1
0
        public void TestSplitCommandLine3()
        {
            var argList = new List <string>(ImplUtil.SplitCommandLine("1 2\\"));

            foreach (var arg in argList)
            {
                Console.WriteLine(arg);
            }

            Assert.IsTrue(argList[0] == "1");
            Assert.IsTrue(argList[1] == "2");
        }
Exemplo n.º 2
0
        public void TestSplitCommandLine4()
        {
            try
            {
                new List <string>(ImplUtil.SplitCommandLine("\"1 2"));
            }
            catch (InvalidOperationException)
            {
                Assert.Pass();
                return;
            }

            Assert.True(false);
        }
Exemplo n.º 3
0
        public void TestSplitCommandLine1()
        {
            var argList = new List <string>(ImplUtil.SplitCommandLine("1 2 'a b \\\\ \\ \\\" \\1' \"1 \\\" \\\\ \\ \\1\" '1 2'\" 3\""));

            foreach (var arg in argList)
            {
                Console.WriteLine(arg);
            }

            Assert.IsTrue(argList[0] == "1");
            Assert.IsTrue(argList[1] == "2");
            Assert.IsTrue(argList[2] == "a b \\ \\ \\\" \\1");
            Assert.IsTrue(argList[3] == "1 \" \\ \\ \\1");
            Assert.IsTrue(argList[4] == "1 2 3");
        }
Exemplo n.º 4
0
        public void TestSerializeComplexList()
        {
            var list = new List <TestingClass4>
            {
                new() { FieldA = 1, FieldB = new TestingClass1()
                        {
                            FieldA = 11, FieldB = 12
                        } },
                new() { FieldA = 2, FieldB = new TestingClass1()
                        {
                            FieldA = 21, FieldB = 22
                        } },
            };

            CommandLineSerializer serializer = new();
            var argList     = serializer.SerializeObject(list);
            var commandLine = ImplUtil.MergeCommandLine(argList);

            Console.WriteLine(commandLine);

            Assert.True(commandLine == "-- \"--FieldA 1 --FieldB \\\"--FieldA 11 --FieldB 12\\\"\" \"--FieldA 2 --FieldB \\\"--FieldA 21 --FieldB 22\\\"\"");
        }
Exemplo n.º 5
0
        private T _Deserialize <T>(string commandLine, out LinkedList <string> remainArgs)
        {
            CommandLineSerializer serializer = new();

            return((T)serializer.DeserializeObject(typeof(T), ImplUtil.SplitCommandLine(commandLine), out remainArgs) !);
        }