当前位置: 首页>>代码示例>>C#>>正文


C# Serializer.SerializeObject方法代码示例

本文整理汇总了C#中Serializer.SerializeObject方法的典型用法代码示例。如果您正苦于以下问题:C# Serializer.SerializeObject方法的具体用法?C# Serializer.SerializeObject怎么用?C# Serializer.SerializeObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Serializer的用法示例。


在下文中一共展示了Serializer.SerializeObject方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SaveRule

        public void SaveRule()
        {
            var dal = new DAL();
            var bonds = dal.GetList();
            if (bonds.Count == 0)
            {
                const string message = @"You do not have any bonds to Save, thus I am unable "
                    + @" to save any bonds. Please add some bonds before Saving";
                MessageBox.Show(message);
                return;
            }

            var dlg = new SaveFileDialog { FileName = "Prize Bond Manager",
                DefaultExt = ".pbm", Filter = @"Prize Bond Manager Files (.pbm)|*.pbm" };

            // Show save file dialog box
            var result = dlg.ShowDialog();

            // Process save file dialog box results
            if (result == DialogResult.OK)
            {
                // Save document
                string filename = dlg.FileName;
                var serializer = new Serializer();
                var objectToSerialize = new ObjectToSerialize { Bonds = bonds };
                serializer.SerializeObject(filename, objectToSerialize);
            }
        }
开发者ID:munnaonc,项目名称:PrizeBondManager,代码行数:28,代码来源:BackUpManager.cs

示例2: deleteButton_Click

        private void deleteButton_Click(object sender, EventArgs e)
        {
            downloadedTrailers.RemoveAt(historyListBox.SelectedIndex);
            historyListBox.DataSource = null;
            historyListBox.DataSource = downloadedTrailers;

            // Save new list
            downloadedTrailers = (List<string>)historyListBox.DataSource;
            Serializer serializer = new Serializer();
            serializer.SerializeObject(Application.StartupPath + "\\trailerDB.txt", trailerDBobject);
        }
开发者ID:tmar89,项目名称:tmar89snapstreamdev,代码行数:11,代码来源:dBEditor.cs

示例3: runwork

        // Thread to scan
        private void runwork()
        {
            // Log in again
            if (!login())
            {
                SetStatus(statusWindow, "Will try to log on again in 10 seconds");
                hourTimer.Change(10000, 1000 * 60 * 60 * 4);
                scanner.Abort();
            }

            try
            {
                // List to save movies to db file
                List<string> downloadedTrailers = new List<string>();
                ObjectToSerialize trailerDBobject = new ObjectToSerialize();
                trailerDBobject.DownloadedTrailers = downloadedTrailers;

                // Scan for trailers
                SetStatus(statusWindow, "Scanning for new Trailers");
                string URL = "http://www.trailerfreaks.com/";
                HttpWebRequest webreq = (HttpWebRequest)WebRequest.Create(new System.Uri(URL));
                HttpWebResponse webres = (HttpWebResponse)webreq.GetResponse();
                Stream resStream = webres.GetResponseStream();
                string response = new StreamReader(resStream).ReadToEnd();
                // Find trailer
                string trailerStart = "a href =\"trai"; string toFind; string trailerName; string trailerDescription;
                string trailerDate; string trailerActors; string trailerNameClean; string trailerDetailsURL;
                int startindex, endindex;
                //int numToGet = 10000;
                //if (!numTrailersToGet.Equals("All"))
                //    numToGet = int.Parse(numTrailersToGet);
                //int count = 0;
                //while ((startindex = response.IndexOf(trailerStart)) > -1 && count < numToGet)
                while ((startindex = response.IndexOf(trailerStart)) > -1)
                {
                    bool skip = false;

                    if (startindex > -1)
                    {
                        response = response.Substring(startindex);
                    }
                    else
                    {
                        SetStatus(statusWindow, "Error Finding Trailer Page Links");
                        SetStatus(statusWindow, "Scanning aborted.");
                        enableControls(true);
                        scanner.Abort();
                    }
                    toFind = "title=\"";
                    startindex = response.IndexOf(toFind);
                    if (startindex > -1)
                    {
                        startindex += toFind.Length; // Move to starting position of new Trailer
                    }
                    else
                    {
                        SetStatus(statusWindow, "Error parsing for Trailer Name");
                        continue;
                    }
                    endindex = response.IndexOf("\"", startindex);
                    trailerName = response.Substring(startindex, endindex - startindex).Trim();
                    // Remove Year
                    trailerName = trailerName.Remove(trailerName.LastIndexOf(" "));
                    trailerNameClean = replaceSpecials(trailerName);
                    trailerNameClean = trailerNameClean.Remove(trailerNameClean.LastIndexOf(" "));
                    SetStatus(statusWindow, "Found Trailer: " + trailerName);
                    response = response.Substring(endindex);

                    // Check if it exists already in flat file
                    string trailerDB = Application.StartupPath + "\\trailerDB.txt";
                    if (!File.Exists(trailerDB))
                    {
                        if (verbose)
                            SetStatus(statusWindow, "New DB Created and will add Trailer after successfull download");
                    }
                    else
                    {
                        Serializer serializer = new Serializer();
                        trailerDBobject = serializer.DeSerializeObject(Application.StartupPath + "\\trailerDB.txt");
                        downloadedTrailers = trailerDBobject.DownloadedTrailers;
                        if (downloadedTrailers.Contains(trailerName + GetText(formatBox)))
                        {
                            SetStatus(statusWindow, "Already Downloaded, Skipping Trailer");
                            skip = true;
                        }
                        else
                        {
                            if (verbose)
                                SetStatus(statusWindow, "Not in DB will add Trailer after successfull download");
                        }
                    }

                    if (!skip)
                    {
                        // Get description
                        toFind = "<a href=\"";
                        startindex = response.IndexOf(toFind);
                        if (startindex > -1)
                        {
//.........这里部分代码省略.........
开发者ID:tmar89,项目名称:tmar89snapstreamdev,代码行数:101,代码来源:GUI.cs

示例4: ToFile

 public override void ToFile()
 {
     Serializer serializer = new Serializer();
     serializer.SerializeObject<TerrainScreen>("save.txt", this);
 }
开发者ID:Andrusza,项目名称:PiratesArr,代码行数:5,代码来源:Setup.cs


注:本文中的Serializer.SerializeObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。