示例#1
0
        static void Main(string[] args)
        {
            //Worker.I.DoWork();
            Worker.I.Preview = true;
            Model_CleanerML CleanerML = new Model_CleanerML();

            XmlSerializer srlzr = new XmlSerializer(typeof(cleaner));

            FileInfo fi = new FileInfo(@"D:\Clients\oDesk\2015\Frank\mCleaner\mCleaner\mCleaner\Cleaners\freerider.xml");

            //using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(mCleaner.App.testcleaner)))
            {
                cleaner clnr = (cleaner)srlzr.Deserialize(fi.OpenText());
                CleanerML.CleanerML = clnr;

                foreach (option o in clnr.option)
                {
                    foreach (action a in o.action)
                    {
                        Console.WriteLine("Executing '{0}' command with '{1}' search parameter in '{2}' path", a.command, a.search, a.path);

                        COMMANDS cmd = (COMMANDS)StringEnum.Parse(typeof(COMMANDS), a.command);

                        iActions axn = null;

                        switch (cmd)
                        {
                            case COMMANDS.delete:
                                axn = new CommandLogic_Delete();
                                break;
                            case COMMANDS.sqlite_vacuum:
                                break;
                            case COMMANDS.truncate:
                                break;
                            case COMMANDS.winreg:
                                break;
                        }

                        if (axn != null)
                        {
                            axn.Action = a;
                            axn.Execute();
                        }
                    }
                }
            }

            Worker.I.PreviewWork();

            Console.WriteLine("done");
            Console.ReadLine();
        }
示例#2
0
        static void Main(string[] args)
        {
            Model_CleanerML CleanerML = new Model_CleanerML();

            XmlSerializer srlzr = new XmlSerializer(typeof(cleaner));

            //using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(mCleaner.App.testcleaner)))
            //{
            //    cleaner clnr = (cleaner)srlzr.Deserialize(stream);
            //    CleanerML.CleanerML = clnr;

            //    Console.WriteLine("issupported=" + CleanerML.isSupported);
            //    Console.WriteLine("id=" + clnr.id);
            //    Console.WriteLine("label=" + clnr.label);
            //    Console.WriteLine("description=" + clnr.description);

            //    foreach (running r in clnr.running)
            //    {
            //        Console.WriteLine("type=" + r.type + ">" + r.text);
            //    }

            //    foreach (option o in clnr.option)
            //    {
            //        Console.WriteLine("\tid=" + o.id);
            //        Console.WriteLine("\tlabel=" + o.label);
            //        Console.WriteLine("\tdescription=" + o.description);
            //        foreach (action a in o.action)
            //        {
            //            Console.WriteLine("\t\tcommand=" + a.command + " search=" + a.search + " regex=" + a.regex + " path=" + a.path);
            //        }
            //    }
            //}

            Console.WriteLine("\r\n\r\n\r\ndeserialization done");
            Console.ReadLine();
        }
        public ObservableCollection<TreeNode> GetCleaners()
        {
            if (base.IsInDesignMode)
            {
                #region designer data
                TreeNode root = new TreeNode("Chromium", "chrome")
                {
                    IsInitiallySelected = true,
                    IsAccordionHeader = true,
                    IsExpanded = true,
                    Tag = 1,
                    Children =
                    {
                        new TreeNode("Cache") {},
                        new TreeNode("Cookies") {}
                    }
                };
                root.Initialize();
                this._nodes.Add(root);

                TreeNode root2 = new TreeNode("Windows Explorer", "win_exp")
                {
                    IsAccordionHeader = true,
                    IsExpanded = true,
                    Tag = 1,
                    Children =
                    {
                        new TreeNode("Most recently used") {},
                        new TreeNode("Recent documents list") {},
                        new TreeNode("Run") {},
                        new TreeNode("Search history") {},
                        new TreeNode("Thumbnails") {},
                    }
                };
                root2.Initialize();
                this._nodes.Add(root2);

                SortCleanerCollection();
                #endregion
            }
            else
            {
                XmlSerializer srlzr = new XmlSerializer(typeof(cleaner));
                Model_CleanerML CleanerML = new Model_CleanerML();

                string cleaners_folder = Path.Combine(this._execPath, "cleaners");
                string[] files = Directory.GetFiles(cleaners_folder, "*.xml");
                Array.Sort(files);
                this._nodes.Clear();

                foreach (string filename in files)
                {
                    TreeNode root = new TreeNode();

                    FileInfo fi = new FileInfo(filename);
                    using (StreamReader reader = fi.OpenText())
                    {
                        cleaner clnr = (cleaner)srlzr.Deserialize(reader);
                        CleanerML.CleanerML = clnr;

                        // cleaner files are initially verified after deserialization
                        bool isSupported = CleanerML.isSupported;
                        Debug.WriteLine(clnr.label + "> " + isSupported.ToString());

#if !DEBUG
                        if (isSupported)
                        {
                            if (Settings.Default.HideIrrelevantCleaners)
                            {
                                // further check if the current cleaner is executable.

                                // though check if it has a slow option so skip the precheck
                                // and just include it automatically
                                bool skipprecheck = false;
                                foreach (option o in clnr.option)
                                {
                                    if (o.warning != null && o.warning != string.Empty)
                                    {
                                        skipprecheck = true;
                                        break;
                                    }
                                }

                                if (skipprecheck)
                                {
                                    isSupported = true;
                                }
                                else
                                {
                                    isSupported = CheckIfSupported(clnr);
                                }
                            }
                        }
#endif

                        if (isSupported)
                        {
                            root = new TreeNode(clnr.label, clnr.id);
                            root.Cleaner = clnr;
                            root.Tag = clnr;
                            root.TreeNodeChecked += TeeNode_TreeNodeChecked;
                            root.TreeNodeSelected += TreeNode_TreeNodeSelected;
                            root.IsAccordionHeader = true;
                            root.IsExpanded = true;
                            root.Children = new List<TreeNode>();

                            foreach (option o in clnr.option)
                            {
                                o.parent_cleaner = clnr;

                                TreeNode child = new TreeNode(o.label, o.id);
                                child.Tag = o;
                                child.TreeNodeChecked += TeeNode_TreeNodeChecked;
                                child.TreeNodeSelected += TreeNode_TreeNodeSelected;
                                child.Initialize();

                                root.Children.Add(child);

                                foreach (action a in o.action)
                                {
                                    a.parent_option = o;
                                }
                            }

                            root.Initialize();
                            this._nodes.Add(root);
                        }
                    }
                }

                AddSystemCleaner();
            }

            SortCleanerCollection();

            return this.CleanersCollection;
        }
        public ObservableCollection<TreeNode> GetCleaners()
        {
            if (base.IsInDesignMode)
            {
                #region designer data
                TreeNode root = new TreeNode("Chromium")
                {
                    IsInitiallySelected = true,
                    Children =
                    {
                        new TreeNode("Cache") {},
                        new TreeNode("Cookies") {}
                    }
                };
                root.Initialize();
                this.CleanersCollection.Add(root);

                TreeNode root2 = new TreeNode("Windows Explorer")
                {
                    Children =
                    {
                        new TreeNode("Most recently used") {},
                        new TreeNode("Recent documents list") {},
                        new TreeNode("Run") {},
                        new TreeNode("Search history") {},
                        new TreeNode("Thumbnails") {},
                    }
                };
                root2.Initialize();
                this.CleanersCollection.Add(root2);
                #endregion
            }
            else
            {
                XmlSerializer srlzr = new XmlSerializer(typeof(cleaner));
                Model_CleanerML CleanerML = new Model_CleanerML();

                string cleaners_folder = Path.Combine(this._exec_path, "cleaners");
                foreach (string filename in Directory.GetFiles(cleaners_folder, "*.xml"))
                {
                    TreeNode root = new TreeNode();

                    FileInfo fi = new FileInfo(filename);
                    using (StreamReader reader = fi.OpenText())
                    {
                        cleaner clnr = (cleaner)srlzr.Deserialize(reader);
                        CleanerML.CleanerML = clnr;

                        // cleaner files are initially verified after deserialization
                        bool isSupported = CleanerML.isSupported;
                        Debug.WriteLine(clnr.label + "> " + isSupported.ToString());

                        if (isSupported)
                        {
                            // further check if the current cleaner is executable.
                            isSupported = CheckIfSupported(clnr);
                        }

                        if (isSupported)
                        {
                            root = new TreeNode(clnr.label, clnr.id);
                            //root.IsInitiallySelected = true;
                            //root.IsChecked = true;
                            root.Tag = clnr;
                            root.TreeNodeChecked += TeeNode_TreeNodeChecked;
                            root.TreeNodeSelected += TreeNode_TreeNodeSelected;
                            root.Children = new List<TreeNode>();

                            foreach (option o in clnr.option)
                            {
                                o.parent_cleaner = clnr;

                                TreeNode child = new TreeNode(o.label, o.id);
                                child.Tag = o;
                                child.TreeNodeChecked += TeeNode_TreeNodeChecked;
                                child.TreeNodeSelected += TreeNode_TreeNodeSelected;
                                child.Initialize();

                                root.Children.Add(child);

                                foreach (action a in o.action)
                                {
                                    a.parent_option = o;
                                }
                            }

                            root.Initialize();
                            this.CleanersCollection.Add(root);
                        }
                    }
                }
            }

            return this.CleanersCollection;
        }