User objects in application settings?

G

Grant Schenck

This seems like is should be straight forward but I'm just not getting it.

I have a very simple class (see below) which I think should be XML
serializable. I have this class defined in my simple form app's namespace.
Now I want to add an instance of this class to my Application Settings. So,
I go to Project | Properties | Settings tab and while I can add settings of
various system types I can't seem to add one of type "Foo". I tried
Browse... but while it shows various system types, it doesn't show my class.

How the heck do I create a setting of type "Foo"???

Once I've got that figured out, how do I create an list of "Foo"s that can
be saved in my settings?

BTW, I use this as an example. I realize that if all I wanted to store was
a string there are simpler built in types.

Thanks!
Grant Schenck

// -----------------
public class Foo
{
Foo() {}

public string Name
{
get { return m_strName; }
set { m_strName = value; }
}

private string m_strName;
}
 
P

Peter Duniho

Any ideas???

Well, since no one who actually knows the answer stepped up, I'll tell you
what I do know:

If your object is serializable, you can save it in your settings.

To make an object serializable, you add the "[Serializable]" property just
before the class. I haven't had a need to do this sort of thing yet, but
my understanding is that if all the members are already serializable, and
you don't want any special handling for any of the members, then that's
all you need to do in order to make the whole class serializable.

It seems to me that those two pieces of information together should
address your question.

If not, well...I did warn you that I don't actually know the answer. :)

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top