开发者

Using Shared DLLs and adding UI Attributes to classes

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 开发者_StackOverflowI cant get it to ?


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜