Example #1
0
        public static DesignCondition Deserialize()
        {
            try
            {
                DesignCondition returnSetting = new DesignCondition();

                // if (checkFile(DesignCondition.SettingFile))
                // {

                if (File.Exists(DesignCondition.SettingFile))
                {
                    using (FileStream fs = new FileStream(DesignCondition.SettingFile, FileMode.Open))
                    {
                        XmlSerializer xs = new XmlSerializer(typeof(DesignCondition));
                        //反序列化
                        returnSetting = (DesignCondition)xs.Deserialize(fs);
                        fs.Close();
                    }
                }

                //}
                return(returnSetting);
            }
            catch (Exception e)
            {
                throw new Exception("Deserialize Error:" + e.Message);
            }
        }
Example #2
0
        }                                             //= 15;


        // public string ProjectName = "VRFProject";

        //public DesignCondition(DesignCondition designcondition)
        //{
        //    condition = designcondition;
        //}

        public static void Serialize(string filePath, DesignCondition design)
        {
            try
            {
                using (FileStream fs = new FileStream(filePath, FileMode.Create))
                {
                    System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(DesignCondition));
                    //序列化
                    //xs.Serialize(fs, DesignCondition.UserSetting);
                    xs.Serialize(fs, design);
                    fs.Close();
                }
            }
            catch (Exception e)
            {
                throw new Exception("Serialize Error:" + e.Message);
            }
        }