使用共享 DLL 并向类添加 UI 属性
我有一个具有 WCF 通信的服务器/客户端项目,并在合同和对象之间共享 dll:
Service | Shared Objects | Client
对于我的对象,我添加了在 propertygrid 中使用的属性:
[DataMember]
[DisplayName("Javascript File Name")]
[Description("The browseable path of the Javascript file.")]
[Browsable(true)]
[Editor("BaseNS.NS.NS2.ObjectEditor", typeof(System.Drawing.Design.UITypeEditor))]
public String JavaScriptFileName { get; set; }
我使用了 Editor 属性的 (String,Type) 构造函数,因为编辑器将存储在客户端,但我不想将其嵌入到共享 DLL 中,
这项工作是否会导致我无法获取它?
I have a Server/Client project with WCF communications and sharing a dll between both with Contracts and objects:
Service | Shared Objects | Client
For my Objects I added attributes for use in the propertygrid :
[DataMember]
[DisplayName("Javascript File Name")]
[Description("The browseable path of the Javascript file.")]
[Browsable(true)]
[Editor("BaseNS.NS.NS2.ObjectEditor", typeof(System.Drawing.Design.UITypeEditor))]
public String JavaScriptFileName { get; set; }
I used the (String,Type) constructor of the Editor attribute because the editor will be stored at the client and I dont want to embed it in the shared DLL
Should this work cause I cant get it to ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为将任何形式的 UI 代码添加到数据协定类中都不是一个好主意。您正在使用 UI 在模型中创建依赖项。
II 建议您使用一个简单的视图模型类将模型中的相关属性公开到视图并手动执行映射(如果需要,您可以使用现有的映射服务来避免手动执行)。
I don't think it's a good idea to add UI code of any form to a data contract class. You are creating a dependency in your model with the UI.
I I would recommend you to use a simple view model class to expose the relevant properties from your model to the view and do the mapping manually (if you need, you can use an existing mapping service to avoid doing it manually).