I know that when using a stream I need to flush it so it will releases any resources related to the stream and flushing a stream takes any buffered data which hasn't been written yet, and writes it out right away.
I have the following class:
[XmlRoot("EventList")]
public class EventList
{
private List<BaseEvent> events_ = new List<BaseEvent>();
/// Default constructor. Required for serialization
public EventList() {}
[XmlElement(ElementName = "Event")]
public List<BaseEvent> Events
{
get
{
return events_;
}
set
{
events_ = value;
}
}
}
now before I send it as a response to HTTPRequest do I need to flush it? if so how can I?
I'm asking because I have problem which described here: AJAX response - XmlHttp.responseXML is cut off
The method being activated by js client is:
[WebMethod]
public EventsRequestResult GetEvents(string agentId, int delayedReturnMS)
// EventsRequestResult - return value of the GetEvents method of the EventsService.
public class EventsRequestResult
{
private EventList events_ = null;
/// <summary>
/// List of the events
/// </summary>
[XmlElement(ElementName = "Events")]
public EventList Events
{
get
{
return events_;
}
set
{
events_ = value;
}
}
/// Default constructor.
public EventsRequestResult(){}
/// <summary>
/// Constructor used in case of the failure.
/// </summary>
/// <param name="errorCode">Numeric error code</param>
/// <param name="errorDescription">Human readable error description</param>
public EventsRequestResult(RequestErrorCode errorCode, string errorDescription) : base(errorCode, errorDescription){}
/// <summary>
/// Constructor used in case of successful events request.
/// </summary>
/// <param name="events">List of the events</param>
public EventsRequestResult(EventList events) : base()
{
events_ = events;
}
}