Esempio n. 1
0
        public void ReadProduct()
        {
            string  filePath = @"..\..\Utils\Xml\Serialization\TestData\SomeProduct.xml";
            Product product  = ObjectXmlSerializer <Product> .Load(filePath);

            Assert.AreEqual(product.ProductID, 10);
            Assert.AreEqual(product.Name, "testname");
            Assert.AreEqual(product.ListPrice, 10.0m);
        }
Esempio n. 2
0
        public void GetData(Action <FormularData, Exception> callback)
        {
            // Code runs "for real"
            //string folder = Environment.CurrentDirectory;
            string       folder   = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            string       path     = Path.Combine(folder, @"Data\FormData.xml");
            FormularData formData = ObjectXmlSerializer <FormularData> .Load(path);

            callback(formData, null);
        }
Esempio n. 3
0
        public void Write()
        {
            //try to serialize a derived class while xml tags are only present in the baseclass
            string filePath1 = @"CustomSerializerTest.Write.xml";

            derived.Id        = 121;
            derived.AnotherId = 1600;
            test.SomeClass    = derived;
            ObjectXmlSerializer <TestClass> .Save(test, filePath1);

            //reload the class, compare the property values
            TestClass myClassFromFile = ObjectXmlSerializer <TestClass> .Load(filePath1);

            Assert.AreEqual(test.SomeClass.Id, myClassFromFile.SomeClass.Id);
        }
Esempio n. 4
0
        private void LoadProject()
        {
            if (_threads != null)
            {
                foreach (var thread in _threads)
                {
                    thread.Abort();
                }
            }
            timer1.Enabled = false;
            LblTime.Text   = "";
            LblStatus.Text = @"Ready";
            Globals.Pause  = false;
            ThreadPool.Queue.Clear();
            BtnStart.Text   = @"Start";
            PrgMain.Maximum = 0;
            PrgMain.Value   = 0;
            LstResults.Items.Clear();
            Actions.Agents.Clear();
            //Load Project
            _currentProject = ObjectXmlSerializer <ProjectModel> .Load(DirStructure.ProjectsDir + Globals.ActiveProject + "\\" + Globals.ActiveProject + ".xml");

            Log.Add2Log("Project loaded: " + _currentProject.ProjectName, _currentProject.ProjectName);
            if (_currentProject.Sites.Count > 5)
            {
                MessageBox.Show(@"Project has been deleted due to usage violation" +
                                Environment.NewLine + @"Only 5 domains allowed per project!" +
                                Environment.NewLine + @"Please don't alter the project file next time.",
                                @"Usage Violation", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                File.Delete(DirStructure.ProjectsDir + Globals.ActiveProject + "\\" + Globals.ActiveProject + ".xml");
                Directory.Delete(DirStructure.ProjectsDir + Globals.ActiveProject);
                Globals.ActiveProject    = "";
                BtnDeleteProject.Visible = false;
                Text = @"SeHydra";
                LoadProjectsList();
                return;
            }
            //Load Projects
            if (_currentProject.UsePremiumProxies)
            {
                Proxies.Actions.LoadProxyList();
            }
            if (!_currentProject.UsePremiumProxies && !string.IsNullOrEmpty(_currentProject.ProxyList))
            {
                Proxies.Actions.LoadProxyListFromFile(_currentProject.ProxyList);
            }
        }
Esempio n. 5
0
        private void MnuAppLoad_Click()
        {
            Microsoft.Win32.OpenFileDialog oXml = new OpenFileDialog
            {
                Title  = "Select XML-ConfigFile",
                Filter = "XML (*.xml)|*.xml"
            };
            //oDlg.RestoreDirectory = true;
            string dir = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);

            oXml.InitialDirectory = dir;

            // Show open file dialog box
            Nullable <bool> result = oXml.ShowDialog();

            if (result == true)
            {
                this._pfadKonfigurationsdatei = oXml.FileName.ToString();
            }
            // Load the form object from the existing XML file (if any)...
            if (File.Exists(this._pfadKonfigurationsdatei) == true)
            {
                // Load the form object from the XML file using our custom class...
                FormularData formdata = ObjectXmlSerializer <FormularData> .Load(this._pfadKonfigurationsdatei);

                if (formdata == null)
                {
                    MessageBox.Show("Unable to load a formular data object from file '" + this._pfadKonfigurationsdatei + "'!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else  // Load form properties into form data...
                {
                    //this.LoadCustomerIntoForm(formdata);
                    this.FormData.DeepCopy(formdata);
                    //this.FormData = formdata;
                    this.Title = this._pfadKonfigurationsdatei;
                }
            }
            else
            {
                MessageBox.Show(this.CreateFileDoesNotExistMsg(), "Information", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Esempio n. 6
0
        /// <summary>
        ///     Tries the load.
        /// </summary>
        /// <param name="pathFileName">Name of the path file.</param>
        /// <param name="trend">The trend.</param>
        /// <returns></returns>
        public static bool TryLoad(string pathFileName, out TrendDeltaV trend)
        {
            // Check file name
            if (!File.Exists(pathFileName))
            {
                trend = null;
                return(false);
            }

            // Load
            try
            {
                trend = ObjectXmlSerializer <TrendDeltaV> .Load(typeof(TrendDeltaV), pathFileName);

                trend.SourcePathFilename = pathFileName;
            }
            catch (Exception e)
            {
                ServiceContext.MessageDisplayService.ShowError("Load failed", e);
                trend = null;
            }

            return(trend != null);
        }
Esempio n. 7
0
        private void LoadSettings()
        {
            TxtProjectName.Enabled = false;
            var result = ObjectXmlSerializer <ProjectModel> .Load(DirStructure.ProjectsDir + _name + "\\" + _name + ".xml");

            TxtProjectName.Text       = result.ProjectName;
            TrkMaxWait.Value          = result.MaxWait;
            TrkThreadCount.Value      = result.ThreadCount;
            TrkLoopCount.Value        = result.LoopCount;
            ChkClickMyLinks.Checked   = result.ClickLinks;
            TxtProxyList.Text         = result.ProxyList;
            ChkPremiumProxies.Checked = result.UsePremiumProxies;
            //if (!string.IsNullOrEmpty(result.AgentList))
            //GetAgentCount(result.AgentList);
            //if (!string.IsNullOrEmpty(result.ProxyList))
            // GetProxyCount(result.ProxyList);
            //_openAgentListDlg.FileName = result.AgentList;

            foreach (var contro in result.Sites.Select(site => new DomainControl {
                Domain = site.Site, Keywords = site.Keywords
            }))
            {
                PnlDomains.Controls.Add(contro);
            }

            foreach (var engine in result.Engines.Select(item => item.Split('|')[0]))
            {
                for (var i = 0; i <= LstEngines.Items.Count - 1; i++)
                {
                    if ((LstEngines.Items[i].ToString().Contains(engine)))
                    {
                        LstEngines.SetItemCheckState(i, CheckState.Checked);
                    }
                }
            }
        }