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


     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;
                        }
                    }
                }
  • 相关阅读:
    VScode网页开发工具
    Java修饰符总结
    C++进阶补充
    C++进阶
    计算机简单开发的基础
    C++动态规划和递归
    C++设计模式
    C++ virtual
    C++-基于STL的演讲比赛流程管理系统
    C++6(5补充)
  • 原文地址:https://www.cnblogs.com/llcdbk/p/4725546.html
Copyright © 2020-2023  润新知