Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Diagnostics;
- using System.IO;
- using System.Text;
- namespace BA.Core.IO {
- /// <summary>
- /// Used for handling notification on a TextWriter
- /// </summary>
- public class NotificationTextWriter :TextWriter {
- public event TextNotificationHandler TextNotification;
- public NotificationTextWriter() { }
- public NotificationTextWriter(TextNotificationHandler notificationFunc) {
- TextNotification += notificationFunc;
- }
- protected void OnTextNotification(TextNotificationArgs args) {
- if (TextNotification != null )
- TextNotification(this ,args);
- }
- public override void Write(char [] buffer,int index,int count) {
- this .Write(new String (buffer,index,count));
- }
- public override void Write(string value) {
- OnTextNotification(new TextNotificationArgs () { Output = value });
- }
- public override Encoding Encoding {
- get { return Encoding .Default; }
- }
- }
- public delegate void TextNotificationHandler (object sender,TextNotificationArgs e);
- public class TextNotificationArgs :EventArgs {
- public string Output { get ; set ; }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment