Ejemplo n.º 1
0
        private void OnFormLoad(object sender, EventArgs e)
        {
            _executor        = new Executor();
            _env             = new ProcEnvironInfo();
            _defaultCmdPaths = new List <string>();
            _defaultCmdPaths.Add(_env.SysDir.System32);
            _defaultCmdPaths.Add(_env.SysDir.WinDir);

            _configFile = Path.Combine(_env.WorkingDir, CmdConfigFile);
            if (FileValidator.IsValid(_configFile))
            {
                _cmdTable = ObjSerializer.Load <DataTable>(Path.Combine(_env.WorkingDir, CmdConfigFile));
            }
            else
            {
                _cmdTable = new DataTable("CommandTable");
                _cmdTable.Columns.Add("Command");
                _cmdTable.Columns.Add("Parameters");

                object[] itemArray = new object[_cmdTable.Columns.Count];
                itemArray[0] = ExplorerCmd;
                itemArray[1] = ExplorerParam;
                DataRow dtRowTmp = _cmdTable.NewRow();
                dtRowTmp.ItemArray = itemArray;
                _cmdTable.Rows.Add(dtRowTmp);
            }

            FillSettingTable();
        }
Ejemplo n.º 2
0
 private void LoadMesh(string path)
 {
     if (File.Exists(path))
     {
         var mesh = mObjReader.Load(path);
         if (mesh != null && mesh.IsValid())
         {
             AddMeshData(mesh.Name, mesh, path);
         }
     }
 }
Ejemplo n.º 3
0
        private bool DoLoad <SettingT>(string filePath, out SettingT obj) where SettingT : new()
        {
            if (FileValidator.IsValid(filePath, 1))
            {
                try
                {
                    obj = ObjSerializer.Load <SettingT>(filePath);
                    return(true);
                }
                catch
                {
                }
            }

            obj = new SettingT();
            return(false);
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            if (args.Length > 0 && File.Exists(args[0]))
            {
                string batchOptFile = args[0];

                BatchOptionBase <ReplaceOption> bo = ObjSerializer.Load <BatchOptionBase <ReplaceOption> >(batchOptFile);
                BatchTextReplacer batchPro         = new BatchTextReplacer(bo);
                batchPro.Start();
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new TextProcessorForm());
            }
        }
Ejemplo n.º 5
0
        private void OnBatchReplaceOperation(object sender, EventArgs e)
        {
            BatchOptionBase <ReplaceOption> bo = ObjSerializer.Load <BatchOptionBase <ReplaceOption> >(BatchConfigFile);

            _batchOptDlg = new OptionsDlg();
            _batchOptDlg.AddOption(bo);

            if (_batchOptDlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            ObjSerializer.Save(BatchConfigFile, bo);
            BatchTextReplacer batchPro = new BatchTextReplacer(bo);

            batchPro.Start();
        }
Ejemplo n.º 6
0
        public void SerializationTest()
        {
            bool testDictionary = false;
            bool testList       = true;

            if (testDictionary)
            {
                string dcFile = "dictionary.xml";
                Dictionary <int, string> td1 = new Dictionary <int, string>();
                td1.Add(1, "One");
                td1.Add(2, "Two");
                td1.Add(3, "Three");

                ObjSerializer.Save(dcFile, td1);

                Dictionary <int, string> td2 = ObjSerializer.Load <Dictionary <int, string> >(dcFile);
                foreach (int key in td1.Keys)
                {
                    Assert.IsTrue(td1[key] == td2[key]);
                }
            }

            if (testList)
            {
                string      lstFile = "list.xml";
                DBLoginInfo e1      = new DBLoginInfo();
                e1.ServerName = "(local)";
                List <KVPair <string, DBLoginInfo> > lst1 = new List <KVPair <string, DBLoginInfo> >();
                lst1.Add(new KVPair <string, DBLoginInfo>("(local)", e1));
                lst1.Sort();

                ObjSerializer.Save(lstFile, lst1);
                List <KVPair <string, DBLoginInfo> > lst2 = ObjSerializer.Load <List <KVPair <string, DBLoginInfo> > >(lstFile);
                lst2.Sort();
                foreach (KVPair <string, DBLoginInfo> item in lst1)
                {
                    Assert.IsTrue(lst2.Contains(item));
                }
            }
        }