码迷,mamicode.com
首页 > 其他好文 > 详细

序列化避免异常的一种解决思路

时间:2015-08-12 23:24:18      阅读:111      评论:0      收藏:0      [点我收藏+]

标签:

 SerializationInfoEnumerator enumerator = info.GetEnumerator();
            while (enumerator.MoveNext())
            {
                if (enumerator.Value != null)
                {
                    if (enumerator.Name == "Caption")
                    {
                        this.caption = Convert.ToString(enumerator.Value);
                    }
                    else if (enumerator.Name == "Mark")
                    {
                        this.mark = Convert.ToString(enumerator.Value);
                    }
                    else if (enumerator.Name == "ImageIndex")
                    {
                        this.imageIndex = Convert.ToInt32(enumerator.Value);
                    }
                    else if (enumerator.Name == "ChildMenus")
                    {
                        this.childMenus = enumerator.Value as List<ToolMenu>;
                    }
                    else if (enumerator.Name == "DisplayStyle")
                    {
                        this.displayStyle = (MenuDisplayStyle)enumerator.Value;
                    }
                    else if (enumerator.Name == "GUID")
                    {
                        this.guid = Convert.ToString(enumerator.Value);
                    }
                    else if (enumerator.Name == "ISchecked")
                    {
                        this.isChecked = Convert.ToBoolean(enumerator.Value);
                    }
                    else if (enumerator.Name == "ISAllowCheck")
                    {
                        this.isAllowCheck = Convert.ToBoolean(enumerator.Value);
                    }
                    else if (enumerator.Name == "ISAllowDropIn")
                    {
                        this.isAllowDropIn = Convert.ToBoolean(enumerator.Value);
                    }
                    else if (enumerator.Name == "ISAllowDropOut")
                    {
                        this.isAllowDropOut = Convert.ToBoolean(enumerator.Value);
                    }
                    else if (enumerator.Name == "Alignment")
                    {
                        this.alignment = (MenuAlignment)enumerator.Value;
                    }
                    else if (enumerator.Name == "MenuType")
                    {
                        this.menuType = (MenuType)enumerator.Value;
                    }
                }
            }

 

序列化避免异常的一种解决思路

标签:

原文地址:http://www.cnblogs.com/llcdbk/p/4725546.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!