Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Rest ServiceStack/TypeScript:TypeScript引用忽略名称空间(这会导致重复)_Rest_Typescript_<img Src="//i.stack.imgur.com/WM7S8.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">servicestack_Nativescript_Angular2 Nativescript - Fatal编程技术网 servicestack,nativescript,angular2-nativescript,Rest,Typescript,servicestack,Nativescript,Angular2 Nativescript" /> servicestack,nativescript,angular2-nativescript,Rest,Typescript,servicestack,Nativescript,Angular2 Nativescript" />

Rest ServiceStack/TypeScript:TypeScript引用忽略名称空间(这会导致重复)

Rest ServiceStack/TypeScript:TypeScript引用忽略名称空间(这会导致重复),rest,typescript,servicestack,nativescript,angular2-nativescript,Rest,Typescript,servicestack,Nativescript,Angular2 Nativescript,我正在学习NativeScript+Angular2,以C#中的ServiceStack作为后端 对于应用程序,我使用TypeScript ref命令生成了TypeScript类,用于ServiceStack中的JsonServiceClient: >typescript-ref http://192.168.0.147:8080 RestApi 这一切看起来都很美好,但我发现它似乎忽略了ServiceStack服务和响应DTO在.NET端的不同名称空间中: 我有不同的服务分支,其中每

我正在学习NativeScript+Angular2,以C#中的ServiceStack作为后端

对于应用程序,我使用
TypeScript ref
命令生成了TypeScript类,用于ServiceStack中的
JsonServiceClient

>typescript-ref http://192.168.0.147:8080 RestApi
这一切看起来都很美好,但我发现它似乎忽略了ServiceStack服务和响应DTO在.NET端的不同名称空间中:

我有不同的服务分支,其中每个服务的处理程序在分支之间可能略有不同。这在ServiceStack中运行良好,登录和处理程序工作正常

因此,在app/NativeScript/Angular2端,我使用
typescript ref
并生成
restapi.dtos.ts
。问题在于它跳过了名称空间的差异,只创建了重复的类(从VSCode):

ServiceStack中的后端WS是以这种“分支”方式构建的,因此我不必在不同的端口上启动不同的服务,而是将所有服务集中在一个端口上,并保持简单和清晰


我的问题可以解决吗?

在面向公众的服务合同中,您永远不应该依赖.NET名称空间。它在.NET客户端中受支持,但在任何其他语言中都不受支持


一般来说,您的DTO在整个SOA边界内应该是唯一的,因此只有1个
Test
DTO映射到单个模式定义,从而确保当它通过服务网关发送、通过服务发现解决、发布到MQ服务器等时,它只映射到单个DTO契约。

对,那我得重新考虑一下。您知道有没有一种方法可以在同一端口上承载多个API,而不是使用经典的Web服务器作为反向代理?我是自托管。@Ted不在同一端口上,因此如果希望同一主机上出现多个实例,则需要使用反向代理。好的,谢谢。如果能够在一个端口上启动一个AppHost,但定义多个API,这样AppHost就可以在构造函数中指定多个程序集,或者类似的东西,这可能是一个很好的未来特性?因此,与其使用:
public-AppHost(IModuleController-ModuleControl,IContactModule-contactModule):base(“HttpListener-Self-Host”,typeof(AppHost).Assembly)
,不如使用类似于
AddAssemblyWithServices(Assembly-Assembly,string-prefix)
的方法,其中
前缀为程序集中的所有服务加前缀,所以
/api/
?=)@你可以指定。IMO路由应该在每个请求DTO上明确显示,因为它是服务合同的一部分,但也有一些方法可以通过DTO动态修改路由。可以添加其他功能请求,以便测量兴趣。好的,但是在包含服务的每个程序集中,DTO/服务必须仍然具有唯一的名称(因为它是相同的“服务契约”)。因此,在
typeof(servicesfromdl1).Assembly,typeof(servicesfromdl2).Assembly
的情况下,
servicesfromdl1
中的服务名称不能在
servicesfromdl2
中有任何同名的DTO等,如您上面的回答所示?