I do not know how to correctly name the question, so I could not change it. My question is: I have about 10 methods that look like this:
[WebMethod(EnableSession = true)] public string ReadUserAdditional() { EUser user = (EUser)Session["user"]; var json = new { result = true, user.Image, user.Biography }; return new JavaScriptSerializer().Serialize(json); } [WebMethod(EnableSession = true)] public string ReadUserBasicInformation() { EUser user = (EUser)Session["user"]; var json = new { result = true, user.Name, user.Username}; return new JavaScriptSerializer().Serialize(json); }
The methods are very similar, but they return different fields. Im thinking of reorganizing all methods into one, getting fields to return as parameters. Is that a good idea? How can i do this? Reflection?
user989818
source share