P
Paul Hadfield
Hi,
I'm not having a lot of luck googling for this one, I want to be able to
store a custom class in the user settings (DotNet2.0, win app). I don't
wish to create public get / set properities for all the things I want to
persist just for storing in the user settings file (because that would allow
other apps to access / change data they shouldn't be able to).
I understand how to browse to the object in VS2005 to add an entry to the
settings file., but I'm not sure what I need to do to my class to get it to
work. Using a very basic example below, is there an interface I should
inherit from? I'm guessing there must be an interface that defines at least
two methods, one that returns an xml string of the parameters to persist and
another that takes that xml string and allows the class to initalise itself
internally. (Note I really don't want to add Get/Set for val1 and val2 just
to get default persistance of all public properties).
Thanks in Advance,
- Paul
public ClassA
{
private int val1;
private string val2;
ClassA( val1, val2)
{
this.val1 = val1;
this.val2 = val2;
}
public bool Valid()
{
return ((val1 > 10) && !string.IsNullOrEmpty(val2));
}
public string Text()
{
return (val1.ToString() + ' ' + val2);
}
}
I'm not having a lot of luck googling for this one, I want to be able to
store a custom class in the user settings (DotNet2.0, win app). I don't
wish to create public get / set properities for all the things I want to
persist just for storing in the user settings file (because that would allow
other apps to access / change data they shouldn't be able to).
I understand how to browse to the object in VS2005 to add an entry to the
settings file., but I'm not sure what I need to do to my class to get it to
work. Using a very basic example below, is there an interface I should
inherit from? I'm guessing there must be an interface that defines at least
two methods, one that returns an xml string of the parameters to persist and
another that takes that xml string and allows the class to initalise itself
internally. (Note I really don't want to add Get/Set for val1 and val2 just
to get default persistance of all public properties).
Thanks in Advance,
- Paul
public ClassA
{
private int val1;
private string val2;
ClassA( val1, val2)
{
this.val1 = val1;
this.val2 = val2;
}
public bool Valid()
{
return ((val1 > 10) && !string.IsNullOrEmpty(val2));
}
public string Text()
{
return (val1.ToString() + ' ' + val2);
}
}