THRIFT-25. csharp: Various compiler and library improvements

Compiler:
- Thrift structures are serializable.
- The member fields of thrift structures are now private and only accessible
  through Properties, which keep the appropriate __isset up to date.

Library
- Addition of TBufferedTransport, which can be used to wrap other Transports.
- Addition of TThreadedServer, which manually manages threads instead of
  relying on .NET ThreadPool.
- Servers use a log delegate that defaults to System.Console but allows
  servers to use log4net without introducing the dependency.

ThriftTest Visual Studio Project
- Test client and server that use ThriftTest.thrift. The project references
  thrift.exe and Thrift.dll from the subversion tree and automatically builds
  generated code. This makes it very easy to test changes in both the compiler
  and library.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@732079 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/csharp/src/Server/TServer.cs b/lib/csharp/src/Server/TServer.cs
index a9b2816..afb2b9f 100644
--- a/lib/csharp/src/Server/TServer.cs
+++ b/lib/csharp/src/Server/TServer.cs
@@ -14,6 +14,7 @@
 using System.Collections.Generic;
 using Thrift.Protocol;
 using Thrift.Transport;
+using System.IO;
 
 namespace Thrift.Server
 {
@@ -48,6 +49,8 @@
 		 * Output Protocol Factory
 		 */
 		protected TProtocolFactory outputProtocolFactory;
+		public delegate void LogDelegate(string str);
+		protected LogDelegate logDelegate;
 
 		/**
 		 * Default constructors.
@@ -55,7 +58,14 @@
 
 		public TServer(TProcessor processor,
 						  TServerTransport serverTransport)
-			:this(processor, serverTransport, new TTransportFactory(), new TTransportFactory(), new TBinaryProtocol.Factory(), new TBinaryProtocol.Factory())
+			:this(processor, serverTransport, new TTransportFactory(), new TTransportFactory(), new TBinaryProtocol.Factory(), new TBinaryProtocol.Factory(), DefaultLogDelegate)
+		{
+		}
+
+		public TServer(TProcessor processor,
+						TServerTransport serverTransport,
+						LogDelegate logDelegate)
+			: this(processor, serverTransport, new TTransportFactory(), new TTransportFactory(), new TBinaryProtocol.Factory(), new TBinaryProtocol.Factory(), DefaultLogDelegate)
 		{
 		}
 
@@ -67,7 +77,8 @@
 				 transportFactory,
 				 transportFactory,
 				 new TBinaryProtocol.Factory(),
-				 new TBinaryProtocol.Factory())
+				 new TBinaryProtocol.Factory(),
+				 DefaultLogDelegate)
 		{
 		}
 
@@ -80,7 +91,8 @@
 				 transportFactory,
 				 transportFactory,
 				 protocolFactory,
-				 protocolFactory)
+				 protocolFactory,
+			     DefaultLogDelegate)
 		{
 		}
 
@@ -89,7 +101,8 @@
 						  TTransportFactory inputTransportFactory,
 						  TTransportFactory outputTransportFactory,
 						  TProtocolFactory inputProtocolFactory,
-						  TProtocolFactory outputProtocolFactory)
+						  TProtocolFactory outputProtocolFactory,
+						  LogDelegate logDelegate)
 		{
 			this.processor = processor;
 			this.serverTransport = serverTransport;
@@ -97,6 +110,7 @@
 			this.outputTransportFactory = outputTransportFactory;
 			this.inputProtocolFactory = inputProtocolFactory;
 			this.outputProtocolFactory = outputProtocolFactory;
+			this.logDelegate = logDelegate;
 		}
 
 		/**
@@ -105,6 +119,11 @@
 		public abstract void Serve();
 
 		public abstract void Stop();
+
+		protected static void DefaultLogDelegate(string s)
+		{
+			Console.Error.WriteLine(s);
+		}
 	}
 }