Hm...well, you maybe you could implement an after action filter and
within the filter have an implementation of TransformFilter (just an
HttpFilter) grab the string from the and clear the buffer. Here's an
filter (not an monorail filter, an HttpFilter) that I use to modify
the response in another filter I implement. I use this in my after
render step of the Monorail filter:
context.UnderlyingContext.Response.Filter =new
ModifyResponseFilter(context.UnderlyingContext.Response.Filter,
ResponseModifier);
and HttpFilter is :
/// <summary>
/// Delegate for modifying the contents of the response. Passes in
the current response text for manipulation and
/// requires the final response to be write back into the stream.
/// </summary>
public delegate string ModifyResponse(string responseText);
/// <summary>
/// For intercepting the response and manipulating it with the <see
cref="ModifyResponse"/> passed in.
/// </summary>
public class ModifyResponseFilter : TransformFilter
{
private readonly ModifyResponse responseModifier;
/// <summary>
/// Initializes a new instance of the <see
cref="ModifyResponseFilter"/> class.
/// </summary>
/// <param name="baseStream">The base stream.</param>
/// <param name="responseModifier">The response
modifier.</param>
public ModifyResponseFilter( Stream baseStream, ModifyResponse
responseModifier):base(baseStream)
{
this.responseModifier = responseModifier;
}
/// <summary>
/// When overridden in a derived class, writes a sequence of
bytes
to the current stream and advances the current position within this
stream by the number of bytes written.
/// </summary>
/// <param name="buffer">An array of bytes. This method copies
<paramref name="count"/> bytes from <paramref name="buffer"/> to the
current stream.</param>
/// <param name="offset">The zero-based byte offset in <paramref
name="buffer"/> at which to begin copying bytes to the current
stream.</param>
/// <param name="count">The number of bytes to be written to the
current stream.</param>
/// <exception cref="T:System.ArgumentException">The sum of
<paramref name="offset"/> and <paramref name="count"/> is greater than
the buffer length. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="buffer"/> is null. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="offset"/> or <paramref name="count"/> is
negative. </exception>
/// <exception cref="T:System.IO.IOException">An I/O error
occurs. </
exception>
/// <exception cref="T:System.NotSupportedException">The stream
does
not support writing. </exception>
/// <exception cref="T:System.ObjectDisposedException">Methods
were
called after the stream was closed. </exception>
public override void Write(byte[] buffer, int offset, int count)
{
if (Closed) throw new
ObjectDisposedException("ModifyResponseFilter");
if(responseModifier== null)
{
throw new
ArgumentNullException("responseModifier");
}
//Get a string version of the buffer
string content =
responseModifier(Encoding.Default.GetString(buffer, offset, count));
byte[] newOutput = Encoding.Default.GetBytes(content);
BaseStream.Write(newOutput, 0, newOutput.Length);
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Castle Project Users" 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/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---