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


C# Serialization.DeserializeObject方法代码示例

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


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

示例1: MainForm_Load

        private void MainForm_Load(object sender, EventArgs e)
        {
            // tooltips
            this.toolTip.SetToolTip(this.ckbBasename, "Only show the name of the last directory in listing.");

            //
            this.Location = Properties.Settings.Default.frmMain_Location;
            this.Size = Properties.Settings.Default.frmMain_Size;

            //
            this.columnPath.Width = Properties.Settings.Default.columnPath_Width;
            this.columnChanges.Width = Properties.Settings.Default.columnChanges_Width;

            //
            this.ckbBasename.Checked = Properties.Settings.Default.ckbBasename_Checked;

            // deserialize
            Serialization ser = new Serialization();
            this.Projects = ser.DeserializeObject<Projects>(Properties.Settings.Default.Projects);

            if (this.Projects == null) {
                this.Projects = new Projects();
            }

            this.Projects.OnAdd += delegate(object s, Project p) {
                ListViewItem l = new ListViewItem();
                l.Tag = p;
                if (!this.ckbBasename.Checked) {
                    l.Text = p.Path;
                } else {
                    l.Text = p.Path.Substring(p.Path.LastIndexOf('\\') + 1);
                }

                l.SubItems.Add(new ListViewItem.ListViewSubItem() {
                    Text = p.Changes.Count.ToString()
                });
                this.lvPaths.Items.Add(l);

                if (p.ShowingWindow == true) {
                    p.Window(new frmInfo(p));
                    p.Window().Show();
                }

            };

            this.Projects.OnChange += delegate(object s, Project p) {
                foreach (ListViewItem lvi in lvPaths.Items) {
                    if ((lvi.Tag as Project) == p) {
                        lvi.SubItems[1].Text = p.Changes.Count.ToString();
                        return;
                    }
                }
            };

            this.Projects.Setup(this); // Ensure stuff for late execution

            // drag and drop
            this.lvPaths.AllowDrop = true;

            this.lvPaths.DragEnter += delegate(object ss, DragEventArgs se) {
                if (se.Data.GetDataPresent(DataFormats.FileDrop)) {
                    se.Effect = DragDropEffects.Move;
                }
            };

            this.lvPaths.DragDrop += delegate(object ss, DragEventArgs se) {

                string[] files = (string[])se.Data.GetData(DataFormats.FileDrop);

                foreach (string file in files) {
                    if (!System.IO.Directory.Exists(file)) {
                        return;
                    }
                    this.Projects.Add(file);
                }
            };

            // Sortingz
            this.lvPaths.AutoArrange = true; // keep itams sorted
            this.lvPaths.ColumnClick += this.lvPaths_OnColumnClick;
            this.lvPaths.Sorting = (SortOrder)(Properties.Settings.Default.lvPaths_Sorting);
            this.SortColumn = Properties.Settings.Default.lvPaths_SortColumn;
            this.lvPaths.ListViewItemSorter = new ListViewItemComparer(this.SortColumn, this.lvPaths.Sorting);
            this.lvPaths.Sort();
        }
开发者ID:egilkh,项目名称:WatchIT,代码行数:85,代码来源:frmMain.cs


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