/// <summary> /// Serialize given object with provided serialization action adapter /// </summary> /// <typeparam name="T">object type to be serialized</typeparam> /// <param name="serializationActionAdapter">delegate accepting TextWriter and object that will perform serialization</param> /// <param name="objectToSerialize">object to be serialized</param> /// <param name="addHeaders">Additional HTTP headers population delegate</param> public void SerializeWith <T>(Action <System.IO.TextWriter, T> serializationActionAdapter, T objectToSerialize, Action <IDictionary <string, string> > addHeaders) { _controllerBridge.SendCancelLayoutAndView(); _controllerBridge.UseResponseWriter(writer => serializationActionAdapter(writer, objectToSerialize)); AddResponseHeaders(addHeaders); }
public void Serialize(Object obj) { _controllerBridge.SendCancelLayoutAndView(); XmlSerializer serial = new XmlSerializer(obj.GetType()); _controllerBridge.UseResponseWriter(delegate(TextWriter writer) { serial.Serialize(writer, obj); }); }