private void SaveSymbolAsFavorite(object parameter) { //Create copy by serializing/deserializing SymbolAttributeSet.FavoriteId = Guid.NewGuid().ToString(); var json = new JavaScriptSerializer().Serialize(SymbolAttributeSet); SymbolAttributeSet favoriteSet = new JavaScriptSerializer().Deserialize<SymbolAttributeSet>(json); //Add to favorites favoriteSet.GeneratePreviewSymbol(); Favorites.Add(favoriteSet); //Serialize Favorites and save to file var favoritesJson = new JavaScriptSerializer().Serialize(Favorites); File.WriteAllText(_favoritesFilePath, favoritesJson); }