As a way to return (without register enum type) the information of an
enumeration you can return its value an in the SerializePrimitive
method add the support to Enum type in order to convert it to an object
with properties as the names of the enumeration and its values for each
one.
For example:
internal void SerializePrimitive(object o, StringBuilder sb)
{
// ...
if (o is Enum)
{
names = Enum.GetNames (o.GetType ());
values = Enum.GetValues (o.GetType ());
b = true;
sb.Append ("{");
for (i = 0; i < names.Length; i++)
{
if (b){ b = false; }
else { sb.Append (","); }
sb.Append (string.Format ("{0}:{1}",
JavaScriptSerializer.Serialize
(names [i]), values.GetValue (i).ToString ()));
}
sb.Append ("}");
}
Then you can return an type for an enumeration and work with then as an
object variable in the client.
I use it in order to support cross layers the lenghts of a fields of
database for example in the businessLayer:
// Lengths of the fields for table City
public enum CityLength
{
Name = 60
}
Then in the client (any presentation layer) working with the info of
this enumeration:
ThisForm.txt_CityName.maxLength = CityLength.Name;
Please have in mind.
Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ajax.NET Professional" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/ajaxpro
The latest downloads of Ajax.NET Professional can be found at
http://www.ajaxpro.info/
Don't forget to read my blog at http://weblogs.asp.net/mschwarz/
-~----------~----~----~----~------~----~------~--~---