public void TestMoveProperty()
        {
            extractor.PropertySheetPath = "TestData\\test.props";

            int prev = extractor.PropertySheet.Properties.Count;

            extractor.Move("TheType", "foobar");
            int after = extractor.PropertySheet.Properties.Count;

            Assert.AreEqual(prev + 1, after);

            var prop = extractor.PropertySheet.GetProperty("TheType");

            Assert.AreEqual("foobar", prop.EvaluatedValue);

            Assert.AreEqual(5, extractor.AllFoundProperties.Count());
            var allprops = (from p in extractor.AllFoundProperties
                            let pl = p.Key
                                     orderby pl ascending
                                     select pl).ToList();

            Assert.AreEqual("AssemblyName", allprops[0]);
            Assert.AreEqual("Configuration", allprops[1]);
            Assert.AreEqual("OutputPath", allprops[2]);
            Assert.AreEqual("Platform", allprops[3]);
            Assert.AreEqual("UniqueforDebug", allprops[4]);

            extractor.Move("OutputPath", @"C:\builds\debug\");
            prop = extractor.PropertySheet.GetProperty("OutputPath");
            Assert.AreEqual(@"C:\builds\debug\", prop.EvaluatedValue);

            Assert.AreEqual(4, extractor.AllFoundProperties.Count());
            allprops = (from p in extractor.AllFoundProperties
                        let pl = p.Key
                                 orderby pl ascending
                                 select pl).ToList();
            Assert.AreEqual("AssemblyName", allprops[0]);
            Assert.AreEqual("Configuration", allprops[1]);
            Assert.AreEqual("Platform", allprops[2]);
            Assert.AreEqual("UniqueforDebug", allprops[3]);
        }
예제 #2
0
        static void Main(string[] args)
        {
            var timer = new Stopwatch();

            timer.Start();
            if (args.Length != 4)
            {
                Console.WriteLine("RefactorConsole <input_dir> <property_sheet> <config> <platform>");
                return;
            }

            string inputDir = args[0];

            if (!Directory.Exists(inputDir))
            {
                Console.WriteLine("Input directory doesn't exist: {0}", inputDir);
                return;
            }
            string propSheet = args[1];

            if (!File.Exists(propSheet))
            {
                Console.WriteLine("Input property sheet file doesn't exist: {0}", propSheet);
                return;
            }
            string config   = args[2];
            string platform = args[3];

            bool verbose  = true;
            var  refactor = new PropertyExtractor(inputDir, config, platform, verbose);

            refactor.PropertySheetPath = propSheet;
            timer.Stop();
            Console.WriteLine("{0} files", refactor.CountFoundFiles);
            Console.WriteLine("{0} files valid", refactor.Count);
            Utils.WL(ConsoleColor.DarkYellow, String.Format("Elapsed Time: {0}\n", timer.Elapsed));

            Console.WriteLine("Change configuration property");
            timer.Restart();
            refactor.SetGlobalProperty("Configuration", "Release");
            timer.Stop();
            Utils.WL(ConsoleColor.DarkYellow, String.Format("Elapsed Time: {0}\n", timer.Elapsed));

            Console.WriteLine("Moving a property");
            timer.Restart();
            refactor.Move("OutputPath", "$(BuildDir)");
            timer.Stop();
            Utils.WL(ConsoleColor.DarkYellow, String.Format("Elapsed Time: {0}\n", timer.Elapsed));

            Console.WriteLine("Change configuration property");
            timer.Restart();
            refactor.SetGlobalProperty("Configuration", "Debug");
            timer.Stop();
            Utils.WL(ConsoleColor.DarkYellow, String.Format("Elapsed Time: {0}\n", timer.Elapsed));

            Console.WriteLine("Moving a property");
            timer.Restart();
            refactor.Move("OutputPath", "$(BuildDir)");
            timer.Stop();
            Utils.WL(ConsoleColor.DarkYellow, String.Format("Elapsed Time: {0}\n", timer.Elapsed));

            Console.WriteLine("Removing a random property");
            timer.Restart();
            refactor.Remove("Optimize");
            refactor.Move("ProjectType", "local");
            timer.Stop();
            Utils.WL(ConsoleColor.DarkYellow, String.Format("Elapsed Time: {0}\n", timer.Elapsed));

            Console.WriteLine("Saving the files");
            timer.Restart();
            refactor.SaveAll();
            timer.Stop();
            Utils.WL(ConsoleColor.DarkYellow, String.Format("Elapsed Time: {0}\n", timer.Elapsed));

            Console.WriteLine("Print Found Properties");
            timer.Restart();
            refactor.PrintFoundProperties();
            timer.Stop();
            Utils.WL(ConsoleColor.DarkYellow, String.Format("Elapsed Time: {0}\n", timer.Elapsed));
        }