Michael Schwarz wrote:
> If you define which fields you want to return for each method this
> will not be different if you return different types (classes or
> structs), I don't see the reason or what you want to do instead?!?
>
> Regards,
> Michael
>
>
> On 6/26/06, Deepa <[EMAIL PROTECTED]> wrote:
> >
> > Thanks for the response. So, u suggest that we need to modify the
> > library to create the light weight structs where needed. Is there any
> > way, out of curioisity that this can be acheived, without us having to
> > change the library at all?
> >
> > I understand that the structs are the easy way to go, but just
> > wondering if its at all possible to acheive this any other way.
> >
> > Thanks
> > Deepa.
> >
> --
> Best regards | Schöne Grüße
> Michael
>
excuse me for jumping in, but this very same issue was bothering me as
well,
and I have been thinking of this for a very long time.
At first I thought that what would help me is the ability to define on
a per method base what serializer to use on its output.
this way if you have a class C that has 10 public properties and you
have two functions returning that object,
that you need properties 1 to 5 on the first and properties 4-10 on the
second.
define two serializers that serialize the class differently and assign
them appropriately to the functions.
BUT, then thinking onwards I realized that the problem is actually that
in
those functions I actually need to return collections of the said
objects.
so what I would realy need is the ability to define somthing like a
serialization context that will allow me to set up the serializers
for the different classes used while in the context of serializing the
resulting object.
this could look something like.
[AjaxPro.AjaxSerializationContext(class,serializerclass)]
[AjaxPro.AjaxSerializationContext(class2,serializerclass2)]
Internally when a method would be invoked it should create this context
and when serializing and looking for a serializer it should first look
at the serialization context for an appropriate serializer and only if
such was not found it should continue as it does today.
You might ask yourself (or me) what is this better then the structs
solution ?
well, It reflects the actual need better - If I would not have been
using an ajax library I would do just that - define different
serializers and choose which to use based on the "View" of the object
needed at the client side,
also I am using class I calll A "RestrictedCustomSerializer" , it gets
a list of property names and serializes only those properties.
so I can then
have something like:
public class UserSerializer:RestrictedCustomSerializer{
public UserSerializer() : base(new Type[] {
typeof(Company.BLL.User) }, "UserID,DisplayName") { }
}
and
public class DetailedUserSerializer:RestrictedCustomSerializer{
public DetailedUserSerializer() : base(new Type[] {
typeof(Company.BLL.User) },
"UserID,FirstName,LastName,UserName,DisplayName,LastLogin,Headline,SecondaryEmail,HasPhoto")
{ } //,Photo
}
well, obviously today I don't use both because I have no way to tell
AJAX.NET when to use which,
but I use this to create serializers that hide some properties that are
not needed on the clientside.
hmm... this turned out to be longer then I expected - I hope it makes
sense.
Michael - If you want to discuss this like we discussed the move I
suggested to serializers only without converters,
you have my skype.
Eyal Peleg
JSBugHunter.com
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---