c# - Making a generic TypeEditor -


say have property foo of type sometype in class of type someclass edited custom editor sometypeeditor:

[editorattribute(typeof(sometypeeditor), ...)] public sometype foo {         {         return buildfoofrominternalrepresenation();     }     set     {         updateinternalrepresentation(value);     } } 

the sometypeeditor.editvalue function looks this:

public override object editvalue(system.componentmodel.itypedescriptorcontext context, system.iserviceprovider provider, object value) {     iwindowsformseditorservice edsvc = (iwindowsformseditorservice)provider.getservice(typeof(iwindowsformseditorservice));     if (null == edsvc)     {         return null;     }     var form = new sometypeeditorform(value sometype);     if (dialogresult.ok == edsvc.showdialog(form))     {         var someclass = context.instance someclass;         someclass.foo = form.result;         return someclass.foo;     }     else     {         return value;     } } 

i add property baz, of type sometype, someclass. edit property sometypeeditor line

someclass.foo = form.result; 

in editvalue ties sometypeeditor particular property. simple enough make duplicate of sometypeeditor edits baz instead avoid if possible. there anyway make sometypeeditor generic (in sense of word) can used edit both foo , baz?

you can use provider name of property being edited in property grid. see set break point on editing routine editvalue , hover on provider property. expand , see contains property name of foo/baz being edited. not sure if recommended way obtain information seems work.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -