S
S.Sigal
Hello:
I've been trying to 'organize' the layout of my larger controls by moving variables into instances
of subclasses...but it just dawned on me that I might be opening a real can of worms due to StateBag
serialization...
If ViewState serialization is optimized for Int32, Bool, String, Color, and arrays thereof... what
happens when I want to serialize the instance of a class that contains an Int32, Bool String, or
Color?
In other words, if this is optimized:
class MyControl : WebControl {
public Int Uno {get {object o = ViewState['Int'];return (o==null)?0int)o);}set
{ViewState["Int"] = value;}}
public string Dos{get {object o = ViewState['S'];return (o==null)?0string)o);}set
{ViewState["S"] = value;}}
public bool Dos{get {object o = ViewState['B'];return (o==null)?0bool)o);}set {ViewState["B"]
= value;}}
....
}
...is the following optimized as well -- by proxy -- or does it totally mess up everything and fall
back to the lowest common denominator of BinarySerialization or something?
class MyControl : WebControl {
public Control_Grouped_Vars Vars {get {return _Vars;}}
private Control_Grouped_Vars _Vars = new Control_Grouped_Vars();
....
override LoadViewState...
override SaveViewState...
}
public class Control_Grouped_Vars : IStateManaged {
public Int Uno {get {object o = ViewState['Int'];return (o==null)?0int)o);}set
{ViewState["Int"] = value;}}
public string Dos{get {object o = ViewState['S'];return (o==null)?0string)o);}set
{ViewState["S"] = value;}}
public bool Dos{get {object o = ViewState['B'];return (o==null)?0bool)o);}set {ViewState["B"]
= value;}}
override LoadViewState...
override SaveViewState...
}
Questions would be:
a) No need to worry?
b) If yes, will a custom TypeConverter do the trick? Convert the public props to a string of
key:value;key:Value; (same as html style attribute) do the trick?
Thanks for getting back to me asap before I do a lot of damage to myself
I've been trying to 'organize' the layout of my larger controls by moving variables into instances
of subclasses...but it just dawned on me that I might be opening a real can of worms due to StateBag
serialization...
If ViewState serialization is optimized for Int32, Bool, String, Color, and arrays thereof... what
happens when I want to serialize the instance of a class that contains an Int32, Bool String, or
Color?
In other words, if this is optimized:
class MyControl : WebControl {
public Int Uno {get {object o = ViewState['Int'];return (o==null)?0int)o);}set
{ViewState["Int"] = value;}}
public string Dos{get {object o = ViewState['S'];return (o==null)?0string)o);}set
{ViewState["S"] = value;}}
public bool Dos{get {object o = ViewState['B'];return (o==null)?0bool)o);}set {ViewState["B"]
= value;}}
....
}
...is the following optimized as well -- by proxy -- or does it totally mess up everything and fall
back to the lowest common denominator of BinarySerialization or something?
class MyControl : WebControl {
public Control_Grouped_Vars Vars {get {return _Vars;}}
private Control_Grouped_Vars _Vars = new Control_Grouped_Vars();
....
override LoadViewState...
override SaveViewState...
}
public class Control_Grouped_Vars : IStateManaged {
public Int Uno {get {object o = ViewState['Int'];return (o==null)?0int)o);}set
{ViewState["Int"] = value;}}
public string Dos{get {object o = ViewState['S'];return (o==null)?0string)o);}set
{ViewState["S"] = value;}}
public bool Dos{get {object o = ViewState['B'];return (o==null)?0bool)o);}set {ViewState["B"]
= value;}}
override LoadViewState...
override SaveViewState...
}
Questions would be:
a) No need to worry?
b) If yes, will a custom TypeConverter do the trick? Convert the public props to a string of
key:value;key:Value; (same as html style attribute) do the trick?
Thanks for getting back to me asap before I do a lot of damage to myself