PC Review


Reply
Thread Tools Rate Thread

componentmodel: saving enum type to app.config

 
 
=?Utf-8?B?U2xhd2VrIFBpb3Ryb3dza2k=?=
Guest
Posts: n/a
 
      5th Aug 2005
(using .NET Framework 1.1)


Hello,


I'm finishing work on a component that is available for users in their
visual designer. It has various properties that can be sent by users. Using
"DynamicProperties" users can set my component's properties to be saved in
their application's configuration file (to be later changed on per
installation basics).

Unfortunatelly it doesn't seem to work with properties that are
enumerations. No matter if I mark enum property with
[RecommendedAsConfigurable(true)] or not, it is still not available in
DynamicProperties (even in Advanced settings).

I've taken a look at what code is generated for string properties loaded
from configuration settings and it looks like it would be enough to replace
"(string)" with "(myenumtype)". Seems trivial but how to make code generator
do that?


I've tried to find a solution to this problem and the only thing I've found
that actually worked was switching property from enumaration to string and
implementing a special class that displays a set of options in visual
designer.

Unfortunatelly this workaround can't be called a solution as it has a
serious limitation - if user needs to change property's value at runtime, sie
needs to enter new value as a string - this doesn't work anymore:
mycomponent.myproperty = type.value;

Users need to write code like this:
mycomponent.myproperty = "value";
which looks bad, is easier to make errors and doesn't allow intellisense to
help the user.


I haven't found any other solution.

Fortunatelly the problem looks like something really common, so the solution
shouldn't be that far away.


Do you have any ideas how can I solve this problem? Could you share them?


--
Sławomir Piotrowski / Telsat GP
Rejestracja Czasu Pracy i Kontrola Dostępu
http://www.ewidencja-czasu-pracy.pl

 
Reply With Quote
 
 
 
 
=?Utf-8?B?U2xhd2VrIFBpb3Ryb3dza2k=?=
Guest
Posts: n/a
 
      8th Aug 2005
Update:

I'm fine with generating code required to read enum from app.config myself
(using CodeDom). Unfortunatelly I can't find any way to make Visual Studio
call my code to do that. In fact I can't even find a way to make Visual
Studio allow enum type being set as a dynamic property.

--
Sławomir Piotrowski / Telsat GP
Rejestracja Czasu Pracy i Kontrola Dostępu
http://www.ewidencja-czasu-pracy.pl



"Slawek Piotrowski" wrote:

> (using .NET Framework 1.1)
>
>
> Hello,
>
>
> I'm finishing work on a component that is available for users in their
> visual designer. It has various properties that can be sent by users. Using
> "DynamicProperties" users can set my component's properties to be saved in
> their application's configuration file (to be later changed on per
> installation basics).
>
> Unfortunatelly it doesn't seem to work with properties that are
> enumerations. No matter if I mark enum property with
> [RecommendedAsConfigurable(true)] or not, it is still not available in
> DynamicProperties (even in Advanced settings).
>
> I've taken a look at what code is generated for string properties loaded
> from configuration settings and it looks like it would be enough to replace
> "(string)" with "(myenumtype)". Seems trivial but how to make code generator
> do that?
>
>
> I've tried to find a solution to this problem and the only thing I've found
> that actually worked was switching property from enumaration to string and
> implementing a special class that displays a set of options in visual
> designer.
>
> Unfortunatelly this workaround can't be called a solution as it has a
> serious limitation - if user needs to change property's value at runtime, sie
> needs to enter new value as a string - this doesn't work anymore:
> mycomponent.myproperty = type.value;
>
> Users need to write code like this:
> mycomponent.myproperty = "value";
> which looks bad, is easier to make errors and doesn't allow intellisense to
> help the user.
>
>
> I haven't found any other solution.
>
> Fortunatelly the problem looks like something really common, so the solution
> shouldn't be that far away.
>
>
> Do you have any ideas how can I solve this problem? Could you share them?
>
>
> --
> Sławomir Piotrowski / Telsat GP
> Rejestracja Czasu Pracy i Kontrola Dostępu
> http://www.ewidencja-czasu-pracy.pl
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
The type or namespace name 'Browsable' does not exist in the class ornamespace 'System.ComponentModel' Rich Microsoft Dot NET Compact Framework 3 29th Nov 2007 05:35 PM
specify enum values sin web.config Random Microsoft ASP .NET 0 31st May 2007 07:18 PM
Getting enum value through enum type Harris Microsoft C# .NET 7 19th Jul 2006 08:29 PM
Is enum type derived from Enum struct? Jerry Microsoft C# .NET 3 23rd Oct 2004 06:12 AM
The type System.ComponentModel.PropertyDescriptor is not marked as serializable. Trapulo Microsoft Dot NET Framework 3 19th Sep 2003 08:30 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:24 PM.