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/TSimpleServer.cs b/lib/csharp/src/Server/TSimpleServer.cs
index 0679bb2..95f3962 100644
--- a/lib/csharp/src/Server/TSimpleServer.cs
+++ b/lib/csharp/src/Server/TSimpleServer.cs
@@ -23,9 +23,17 @@
 	public class TSimpleServer : TServer
 	{
 		private bool stop = false;
+
 		public TSimpleServer(TProcessor processor,
 						  TServerTransport serverTransport)
-			:base(processor, serverTransport, new TTransportFactory(), new TTransportFactory(), new TBinaryProtocol.Factory(), new TBinaryProtocol.Factory())
+			:base(processor, serverTransport, new TTransportFactory(), new TTransportFactory(), new TBinaryProtocol.Factory(), new TBinaryProtocol.Factory(), DefaultLogDelegate)
+		{
+		}
+
+		public TSimpleServer(TProcessor processor,
+							TServerTransport serverTransport,
+							LogDelegate logDel)
+			: base(processor, serverTransport, new TTransportFactory(), new TTransportFactory(), new TBinaryProtocol.Factory(), new TBinaryProtocol.Factory(), logDel)
 		{
 		}
 
@@ -37,7 +45,8 @@
 				 transportFactory,
 				 transportFactory,
 				 new TBinaryProtocol.Factory(),
-				 new TBinaryProtocol.Factory())
+				 new TBinaryProtocol.Factory(),
+			     DefaultLogDelegate)
 		{
 		}
 
@@ -50,7 +59,8 @@
 				 transportFactory,
 				 transportFactory,
 				 protocolFactory,
-				 protocolFactory)
+				 protocolFactory,
+				 DefaultLogDelegate)
 		{
 		}
 
@@ -62,7 +72,7 @@
 			}
 			catch (TTransportException ttx)
 			{
-				Console.Error.WriteLine(ttx);
+				logDelegate(ttx.ToString());
 				return;
 			}
 
@@ -85,13 +95,17 @@
 						while (processor.Process(inputProtocol, outputProtocol)) { }
 					}
 				}
-				catch (TTransportException)
+				catch (TTransportException ttx)
 				{
 					// Client died, just move on
+					if (stop)
+					{
+						logDelegate("TSimpleServer was shutting down, caught " + ttx.GetType().Name);
+					}
 				}
 				catch (Exception x)
 				{
-					Console.Error.WriteLine(x);
+					logDelegate(x.ToString());
 				}
 
 				if (inputTransport != null)
@@ -113,7 +127,7 @@
 				}
 				catch (TTransportException ttx)
 				{
-					Console.Error.WriteLine("TServerTrasnport failed on close: " + ttx.Message);
+					logDelegate("TServerTranport failed on close: " + ttx.Message);
 				}
 				stop = false;
 			}
@@ -122,6 +136,7 @@
 		public override void Stop()
 		{
 			stop = true;
+			serverTransport.Close();
 		}
 	}
 }