在Unity App.Config文件中包含通用类 [英] Including a generic class in Unity App.Config file

查看:404
本文介绍了在Unity App.Config文件中包含通用类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类型为ISimpleCache<IBrokeredDataObject>的类,要添加为App.Config文件中的类型别名(然后是类型)

I have a class of type ISimpleCache<IBrokeredDataObject> that I want to add as a type alias (then a type) in the App.Config file

线

<typeAlias alias="ISimpleCacheOfIBrokeredDataObject" type="MyApplication.ISimpleCache<IBrokeredDataObject>, MyApplication" />

由于<>显然是错误的,但是我不认为要转义它们;

is obviously wrong due to the <>, however I'm not convinced escaping them;

<typeAlias alias="ISimpleCacheOfIBrokeredDataObject" type="MyApplication.ISimpleCache&lt;IBrokeredDataObject&gt;, MyApplication" />

也是正确的.

我目前正在撕裂我的代码以使用Unity,因此离可编译的代码库太远了,无法快速进行测试,并且希望在这里得到一些确认.

I am currently ripping my code apart to use Unity, so am too far from a compilable code base to test this quickly, and was hoping to get some confirmation here.

推荐答案

查看

要编写通用类型,请使用`符号,后接接口/类接收的通用类型的数量.

In order to write a generic type, use the ` sign followed by the number of generic types that the interface/class receives.

同一页上的评论说:

要在泛型中使用常量类型,需要使用方括号([[ ]]).

所以我想您的配置文件应包含以下内容:

So I guess your configuration file should contain something like this:

<typeAlias alias="ISimpleCacheOfIBrokeredDataObject"
   type="MyApplication.ISimpleCache`1[[MyApplication.IBrokeredDataObject, MyApplication]], MyApplication" />

请注意使用重音符"或反引号"字符(`),而不是普通的单引号(').

Note the use of the "grave accent" or "backquote" character (`), not the normal single quote (').

这篇关于在Unity App.Config文件中包含通用类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆