scala在case类之间转换的最佳方法是什么?(What would be the best way in scala to convert between case classes?)
我有一个模型类,我从我的servcie中的api回来,当我把它返回到某个客户端时,我想使用我自己的模型来保持它对客户端更简单和更清洁。
例子:
case class ReturnedModel(succeed: Option[String], reason: Reason, transactionId: List[Int], opId: Option[Int]) case class MyReturnedModel(reason: String)
我可能需要在将来做更多这样的事情,所以我想也许有一个我不知道的最好的做法,谢谢!
I have a model class im getting back from an api inside my servcie, and when I return it to some client I want to use my own model to keep it simpler and cleaner for the client.
example :
case class ReturnedModel(succeed: Option[String], reason: Reason, transactionId: List[Int], opId: Option[Int]) case class MyReturnedModel(reason: String)
I might need to do more of those in the future so I thought maybe there is a best practice to do it that I dont know of, thanks!
原文:https://stackoverflow.com/questions/43151618
最满意答案
为了获得Steam游戏文件夹,您必须按照以下步骤操作:
- 找到Steam安装文件夹
- 选中Steam
acf
文件和libraryfolders.vdf
您可以在Windows注册表中找到Steam
InstallPath
:
- 32位:
HKEY_LOCAL_MACHINE\SOFTWARE\Valve\Steam
- 64位:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Valve\Steam
您可以使用以下代码从注册表项中读取值 :
Dim strSteamInstallPath as String = My.Computer.Registry.GetValue( "HKEY_LOCAL_MACHINE\SOFTWARE\Valve\Steam", "InstallPath", Nothing) MsgBox("The install path is " & strSteamInstallPath)
一旦你有Steam主文件夹(包含
steam.exe
文件夹),你可以从\steamapps
子文件夹中包含的appmanifest_<steamappid>.acf
文件中读取游戏安装文件夹。例如,
appmanifest_2280.acf
包含有关Ultimate Doom
信息。您可以搜索特定的
steamappid
或分析每个文件并从name
密钥中获取游戏名称。另请查看
\steamapps
子文件夹中的libraryfolders.vdf
以获取其他游戏安装文件夹。例如,我在
D:\mygames
有一些游戏,所以我的libraryfolders.vdf
是:"LibraryFolders" { "TimeNextStatsReport" "xxxxxxxxxxx" "ContentStatsID" "xxxxxxxxxxx" "1" "D:\\mygames" }
一旦你有这个替代文件夹,检查包含在
\steamapps
子文件夹中的acm
文件。In order to obtain a Steam games folder you have to follow this steps:
- find Steam installation folder
- check Steam
acf
files andlibraryfolders.vdf
You can find Steam
InstallPath
in windows registry:
- 32-bit:
HKEY_LOCAL_MACHINE\SOFTWARE\Valve\Steam
- 64-bit:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Valve\Steam
You can read a Value from a Registry Key using this code:
Dim strSteamInstallPath as String = My.Computer.Registry.GetValue( "HKEY_LOCAL_MACHINE\SOFTWARE\Valve\Steam", "InstallPath", Nothing) MsgBox("The install path is " & strSteamInstallPath)
Once you have Steam main folder (the one containing
steam.exe
) you can read games installation folder fromappmanifest_<steamappid>.acf
files contained in\steamapps
subfolder.For example,
appmanifest_2280.acf
contains informations aboutUltimate Doom
.You can search for a particular
steamappid
or analyze every files and get game name fromname
key.Also check
libraryfolders.vdf
in\steamapps
subfolder for other game installation folders.For example I have some games in
D:\mygames
so mylibraryfolders.vdf
is:"LibraryFolders" { "TimeNextStatsReport" "xxxxxxxxxxx" "ContentStatsID" "xxxxxxxxxxx" "1" "D:\\mygames" }
Once you have this alternative folder, check for
acm
files contained in\steamapps
subfolder.
相关问答
更多-
我正在检查我的旧问题,我注意到这个问题几乎有2.5K的意见! 所以我现在认为,我已经想通了,我应该自己回答,以便其他人可以使用它。 那么,如果我没有记错的话,我当时想要的只是这个网址: http://api.steampowered.com/ISteamApps/GetAppList/v0001/ 它甚至不需要API密钥。 它给你一个〜16k AppID列表,其中包括所有蒸汽库存物品。 这个链接和我在上面的问题中给出的链接用于获取所有项目的列表。 只需将JSON反序列化为一个您可以轻松制作此JSON字符串 ...
-
如错误所述,dpkg无法识别:i386令牌。 此令牌来自dpkg multilib实现( http://wiki.debian.org/Multiarch/Implementation )。 Multilib已在dpkg 1.16.2中实现。 Debian stable目前正在使用dpkg 1.15.8( http://packages.debian.org/squeeze/dpkg )。 看一下包描述,它已经明确地用于Debian测试,你使用的是旧的(或稳定的)dpkg版本,它是不兼容的。 As the ...
-
下载函数将URL作为其参数,并将其存储为名为url的变量。 $(basename“$ url”)执行命令basename,其中url变量作为参数,值返回并存储到filename中。 本质上,它试图确定网址的文件名部分。 因此,如果您的网址是www.example.com/foo.txt,则filename只会等于foo.txt if块会尝试查看该文件是否已存在于您当前的工作目录中。 如果没有,那么它使用curl下载它。 package函数接受两个参数:url和target。 该url传递给已经描述的下载功能 ...
-
您需要从HKEY_CURRENT_USER\Software\Valve\Steam的注册表项获取SteamPath。 然后添加文件夹/SteamApps/sourcemods/ 在Qt中,这是这样实现的: QSettings settings("HKEY_CURRENT_USER\\Software\\Valve\\Steam", QSettings::NativeFormat); QString sourcemods_path = settings.value( " ...
-
为了满足totalgames对每个元素增加players回应: import json response = '{"response": {"players": [{"steamid": "12345","communityvisibilitystate": 3,"profilestate": 1,"personaname": "aSteamID","lastlogoff": 1351676021,"profileurl": "http:\/\/steamcommunity.com\/id\/aSteamI ...
-
这个(还)没有API,但您可以通过Valve提供的XML获取此信息。 首先,您需要知道组的groupID64值。 您可以通过检查组成员的XML来找到它。 以Robin Walker为例,我们可以使用以下URL查看他的个人资料: http://steamcommunity.com/id/robinwalker/?xml=1 在那个XML中,你会发现他是几个小组的成员。 他们每个人都有这样一条线:
103582791429521412 这个价值就是我们所需要的。 ... -
简单的答案在这里: http : //msdn.microsoft.com/en-us/library/aa767914(VS.85).aspx 换句话说,您需要先安装应用程序,然后才能从以该协议开头的浏览器接收请求。 在Windows上,协议存储在HKEY_CLASSES_ROOT下的Windows注册表中。 只需查看http键等,这就是引用默认浏览器应用程序的位置(例如,“你想让Chrome成为默认浏览器吗?”对话框设置)。 请注意,当您单击链接时,这将始终启动一个新进程,因此,如果您只希望消息到达已打 ...
-
一种可能性是过滤具有"playtime_forever": 0 。 作为示例,这将从下面的片段中过滤appids 9,92,211。 { "appid": 9, "playtime_forever": 0 }, { "appid": 92, "playtime_forever": 0 }, { "appid": ...
-
查找蒸汽游戏文件夹[关闭](Find steam games folder [closed])[2022-03-19]
为了获得Steam游戏文件夹,您必须按照以下步骤操作: 找到Steam安装文件夹 选中Steam acf文件和libraryfolders.vdf 您可以在Windows注册表中找到Steam InstallPath : 32位: HKEY_LOCAL_MACHINE\SOFTWARE\Valve\Steam 64位: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Valve\Steam 您可以使用以下代码从注册表项中读取值 : Dim strSteamInstallPat ... -
此文件C:\Program Files (x86)\Steam\steamapps\libraryfolders.vdf 包含所有本地蒸汽库的路径。 (不包括默认库中的那个) 然后获取位于每个游戏文件夹( {library}\steamapps\common\{game}\steam_appid.txt )中的{library}\steamapps\common\{game}\steam_appid.txt ,您将获得所有已安装游戏的Steam应用程序ID列表。 This file C:\Program F ...