对复杂类型使用设置 [英] Using Settings with Complex Types

查看:129
本文介绍了对复杂类型使用设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的.NET项目中使用Settings类。我在编辑器中注意到,只有某些类型可用于设置类中各个属性的类型。如果我想有一个属性是枚举从我的代码或通用集合实例?



我猜想我可以使用部分类机制在一个单独的文件中做到这一点(因为Settings已经定义为部分类)

解决方案

创建一个新的设置文件,以添加复杂/用户定义的选择类型。
这是一个枚举的操作方法。



第1步。创建设置文件





步骤2 。浏览类型



步骤3 。选择类型(Namespace.TypeName)





步骤4 。 Ta da - 完成




I am using the Settings class in my .NET project. I notice in the editor that only certain types are available to be used as types for the individual properties in the Settings class. What if I wanted to have a property that was an enumeration from my code or a generic collection for instance? How would I implement that?

I'm guessing that I can do it in a separate file using the partial class mechanism (since Settings is already defined as a partial class) but I want to see if anyone agrees with that and if there may be a way to do it within the editor.

解决方案

Create a new "Settings" file to add a complex/user-defined type of choice. Here is a how-to for a Enum.

Step 1. Create a Settings file

Step 2. Browse for type

Step 3. Select type (Namespace.TypeName)

Step 4. Ta da - Done

这篇关于对复杂类型使用设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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