Reputation: 105
I'm in the process of creating the Model (MVC) for a new front end in ASP.NET MVC 4.
I'm using an existing backend, that when called returns status codes and the data.
I've created a Class "Status" which holds the status codes, but I'm not sure of the correct procedure to append or attach different kind of Objects to the "Status" Class.
For now i just have an Object called data to hold whatever data the backend returns, but it seems to me that there should be a better way to do this?
public class Status
{
public string SeverityCode { set; get; }
public double ReturnCode { set; get; }
public double ReasonCode { set; get; }
public Object data { get; set; }
}
Upvotes: 0
Views: 73
Reputation: 5024
You can leave it as is and leave processing to the class that will consume your Status
object, or you can subclass it to a generic Status<TData>
, where the TData
is the type of additional data:
public abstract class Status
{
public string SeverityCode { set; get; }
public double ReturnCode { set; get; }
public double ReasonCode { set; get; }
protected object Data { get; set; }
}
public class Status<TData>: Status where TData: class
{
public new TData Data { get { return (TData)base.Data; } set { base.Data = value; } }
}
Upvotes: 1