예제 #1
0
 public static UserSettingModel Get(string path)
 {
     if (!File.Exists(path))
     {
         return(null);
     }
     if (m_humanResource == null)
     {
         FileStream fs = null;
         try
         {
             XmlSerializer xs = new XmlSerializer(typeof(UserSettingModel));
             fs = new FileStream(path, FileMode.Open, FileAccess.Read);
             m_humanResource = (UserSettingModel)xs.Deserialize(fs);
             fs.Close();
         }
         catch
         {
             if (fs != null)
             {
                 fs.Close();
             }
             //throw new Exception("Xml deserialization failed!");
         }
     }
     return(m_humanResource);
 }
예제 #2
0
        public static void Set(string path, UserSettingModel humanResource)
        {
            if (humanResource == null)
            {
                throw new Exception("Parameter humanResource is null!");
            }

            FileStream fs = null;

            try
            {
                XmlSerializer xs = new XmlSerializer(typeof(UserSettingModel));
                fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None);
                xs.Serialize(fs, humanResource);
                m_humanResource = null;
                fs.Close();
            }
            catch
            {
                if (fs != null)
                {
                    fs.Close();
                }
                //throw new Exception("Xml serialization failed!");
            }
        }
예제 #3
0
        /// <summary>
        /// 加载用户配置
        /// </summary>
        /// <returns></returns>
        public UserSettingModel LoadUserSetting(string ExecutablePath)
        {
            UserSettingModel u = ConfigurationManager.Get(CommonMethods.GetStorePath(Account + ".config")) as UserSettingModel;

            if (u != null)
            {
                u.GetAutoRun(ExecutablePath);
            }
            else
            {
                u = this;
            }
            return(u);
        }