public static UserProfile LoadUserProfile() { if (General.isDesignMode()) { return(null); } string InstallationConfigurationPath = Assembly.GetExecutingAssembly().Location.Replace(Path.GetFileName(Assembly.GetExecutingAssembly().Location), "Ginger.InstallationConfiguration.Json"); string UserConfigJsonString = string.Empty; JObject UserConfigJsonObj = null; Dictionary <string, string> UserConfigdictObj = null; if (System.IO.File.Exists(InstallationConfigurationPath)) { UserConfigJsonString = System.IO.File.ReadAllText(InstallationConfigurationPath); UserConfigJsonObj = JObject.Parse(UserConfigJsonString); UserConfigdictObj = UserConfigJsonObj.ToObject <Dictionary <string, string> >(); } if (File.Exists(UserProfileFilePath)) { try { DateTime UserProfileDT = File.GetLastWriteTime(UserProfileFilePath); Reporter.ToLog(eLogLevel.INFO, string.Format("Loading existing User Profile at '{0}'", UserProfileFilePath)); string userProfileTxt = File.ReadAllText(UserProfileFilePath); UserProfile up = (UserProfile)NewRepositorySerializer.DeserializeFromText(userProfileTxt); up.FilePath = UserProfileFilePath; if (UserConfigdictObj != null && DateTime.Compare(UserProfileDT, File.GetLastWriteTime(InstallationConfigurationPath)) < 0) { up.AddUserConfigProperties(UserConfigdictObj); } return(up); } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, string.Format("Failed to load the existing User Profile at '{0}'", UserProfileFilePath), ex); try { //create backup to the user profile so user won't lose all of it configs in case he went back to old Ginger version //TODO- allow recover from newer User Profile version in code instead creating new user profile Reporter.ToLog(eLogLevel.INFO, "Creating backup copy for the User Profile file"); File.Copy(UserProfileFilePath, UserProfileFilePath.Replace("Ginger.UserProfile.xml", "Ginger.UserProfile-Backup.xml"), true); } catch (Exception ex2) { Reporter.ToLog(eLogLevel.ERROR, "Failed to create backup copy for the User Profile file", ex2); } } } Reporter.ToLog(eLogLevel.INFO, "Creating new User Profile"); UserProfile up2 = new UserProfile(); up2.LoadDefaults(); if (UserConfigdictObj != null) { up2.AddUserConfigProperties(UserConfigdictObj); } return(up2); }