使用共享 DLL 并向类添加 UI 属性

发布于 2024-09-19 12:29:56 字数 576 浏览 3 评论 0原文

我有一个具有 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

£冰雨忧蓝° 2024-09-26 12:29:56

我认为将任何形式的 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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文