THRIFT-2768: Whitespace Fixup
Client: C#, Delphi
Patch: Jens Geyer
diff --git a/lib/csharp/Makefile.am b/lib/csharp/Makefile.am
index 1c75aa1..7b2b618 100644
--- a/lib/csharp/Makefile.am
+++ b/lib/csharp/Makefile.am
@@ -76,15 +76,15 @@
 all-local: Thrift.dll
 
 Thrift.dll: $(THRIFTCODE)
-	$(CSC) $(THRIFTCODE) /out:Thrift.dll /target:library /reference:System.Web $(MONO_DEFINES)
+    $(CSC) $(THRIFTCODE) /out:Thrift.dll /target:library /reference:System.Web $(MONO_DEFINES)
 
 clean-local:
-	$(RM) Thrift.dll
+    $(RM) Thrift.dll
 
 # run csharp tests?
 # check:
-# 	cd test/ThriftTest && ./maketest.sh
-# 	cd test/Multiplex && ./maketest.sh
+#     cd test/ThriftTest && ./maketest.sh
+#     cd test/Multiplex && ./maketest.sh
 
 EXTRA_DIST = \
              $(THRIFTCODE) \
diff --git a/lib/csharp/ThriftMSBuildTask/ThriftBuild.cs b/lib/csharp/ThriftMSBuildTask/ThriftBuild.cs
index 75bb339..4e6d301 100644
--- a/lib/csharp/ThriftMSBuildTask/ThriftBuild.cs
+++ b/lib/csharp/ThriftMSBuildTask/ThriftBuild.cs
@@ -33,214 +33,214 @@
 
 namespace ThriftMSBuildTask
 {
-	/// <summary>
-	/// MSBuild Task to generate csharp from .thrift files, and compile the code into a library: ThriftImpl.dll
-	/// </summary>
-	public class ThriftBuild : Task
-	{
-		/// <summary>
-		/// The full path to the thrift.exe compiler
-		/// </summary>
-		[Required]
-		public ITaskItem ThriftExecutable
-		{
-			get;
-			set;
-		}
+    /// <summary>
+    /// MSBuild Task to generate csharp from .thrift files, and compile the code into a library: ThriftImpl.dll
+    /// </summary>
+    public class ThriftBuild : Task
+    {
+        /// <summary>
+        /// The full path to the thrift.exe compiler
+        /// </summary>
+        [Required]
+        public ITaskItem ThriftExecutable
+        {
+            get;
+            set;
+        }
 
-		/// <summary>
-		/// The full path to a thrift.dll C# library
-		/// </summary>
-		[Required]
-		public ITaskItem ThriftLibrary
-		{
-			get;
-			set;
-		}
+        /// <summary>
+        /// The full path to a thrift.dll C# library
+        /// </summary>
+        [Required]
+        public ITaskItem ThriftLibrary
+        {
+            get;
+            set;
+        }
 
-		/// <summary>
-		/// A direcotry containing .thrift files
-		/// </summary>
-		[Required]
-		public ITaskItem ThriftDefinitionDir
-		{
-			get;
-			set;
-		}
+        /// <summary>
+        /// A direcotry containing .thrift files
+        /// </summary>
+        [Required]
+        public ITaskItem ThriftDefinitionDir
+        {
+            get;
+            set;
+        }
 
-		/// <summary>
-		/// The name of the auto-gen and compiled thrift library. It will placed in
-		/// the same directory as ThriftLibrary
-		/// </summary>
-		[Required]
-		public ITaskItem OutputName
-		{
-			get;
-			set;
-		}
+        /// <summary>
+        /// The name of the auto-gen and compiled thrift library. It will placed in
+        /// the same directory as ThriftLibrary
+        /// </summary>
+        [Required]
+        public ITaskItem OutputName
+        {
+            get;
+            set;
+        }
 
-		/// <summary>
-		/// The full path to the compiled ThriftLibrary. This allows msbuild tasks to use this
-		/// output as a variable for use elsewhere.
-		/// </summary>
-		[Output]
-		public ITaskItem ThriftImplementation
-		{
-			get { return thriftImpl; }
-		}
+        /// <summary>
+        /// The full path to the compiled ThriftLibrary. This allows msbuild tasks to use this
+        /// output as a variable for use elsewhere.
+        /// </summary>
+        [Output]
+        public ITaskItem ThriftImplementation
+        {
+            get { return thriftImpl; }
+        }
 
-		private ITaskItem thriftImpl;
-		private const string lastCompilationName = "LAST_COMP_TIMESTAMP";
+        private ITaskItem thriftImpl;
+        private const string lastCompilationName = "LAST_COMP_TIMESTAMP";
 
-		//use the Message Build Task to write something to build log
-		private void LogMessage(string text, MessageImportance importance)
-		{
-			Message m = new Message();
-			m.Text = text;
-			m.Importance = importance.ToString();
-			m.BuildEngine = this.BuildEngine;
-			m.Execute();
-		}
+        //use the Message Build Task to write something to build log
+        private void LogMessage(string text, MessageImportance importance)
+        {
+            Message m = new Message();
+            m.Text = text;
+            m.Importance = importance.ToString();
+            m.BuildEngine = this.BuildEngine;
+            m.Execute();
+        }
 
-		//recursively find .cs files in srcDir, paths should initially be non-null and empty
-		private void FindSourcesHelper(string srcDir, List<string> paths)
-		{
-			string[] files = Directory.GetFiles(srcDir, "*.cs");
-			foreach (string f in files)
-			{
-				paths.Add(f);
-			}
-			string[] dirs = Directory.GetDirectories(srcDir);
-			foreach (string dir in dirs)
-			{
-				FindSourcesHelper(dir, paths);
-			}
-		}
+        //recursively find .cs files in srcDir, paths should initially be non-null and empty
+        private void FindSourcesHelper(string srcDir, List<string> paths)
+        {
+            string[] files = Directory.GetFiles(srcDir, "*.cs");
+            foreach (string f in files)
+            {
+                paths.Add(f);
+            }
+            string[] dirs = Directory.GetDirectories(srcDir);
+            foreach (string dir in dirs)
+            {
+                FindSourcesHelper(dir, paths);
+            }
+        }
 
-		/// <summary>
-		/// Quote paths with spaces
-		/// </summary>
-		private string SafePath(string path)
-		{
-			if (path.Contains(' ') && !path.StartsWith("\""))
-			{
-				return "\"" + path + "\"";
-			}
-			return path;
-		}
+        /// <summary>
+        /// Quote paths with spaces
+        /// </summary>
+        private string SafePath(string path)
+        {
+            if (path.Contains(' ') && !path.StartsWith("\""))
+            {
+                return "\"" + path + "\"";
+            }
+            return path;
+        }
 
-		private ITaskItem[] FindSources(string srcDir)
-		{
-			List<string> files = new List<string>();
-			FindSourcesHelper(srcDir, files);
-			ITaskItem[] items = new ITaskItem[files.Count];
-			for (int i = 0; i < items.Length; i++)
-			{
-				items[i] = new TaskItem(files[i]);
-			}
-			return items;
-		}
+        private ITaskItem[] FindSources(string srcDir)
+        {
+            List<string> files = new List<string>();
+            FindSourcesHelper(srcDir, files);
+            ITaskItem[] items = new ITaskItem[files.Count];
+            for (int i = 0; i < items.Length; i++)
+            {
+                items[i] = new TaskItem(files[i]);
+            }
+            return items;
+        }
 
-		private string LastWriteTime(string defDir)
-		{
-			string[] files = Directory.GetFiles(defDir, "*.thrift");
-			DateTime d = (new DirectoryInfo(defDir)).LastWriteTime;
-			foreach(string file in files)
-			{
-				FileInfo f = new FileInfo(file);
-				DateTime curr = f.LastWriteTime;
-				if (DateTime.Compare(curr, d) > 0)
-				{
-					d = curr;
-				}
-			}
-			return d.ToFileTimeUtc().ToString();
-		}
+        private string LastWriteTime(string defDir)
+        {
+            string[] files = Directory.GetFiles(defDir, "*.thrift");
+            DateTime d = (new DirectoryInfo(defDir)).LastWriteTime;
+            foreach(string file in files)
+            {
+                FileInfo f = new FileInfo(file);
+                DateTime curr = f.LastWriteTime;
+                if (DateTime.Compare(curr, d) > 0)
+                {
+                    d = curr;
+                }
+            }
+            return d.ToFileTimeUtc().ToString();
+        }
 
-		public override bool Execute()
-		{
-			string defDir = SafePath(ThriftDefinitionDir.ItemSpec);
-			//look for last compilation timestamp
-			string lastBuildPath = Path.Combine(defDir, lastCompilationName);
-			DirectoryInfo defDirInfo = new DirectoryInfo(defDir);
-			string lastWrite = LastWriteTime(defDir);
-			if (File.Exists(lastBuildPath))
-			{
-				string lastComp = File.ReadAllText(lastBuildPath);
-				//don't recompile if the thrift library has been updated since lastComp
-				FileInfo f = new FileInfo(ThriftLibrary.ItemSpec);
-				string thriftLibTime = f.LastWriteTimeUtc.ToFileTimeUtc().ToString();
-				if (lastComp.CompareTo(thriftLibTime) < 0)
-				{
-					//new thrift library, do a compile
-					lastWrite = thriftLibTime;
-				}
-				else if (lastComp == lastWrite || (lastComp == thriftLibTime && lastComp.CompareTo(lastWrite) > 0))
-				{
-					//the .thrift dir hasn't been written to since last compilation, don't need to do anything
-					LogMessage("ThriftImpl up-to-date", MessageImportance.High);
-					return true;
-				}
-			}
+        public override bool Execute()
+        {
+            string defDir = SafePath(ThriftDefinitionDir.ItemSpec);
+            //look for last compilation timestamp
+            string lastBuildPath = Path.Combine(defDir, lastCompilationName);
+            DirectoryInfo defDirInfo = new DirectoryInfo(defDir);
+            string lastWrite = LastWriteTime(defDir);
+            if (File.Exists(lastBuildPath))
+            {
+                string lastComp = File.ReadAllText(lastBuildPath);
+                //don't recompile if the thrift library has been updated since lastComp
+                FileInfo f = new FileInfo(ThriftLibrary.ItemSpec);
+                string thriftLibTime = f.LastWriteTimeUtc.ToFileTimeUtc().ToString();
+                if (lastComp.CompareTo(thriftLibTime) < 0)
+                {
+                    //new thrift library, do a compile
+                    lastWrite = thriftLibTime;
+                }
+                else if (lastComp == lastWrite || (lastComp == thriftLibTime && lastComp.CompareTo(lastWrite) > 0))
+                {
+                    //the .thrift dir hasn't been written to since last compilation, don't need to do anything
+                    LogMessage("ThriftImpl up-to-date", MessageImportance.High);
+                    return true;
+                }
+            }
 
-			//find the directory of the thriftlibrary (that's where output will go)
-			FileInfo thriftLibInfo = new FileInfo(SafePath(ThriftLibrary.ItemSpec));
-			string thriftDir = thriftLibInfo.Directory.FullName;
+            //find the directory of the thriftlibrary (that's where output will go)
+            FileInfo thriftLibInfo = new FileInfo(SafePath(ThriftLibrary.ItemSpec));
+            string thriftDir = thriftLibInfo.Directory.FullName;
 
-			string genDir = Path.Combine(thriftDir, "gen-csharp");
-			if (Directory.Exists(genDir))
-			{
-				try
-				{
-					Directory.Delete(genDir, true);
-				}
-				catch { /*eh i tried, just over-write now*/}
-			}
+            string genDir = Path.Combine(thriftDir, "gen-csharp");
+            if (Directory.Exists(genDir))
+            {
+                try
+                {
+                    Directory.Delete(genDir, true);
+                }
+                catch { /*eh i tried, just over-write now*/}
+            }
 
-			//run the thrift executable to generate C#
-			foreach (string thriftFile in Directory.GetFiles(defDir, "*.thrift"))
-			{
-				LogMessage("Generating code for: " + thriftFile, MessageImportance.Normal);
-				Process p = new Process();
-				p.StartInfo.FileName = SafePath(ThriftExecutable.ItemSpec);
-				p.StartInfo.Arguments = "--gen csharp -o " + SafePath(thriftDir) + " -r " + thriftFile;
-				p.StartInfo.UseShellExecute = false;
-				p.StartInfo.CreateNoWindow = true;
-				p.StartInfo.RedirectStandardOutput = false;
-				p.Start();
-				p.WaitForExit();
-				if (p.ExitCode != 0)
-				{
-					LogMessage("thrift.exe failed to compile " + thriftFile, MessageImportance.High);
-					return false;
-				}
-				if (p.ExitCode != 0)
-				{
-					LogMessage("thrift.exe failed to compile " + thriftFile, MessageImportance.High);
-					return false;
-				}
-			}
+            //run the thrift executable to generate C#
+            foreach (string thriftFile in Directory.GetFiles(defDir, "*.thrift"))
+            {
+                LogMessage("Generating code for: " + thriftFile, MessageImportance.Normal);
+                Process p = new Process();
+                p.StartInfo.FileName = SafePath(ThriftExecutable.ItemSpec);
+                p.StartInfo.Arguments = "--gen csharp -o " + SafePath(thriftDir) + " -r " + thriftFile;
+                p.StartInfo.UseShellExecute = false;
+                p.StartInfo.CreateNoWindow = true;
+                p.StartInfo.RedirectStandardOutput = false;
+                p.Start();
+                p.WaitForExit();
+                if (p.ExitCode != 0)
+                {
+                    LogMessage("thrift.exe failed to compile " + thriftFile, MessageImportance.High);
+                    return false;
+                }
+                if (p.ExitCode != 0)
+                {
+                    LogMessage("thrift.exe failed to compile " + thriftFile, MessageImportance.High);
+                    return false;
+                }
+            }
 
-			Csc csc = new Csc();
-			csc.TargetType = "library";
-			csc.References = new ITaskItem[] { new TaskItem(ThriftLibrary.ItemSpec) };
-			csc.EmitDebugInformation = true;
-			string outputPath = Path.Combine(thriftDir, OutputName.ItemSpec);
-			csc.OutputAssembly = new TaskItem(outputPath);
-			csc.Sources = FindSources(Path.Combine(thriftDir, "gen-csharp"));
-			csc.BuildEngine = this.BuildEngine;
-			LogMessage("Compiling generated cs...", MessageImportance.Normal);
-			if (!csc.Execute())
-			{
-				return false;
-			}
+            Csc csc = new Csc();
+            csc.TargetType = "library";
+            csc.References = new ITaskItem[] { new TaskItem(ThriftLibrary.ItemSpec) };
+            csc.EmitDebugInformation = true;
+            string outputPath = Path.Combine(thriftDir, OutputName.ItemSpec);
+            csc.OutputAssembly = new TaskItem(outputPath);
+            csc.Sources = FindSources(Path.Combine(thriftDir, "gen-csharp"));
+            csc.BuildEngine = this.BuildEngine;
+            LogMessage("Compiling generated cs...", MessageImportance.Normal);
+            if (!csc.Execute())
+            {
+                return false;
+            }
 
-			//write file to defDir to indicate a build was successfully completed
-			File.WriteAllText(lastBuildPath, lastWrite);
+            //write file to defDir to indicate a build was successfully completed
+            File.WriteAllText(lastBuildPath, lastWrite);
 
-			thriftImpl = new TaskItem(outputPath);
+            thriftImpl = new TaskItem(outputPath);
 
-			return true;
-		}
-	}
+            return true;
+        }
+    }
 }
diff --git a/lib/csharp/src/Collections/TCollections.cs b/lib/csharp/src/Collections/TCollections.cs
index 23fd8da..f0bb1de 100644
--- a/lib/csharp/src/Collections/TCollections.cs
+++ b/lib/csharp/src/Collections/TCollections.cs
@@ -21,74 +21,74 @@
 
 namespace Thrift.Collections
 {
-	public class TCollections
-	{
-		/// <summary>
-		/// This will return true if the two collections are value-wise the same.
-		/// If the collection contains a collection, the collections will be compared using this method.
-		/// </summary>
-		public static bool Equals (IEnumerable first, IEnumerable second)
-		{
-			if (first == null && second == null)
-			{
-				return true;
-			}
-			if (first == null || second == null)
-			{
-				return false;
-			}
-			IEnumerator fiter = first.GetEnumerator ();
-			IEnumerator siter = second.GetEnumerator ();
+    public class TCollections
+    {
+        /// <summary>
+        /// This will return true if the two collections are value-wise the same.
+        /// If the collection contains a collection, the collections will be compared using this method.
+        /// </summary>
+        public static bool Equals (IEnumerable first, IEnumerable second)
+        {
+            if (first == null && second == null)
+            {
+                return true;
+            }
+            if (first == null || second == null)
+            {
+                return false;
+            }
+            IEnumerator fiter = first.GetEnumerator ();
+            IEnumerator siter = second.GetEnumerator ();
 
-			bool fnext = fiter.MoveNext ();
-			bool snext = siter.MoveNext ();
-			while (fnext && snext)
-			{
-				IEnumerable fenum = fiter.Current as IEnumerable;
-				IEnumerable senum = siter.Current as IEnumerable;
-				if (fenum != null && senum != null)
-				{
-					if (!Equals(fenum, senum))
-					{
-						return false;
-					}
-				}
-				else if (fenum == null ^ senum == null)
-				{
-					return false;
-				}
-				else if (!Equals(fiter.Current, siter.Current))
-				{
-					return false;
-				}
-				fnext = fiter.MoveNext();
-				snext = siter.MoveNext();
-			}
+            bool fnext = fiter.MoveNext ();
+            bool snext = siter.MoveNext ();
+            while (fnext && snext)
+            {
+                IEnumerable fenum = fiter.Current as IEnumerable;
+                IEnumerable senum = siter.Current as IEnumerable;
+                if (fenum != null && senum != null)
+                {
+                    if (!Equals(fenum, senum))
+                    {
+                        return false;
+                    }
+                }
+                else if (fenum == null ^ senum == null)
+                {
+                    return false;
+                }
+                else if (!Equals(fiter.Current, siter.Current))
+                {
+                    return false;
+                }
+                fnext = fiter.MoveNext();
+                snext = siter.MoveNext();
+            }
 
-			return fnext == snext;
-		}
+            return fnext == snext;
+        }
 
-		/// <summary>
-		/// This returns a hashcode based on the value of the enumerable.
-		/// </summary>
-		public static int GetHashCode (IEnumerable enumerable)
-		{
-			if (enumerable == null)
-			{
-				return 0;
-			}
+        /// <summary>
+        /// This returns a hashcode based on the value of the enumerable.
+        /// </summary>
+        public static int GetHashCode (IEnumerable enumerable)
+        {
+            if (enumerable == null)
+            {
+                return 0;
+            }
 
-			int hashcode = 0;
-			foreach (Object obj in enumerable)
-			{
-				IEnumerable enum2 = obj as IEnumerable;
-				int objHash = enum2 == null ? obj.GetHashCode () : GetHashCode (enum2);
-				unchecked
-				{
-					hashcode = (hashcode * 397) ^ (objHash);
-				}
-			}
-			return hashcode;
-		}
-	}
+            int hashcode = 0;
+            foreach (Object obj in enumerable)
+            {
+                IEnumerable enum2 = obj as IEnumerable;
+                int objHash = enum2 == null ? obj.GetHashCode () : GetHashCode (enum2);
+                unchecked
+                {
+                    hashcode = (hashcode * 397) ^ (objHash);
+                }
+            }
+            return hashcode;
+        }
+    }
 }
\ No newline at end of file
diff --git a/lib/csharp/src/Collections/THashSet.cs b/lib/csharp/src/Collections/THashSet.cs
index b71a8d2..e29271a 100644
--- a/lib/csharp/src/Collections/THashSet.cs
+++ b/lib/csharp/src/Collections/THashSet.cs
@@ -30,131 +30,131 @@
 #if SILVERLIGHT
     [DataContract]
 #else
-	[Serializable]
+    [Serializable]
 #endif
-	public class THashSet<T> : ICollection<T>
-	{
+    public class THashSet<T> : ICollection<T>
+    {
 #if NET_2_0 || SILVERLIGHT
 #if SILVERLIGHT
         [DataMember]
 #endif
         TDictSet<T> set = new TDictSet<T>();
 #else
-		HashSet<T> set = new HashSet<T>();
+        HashSet<T> set = new HashSet<T>();
 #endif
-		public int Count
-		{
-			get { return set.Count; }
-		}
+        public int Count
+        {
+            get { return set.Count; }
+        }
 
-		public bool IsReadOnly
-		{
-			get { return false; }
-		}
+        public bool IsReadOnly
+        {
+            get { return false; }
+        }
 
-		public void Add(T item)
-		{
-			set.Add(item);
-		}
+        public void Add(T item)
+        {
+            set.Add(item);
+        }
 
-		public void Clear()
-		{
-			set.Clear();
-		}
+        public void Clear()
+        {
+            set.Clear();
+        }
 
-		public bool Contains(T item)
-		{
-			return set.Contains(item);
-		}
+        public bool Contains(T item)
+        {
+            return set.Contains(item);
+        }
 
-		public void CopyTo(T[] array, int arrayIndex)
-		{
-			set.CopyTo(array, arrayIndex);
-		}
+        public void CopyTo(T[] array, int arrayIndex)
+        {
+            set.CopyTo(array, arrayIndex);
+        }
 
-		public IEnumerator GetEnumerator()
-		{
-			return set.GetEnumerator();
-		}
+        public IEnumerator GetEnumerator()
+        {
+            return set.GetEnumerator();
+        }
 
-		IEnumerator<T> IEnumerable<T>.GetEnumerator()
-		{
-			return ((IEnumerable<T>)set).GetEnumerator();
-		}
+        IEnumerator<T> IEnumerable<T>.GetEnumerator()
+        {
+            return ((IEnumerable<T>)set).GetEnumerator();
+        }
 
-		public bool Remove(T item)
-		{
-			return set.Remove(item);
-		}
+        public bool Remove(T item)
+        {
+            return set.Remove(item);
+        }
 
 #if NET_2_0 || SILVERLIGHT
 #if SILVERLIGHT
         [DataContract]
 #endif
         private class TDictSet<V> : ICollection<V>
-		{
+        {
 #if SILVERLIGHT
             [DataMember]
 #endif
-			Dictionary<V, TDictSet<V>> dict = new Dictionary<V, TDictSet<V>>();
+            Dictionary<V, TDictSet<V>> dict = new Dictionary<V, TDictSet<V>>();
 
-			public int Count
-			{
-				get { return dict.Count; }
-			}
+            public int Count
+            {
+                get { return dict.Count; }
+            }
 
-			public bool IsReadOnly
-			{
-				get { return false; }
-			}
+            public bool IsReadOnly
+            {
+                get { return false; }
+            }
 
-			public IEnumerator GetEnumerator()
-			{
-				return ((IEnumerable)dict.Keys).GetEnumerator();
-			}
+            public IEnumerator GetEnumerator()
+            {
+                return ((IEnumerable)dict.Keys).GetEnumerator();
+            }
 
-			IEnumerator<V> IEnumerable<V>.GetEnumerator()
-			{
-				return dict.Keys.GetEnumerator();
-			}
+            IEnumerator<V> IEnumerable<V>.GetEnumerator()
+            {
+                return dict.Keys.GetEnumerator();
+            }
 
-			public bool Add(V item)
-			{
-				if (!dict.ContainsKey(item))
-				{
-					dict[item] = this;
-					return true;
-				}
+            public bool Add(V item)
+            {
+                if (!dict.ContainsKey(item))
+                {
+                    dict[item] = this;
+                    return true;
+                }
 
-				return false;
-			}
+                return false;
+            }
 
-			void ICollection<V>.Add(V item)
-			{
-				Add(item);
-			}
+            void ICollection<V>.Add(V item)
+            {
+                Add(item);
+            }
 
-			public void Clear()
-			{
-				dict.Clear();
-			}
+            public void Clear()
+            {
+                dict.Clear();
+            }
 
-			public bool Contains(V item)
-			{
-				return dict.ContainsKey(item);
-			}
+            public bool Contains(V item)
+            {
+                return dict.ContainsKey(item);
+            }
 
-			public void CopyTo(V[] array, int arrayIndex)
-			{
-				dict.Keys.CopyTo(array, arrayIndex);
-			}
+            public void CopyTo(V[] array, int arrayIndex)
+            {
+                dict.Keys.CopyTo(array, arrayIndex);
+            }
 
-			public bool Remove(V item)
-			{
-				return dict.Remove(item);
-			}
-		}
+            public bool Remove(V item)
+            {
+                return dict.Remove(item);
+            }
+        }
 #endif
-	}
+    }
 
 }
diff --git a/lib/csharp/src/Protocol/TAbstractBase.cs b/lib/csharp/src/Protocol/TAbstractBase.cs
index de2e3db..c0d5abe 100644
--- a/lib/csharp/src/Protocol/TAbstractBase.cs
+++ b/lib/csharp/src/Protocol/TAbstractBase.cs
@@ -19,11 +19,11 @@
 
 namespace Thrift.Protocol
 {
-	public interface TAbstractBase
-	{
-		///
-		/// Writes the objects out to the protocol
-		///
-		void Write(TProtocol tProtocol);
-	}
+    public interface TAbstractBase
+    {
+        ///
+        /// Writes the objects out to the protocol
+        ///
+        void Write(TProtocol tProtocol);
+    }
 }
diff --git a/lib/csharp/src/Protocol/TBase.cs b/lib/csharp/src/Protocol/TBase.cs
index b8b36fb..350ff49 100644
--- a/lib/csharp/src/Protocol/TBase.cs
+++ b/lib/csharp/src/Protocol/TBase.cs
@@ -19,11 +19,11 @@
 
 namespace Thrift.Protocol
 {
-	public interface TBase : TAbstractBase
-	{
-		///
-		/// Reads the TObject from the given input protocol.
-		///
-		void Read(TProtocol tProtocol);
-	}
+    public interface TBase : TAbstractBase
+    {
+        ///
+        /// Reads the TObject from the given input protocol.
+        ///
+        void Read(TProtocol tProtocol);
+    }
 }
diff --git a/lib/csharp/src/Protocol/TBase64Utils.cs b/lib/csharp/src/Protocol/TBase64Utils.cs
index 78c3767..9eaaebd 100644
--- a/lib/csharp/src/Protocol/TBase64Utils.cs
+++ b/lib/csharp/src/Protocol/TBase64Utils.cs
@@ -21,80 +21,80 @@
 
 namespace Thrift.Protocol
 {
-	internal static class TBase64Utils
-	{
-		internal const string ENCODE_TABLE =
-			"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+    internal static class TBase64Utils
+    {
+        internal const string ENCODE_TABLE =
+            "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
 
-		internal static void encode(byte[] src, int srcOff, int len, byte[] dst,
-								int dstOff)
-		{
-			dst[dstOff] = (byte)ENCODE_TABLE[(src[srcOff] >> 2) & 0x3F];
-			if (len == 3)
-			{
-				dst[dstOff + 1] =
-					(byte)ENCODE_TABLE[
-						((src[srcOff] << 4) & 0x30) | ((src[srcOff + 1] >> 4) & 0x0F)];
-				dst[dstOff + 2] =
-					(byte)ENCODE_TABLE[
-						((src[srcOff + 1] << 2) & 0x3C) | ((src[srcOff + 2] >> 6) & 0x03)];
-				dst[dstOff + 3] =
-					(byte)ENCODE_TABLE[src[srcOff + 2] & 0x3F];
-			}
-			else if (len == 2)
-			{
-				dst[dstOff + 1] =
-					(byte)ENCODE_TABLE[
-						((src[srcOff] << 4) & 0x30) | ((src[srcOff + 1] >> 4) & 0x0F)];
-				dst[dstOff + 2] =
-					(byte)ENCODE_TABLE[(src[srcOff + 1] << 2) & 0x3C];
+        internal static void encode(byte[] src, int srcOff, int len, byte[] dst,
+                                int dstOff)
+        {
+            dst[dstOff] = (byte)ENCODE_TABLE[(src[srcOff] >> 2) & 0x3F];
+            if (len == 3)
+            {
+                dst[dstOff + 1] =
+                    (byte)ENCODE_TABLE[
+                        ((src[srcOff] << 4) & 0x30) | ((src[srcOff + 1] >> 4) & 0x0F)];
+                dst[dstOff + 2] =
+                    (byte)ENCODE_TABLE[
+                        ((src[srcOff + 1] << 2) & 0x3C) | ((src[srcOff + 2] >> 6) & 0x03)];
+                dst[dstOff + 3] =
+                    (byte)ENCODE_TABLE[src[srcOff + 2] & 0x3F];
+            }
+            else if (len == 2)
+            {
+                dst[dstOff + 1] =
+                    (byte)ENCODE_TABLE[
+                        ((src[srcOff] << 4) & 0x30) | ((src[srcOff + 1] >> 4) & 0x0F)];
+                dst[dstOff + 2] =
+                    (byte)ENCODE_TABLE[(src[srcOff + 1] << 2) & 0x3C];
 
-			}
-			else
-			{ // len == 1) {
-				dst[dstOff + 1] =
-					(byte)ENCODE_TABLE[(src[srcOff] << 4) & 0x30];
-			}
-		}
+            }
+            else
+            { // len == 1) {
+                dst[dstOff + 1] =
+                    (byte)ENCODE_TABLE[(src[srcOff] << 4) & 0x30];
+            }
+        }
 
-		private static int[] DECODE_TABLE = {
-			-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-			-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-			-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,
-			52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1,
-			-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,
-			15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,
-			-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,
-			41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1,
-			-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-			-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-			-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-			-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-			-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-			-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-			-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-			-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-		};
+        private static int[] DECODE_TABLE = {
+            -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+            -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+            -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,
+            52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1,
+            -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,
+            15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,
+            -1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,
+            41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1,
+            -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+            -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+            -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+            -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+            -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+            -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+            -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+            -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+        };
 
-		internal static void decode(byte[] src, int srcOff, int len, byte[] dst,
-								 int dstOff)
-		{
-			dst[dstOff] = (byte)
-				((DECODE_TABLE[src[srcOff] & 0x0FF] << 2) |
-				(DECODE_TABLE[src[srcOff + 1] & 0x0FF] >> 4));
-			if (len > 2)
-			{
-				dst[dstOff + 1] = (byte)
-					(((DECODE_TABLE[src[srcOff + 1] & 0x0FF] << 4) & 0xF0) |
-					(DECODE_TABLE[src[srcOff + 2] & 0x0FF] >> 2));
-				if (len > 3)
-				{
-					dst[dstOff + 2] = (byte)
-						(((DECODE_TABLE[src[srcOff + 2] & 0x0FF] << 6) & 0xC0) |
-						DECODE_TABLE[src[srcOff + 3] & 0x0FF]);
-				}
-			}
-		}
+        internal static void decode(byte[] src, int srcOff, int len, byte[] dst,
+                                 int dstOff)
+        {
+            dst[dstOff] = (byte)
+                ((DECODE_TABLE[src[srcOff] & 0x0FF] << 2) |
+                (DECODE_TABLE[src[srcOff + 1] & 0x0FF] >> 4));
+            if (len > 2)
+            {
+                dst[dstOff + 1] = (byte)
+                    (((DECODE_TABLE[src[srcOff + 1] & 0x0FF] << 4) & 0xF0) |
+                    (DECODE_TABLE[src[srcOff + 2] & 0x0FF] >> 2));
+                if (len > 3)
+                {
+                    dst[dstOff + 2] = (byte)
+                        (((DECODE_TABLE[src[srcOff + 2] & 0x0FF] << 6) & 0xC0) |
+                        DECODE_TABLE[src[srcOff + 3] & 0x0FF]);
+                }
+            }
+        }
 
-	}
+    }
 }
diff --git a/lib/csharp/src/Protocol/TBinaryProtocol.cs b/lib/csharp/src/Protocol/TBinaryProtocol.cs
index 2e86a70..4eceb86 100644
--- a/lib/csharp/src/Protocol/TBinaryProtocol.cs
+++ b/lib/csharp/src/Protocol/TBinaryProtocol.cs
@@ -27,324 +27,324 @@
 
 namespace Thrift.Protocol
 {
-	public class TBinaryProtocol : TProtocol
-	{
-		protected const uint VERSION_MASK = 0xffff0000;
-		protected const uint VERSION_1 = 0x80010000;
+    public class TBinaryProtocol : TProtocol
+    {
+        protected const uint VERSION_MASK = 0xffff0000;
+        protected const uint VERSION_1 = 0x80010000;
 
-		protected bool strictRead_ = false;
-		protected bool strictWrite_ = true;
+        protected bool strictRead_ = false;
+        protected bool strictWrite_ = true;
 
-		#region BinaryProtocol Factory
-		 /**
-		  * Factory
-		  */
-		  public class Factory : TProtocolFactory {
+        #region BinaryProtocol Factory
+         /**
+          * Factory
+          */
+          public class Factory : TProtocolFactory {
 
-			  protected bool strictRead_ = false;
-			  protected bool strictWrite_ = true;
+              protected bool strictRead_ = false;
+              protected bool strictWrite_ = true;
 
-			  public Factory()
-				  :this(false, true)
-			  {
-			  }
+              public Factory()
+                  :this(false, true)
+              {
+              }
 
-			  public Factory(bool strictRead, bool strictWrite)
-			  {
-				  strictRead_ = strictRead;
-				  strictWrite_ = strictWrite;
-			  }
+              public Factory(bool strictRead, bool strictWrite)
+              {
+                  strictRead_ = strictRead;
+                  strictWrite_ = strictWrite;
+              }
 
-			public TProtocol GetProtocol(TTransport trans) {
-			  return new TBinaryProtocol(trans, strictRead_, strictWrite_);
-			}
-		  }
+            public TProtocol GetProtocol(TTransport trans) {
+              return new TBinaryProtocol(trans, strictRead_, strictWrite_);
+            }
+          }
 
-		#endregion
+        #endregion
 
-		public TBinaryProtocol(TTransport trans)
-			: this(trans, false, true)
-		{
-		}
+        public TBinaryProtocol(TTransport trans)
+            : this(trans, false, true)
+        {
+        }
 
-		public TBinaryProtocol(TTransport trans, bool strictRead, bool strictWrite)
-			:base(trans)
-		{
-			strictRead_ = strictRead;
-			strictWrite_ = strictWrite;
-		}
+        public TBinaryProtocol(TTransport trans, bool strictRead, bool strictWrite)
+            :base(trans)
+        {
+            strictRead_ = strictRead;
+            strictWrite_ = strictWrite;
+        }
 
-		#region Write Methods
+        #region Write Methods
 
-		public override void WriteMessageBegin(TMessage message)
-		{
-			if (strictWrite_)
-			{
-				uint version = VERSION_1 | (uint)(message.Type);
-				WriteI32((int)version);
-				WriteString(message.Name);
-				WriteI32(message.SeqID);
-			}
-			else
-			{
-				WriteString(message.Name);
-				WriteByte((sbyte)message.Type);
-				WriteI32(message.SeqID);
-			}
-		}
+        public override void WriteMessageBegin(TMessage message)
+        {
+            if (strictWrite_)
+            {
+                uint version = VERSION_1 | (uint)(message.Type);
+                WriteI32((int)version);
+                WriteString(message.Name);
+                WriteI32(message.SeqID);
+            }
+            else
+            {
+                WriteString(message.Name);
+                WriteByte((sbyte)message.Type);
+                WriteI32(message.SeqID);
+            }
+        }
 
-		public override void WriteMessageEnd()
-		{
-		}
+        public override void WriteMessageEnd()
+        {
+        }
 
-		public override void WriteStructBegin(TStruct struc)
-		{
-		}
+        public override void WriteStructBegin(TStruct struc)
+        {
+        }
 
-		public override void WriteStructEnd()
-		{
-		}
+        public override void WriteStructEnd()
+        {
+        }
 
-		public override void WriteFieldBegin(TField field)
-		{
-			WriteByte((sbyte)field.Type);
-			WriteI16(field.ID);
-		}
+        public override void WriteFieldBegin(TField field)
+        {
+            WriteByte((sbyte)field.Type);
+            WriteI16(field.ID);
+        }
 
-		public override void WriteFieldEnd()
-		{
-		}
+        public override void WriteFieldEnd()
+        {
+        }
 
-		public override void WriteFieldStop()
-		{
-			WriteByte((sbyte)TType.Stop);
-		}
+        public override void WriteFieldStop()
+        {
+            WriteByte((sbyte)TType.Stop);
+        }
 
-		public override void WriteMapBegin(TMap map)
-		{
-			WriteByte((sbyte)map.KeyType);
-			WriteByte((sbyte)map.ValueType);
-			WriteI32(map.Count);
-		}
+        public override void WriteMapBegin(TMap map)
+        {
+            WriteByte((sbyte)map.KeyType);
+            WriteByte((sbyte)map.ValueType);
+            WriteI32(map.Count);
+        }
 
-		public override void WriteMapEnd()
-		{
-		}
+        public override void WriteMapEnd()
+        {
+        }
 
-		public override void WriteListBegin(TList list)
-		{
-			WriteByte((sbyte)list.ElementType);
-			WriteI32(list.Count);
-		}
+        public override void WriteListBegin(TList list)
+        {
+            WriteByte((sbyte)list.ElementType);
+            WriteI32(list.Count);
+        }
 
-		public override void WriteListEnd()
-		{
-		}
+        public override void WriteListEnd()
+        {
+        }
 
-		public override void WriteSetBegin(TSet set)
-		{
-			WriteByte((sbyte)set.ElementType);
-			WriteI32(set.Count);
-		}
+        public override void WriteSetBegin(TSet set)
+        {
+            WriteByte((sbyte)set.ElementType);
+            WriteI32(set.Count);
+        }
 
-		public override void WriteSetEnd()
-		{
-		}
+        public override void WriteSetEnd()
+        {
+        }
 
-		public override void WriteBool(bool b)
-		{
-			WriteByte(b ? (sbyte)1 : (sbyte)0);
-		}
+        public override void WriteBool(bool b)
+        {
+            WriteByte(b ? (sbyte)1 : (sbyte)0);
+        }
 
-		private byte[] bout = new byte[1];
-		public override void WriteByte(sbyte b)
-		{
-			bout[0] = (byte)b;
-			trans.Write(bout, 0, 1);
-		}
+        private byte[] bout = new byte[1];
+        public override void WriteByte(sbyte b)
+        {
+            bout[0] = (byte)b;
+            trans.Write(bout, 0, 1);
+        }
 
-		private byte[] i16out = new byte[2];
-		public override void WriteI16(short s)
-		{
-			i16out[0] = (byte)(0xff & (s >> 8));
-			i16out[1] = (byte)(0xff & s);
-			trans.Write(i16out, 0, 2);
-		}
+        private byte[] i16out = new byte[2];
+        public override void WriteI16(short s)
+        {
+            i16out[0] = (byte)(0xff & (s >> 8));
+            i16out[1] = (byte)(0xff & s);
+            trans.Write(i16out, 0, 2);
+        }
 
-		private byte[] i32out = new byte[4];
-		public override void WriteI32(int i32)
-		{
-			i32out[0] = (byte)(0xff & (i32 >> 24));
-			i32out[1] = (byte)(0xff & (i32 >> 16));
-			i32out[2] = (byte)(0xff & (i32 >> 8));
-			i32out[3] = (byte)(0xff & i32);
-			trans.Write(i32out, 0, 4);
-		}
+        private byte[] i32out = new byte[4];
+        public override void WriteI32(int i32)
+        {
+            i32out[0] = (byte)(0xff & (i32 >> 24));
+            i32out[1] = (byte)(0xff & (i32 >> 16));
+            i32out[2] = (byte)(0xff & (i32 >> 8));
+            i32out[3] = (byte)(0xff & i32);
+            trans.Write(i32out, 0, 4);
+        }
 
-		private byte[] i64out = new byte[8];
-		public override void WriteI64(long i64)
-		{
-			i64out[0] = (byte)(0xff & (i64 >> 56));
-			i64out[1] = (byte)(0xff & (i64 >> 48));
-			i64out[2] = (byte)(0xff & (i64 >> 40));
-			i64out[3] = (byte)(0xff & (i64 >> 32));
-			i64out[4] = (byte)(0xff & (i64 >> 24));
-			i64out[5] = (byte)(0xff & (i64 >> 16));
-			i64out[6] = (byte)(0xff & (i64 >> 8));
-			i64out[7] = (byte)(0xff & i64);
-			trans.Write(i64out, 0, 8);
-		}
+        private byte[] i64out = new byte[8];
+        public override void WriteI64(long i64)
+        {
+            i64out[0] = (byte)(0xff & (i64 >> 56));
+            i64out[1] = (byte)(0xff & (i64 >> 48));
+            i64out[2] = (byte)(0xff & (i64 >> 40));
+            i64out[3] = (byte)(0xff & (i64 >> 32));
+            i64out[4] = (byte)(0xff & (i64 >> 24));
+            i64out[5] = (byte)(0xff & (i64 >> 16));
+            i64out[6] = (byte)(0xff & (i64 >> 8));
+            i64out[7] = (byte)(0xff & i64);
+            trans.Write(i64out, 0, 8);
+        }
 
-		public override void WriteDouble(double d)
-		{
+        public override void WriteDouble(double d)
+        {
 #if !SILVERLIGHT
-			WriteI64(BitConverter.DoubleToInt64Bits(d));
+            WriteI64(BitConverter.DoubleToInt64Bits(d));
 #else
             var bytes = BitConverter.GetBytes(d);
             WriteI64(BitConverter.ToInt64(bytes, 0));
 #endif
-		}
+        }
 
-		public override void WriteBinary(byte[] b)
-		{
-			WriteI32(b.Length);
-			trans.Write(b, 0, b.Length);
-		}
+        public override void WriteBinary(byte[] b)
+        {
+            WriteI32(b.Length);
+            trans.Write(b, 0, b.Length);
+        }
 
-		#endregion
+        #endregion
 
-		#region ReadMethods
+        #region ReadMethods
 
-		public override TMessage ReadMessageBegin()
-		{
-			TMessage message = new TMessage();
-			int size = ReadI32();
-			if (size < 0)
-			{
-				uint version = (uint)size & VERSION_MASK;
-				if (version != VERSION_1)
-				{
-					throw new TProtocolException(TProtocolException.BAD_VERSION, "Bad version in ReadMessageBegin: " + version);
-				}
-				message.Type = (TMessageType)(size & 0x000000ff);
-				message.Name = ReadString();
-				message.SeqID = ReadI32();
-			}
-			else
-			{
-				if (strictRead_)
-				{
-					throw new TProtocolException(TProtocolException.BAD_VERSION, "Missing version in readMessageBegin, old client?");
-				}
-				message.Name = ReadStringBody(size);
-				message.Type = (TMessageType)ReadByte();
-				message.SeqID = ReadI32();
-			}
-			return message;
-		}
+        public override TMessage ReadMessageBegin()
+        {
+            TMessage message = new TMessage();
+            int size = ReadI32();
+            if (size < 0)
+            {
+                uint version = (uint)size & VERSION_MASK;
+                if (version != VERSION_1)
+                {
+                    throw new TProtocolException(TProtocolException.BAD_VERSION, "Bad version in ReadMessageBegin: " + version);
+                }
+                message.Type = (TMessageType)(size & 0x000000ff);
+                message.Name = ReadString();
+                message.SeqID = ReadI32();
+            }
+            else
+            {
+                if (strictRead_)
+                {
+                    throw new TProtocolException(TProtocolException.BAD_VERSION, "Missing version in readMessageBegin, old client?");
+                }
+                message.Name = ReadStringBody(size);
+                message.Type = (TMessageType)ReadByte();
+                message.SeqID = ReadI32();
+            }
+            return message;
+        }
 
-		public override void ReadMessageEnd()
-		{
-		}
+        public override void ReadMessageEnd()
+        {
+        }
 
-		public override TStruct ReadStructBegin()
-		{
-			return new TStruct();
-		}
+        public override TStruct ReadStructBegin()
+        {
+            return new TStruct();
+        }
 
-		public override void ReadStructEnd()
-		{
-		}
+        public override void ReadStructEnd()
+        {
+        }
 
-		public override TField ReadFieldBegin()
-		{
-			TField field = new TField();
-			field.Type = (TType)ReadByte();
+        public override TField ReadFieldBegin()
+        {
+            TField field = new TField();
+            field.Type = (TType)ReadByte();
 
-			if (field.Type != TType.Stop)
-			{
-				field.ID = ReadI16();
-			}
+            if (field.Type != TType.Stop)
+            {
+                field.ID = ReadI16();
+            }
 
-			return field;
-		}
+            return field;
+        }
 
-		public override void ReadFieldEnd()
-		{
-		}
+        public override void ReadFieldEnd()
+        {
+        }
 
-		public override TMap ReadMapBegin()
-		{
-			TMap map = new TMap();
-			map.KeyType = (TType)ReadByte();
-			map.ValueType = (TType)ReadByte();
-			map.Count = ReadI32();
+        public override TMap ReadMapBegin()
+        {
+            TMap map = new TMap();
+            map.KeyType = (TType)ReadByte();
+            map.ValueType = (TType)ReadByte();
+            map.Count = ReadI32();
 
-			return map;
-		}
+            return map;
+        }
 
-		public override void ReadMapEnd()
-		{
-		}
+        public override void ReadMapEnd()
+        {
+        }
 
-		public override TList ReadListBegin()
-		{
-			TList list = new TList();
-			list.ElementType = (TType)ReadByte();
-			list.Count = ReadI32();
+        public override TList ReadListBegin()
+        {
+            TList list = new TList();
+            list.ElementType = (TType)ReadByte();
+            list.Count = ReadI32();
 
-			return list;
-		}
+            return list;
+        }
 
-		public override void ReadListEnd()
-		{
-		}
+        public override void ReadListEnd()
+        {
+        }
 
-		public override TSet ReadSetBegin()
-		{
-			TSet set = new TSet();
-			set.ElementType = (TType)ReadByte();
-			set.Count = ReadI32();
+        public override TSet ReadSetBegin()
+        {
+            TSet set = new TSet();
+            set.ElementType = (TType)ReadByte();
+            set.Count = ReadI32();
 
-			return set;
-		}
+            return set;
+        }
 
-		public override void ReadSetEnd()
-		{
-		}
+        public override void ReadSetEnd()
+        {
+        }
 
-		public override bool ReadBool()
-		{
-			return ReadByte() == 1;
-		}
+        public override bool ReadBool()
+        {
+            return ReadByte() == 1;
+        }
 
-		private byte[] bin = new byte[1];
-		public override sbyte ReadByte()
-		{
-			ReadAll(bin, 0, 1);
-			return (sbyte)bin[0];
-		}
+        private byte[] bin = new byte[1];
+        public override sbyte ReadByte()
+        {
+            ReadAll(bin, 0, 1);
+            return (sbyte)bin[0];
+        }
 
-		private byte[] i16in = new byte[2];
-		public override short ReadI16()
-		{
-			ReadAll(i16in, 0, 2);
-			return (short)(((i16in[0] & 0xff) << 8) | ((i16in[1] & 0xff)));
-		}
+        private byte[] i16in = new byte[2];
+        public override short ReadI16()
+        {
+            ReadAll(i16in, 0, 2);
+            return (short)(((i16in[0] & 0xff) << 8) | ((i16in[1] & 0xff)));
+        }
 
-		private byte[] i32in = new byte[4];
-		public override int ReadI32()
-		{
-			ReadAll(i32in, 0, 4);
-			return (int)(((i32in[0] & 0xff) << 24) | ((i32in[1] & 0xff) << 16) | ((i32in[2] & 0xff) << 8) | ((i32in[3] & 0xff)));
-		}
+        private byte[] i32in = new byte[4];
+        public override int ReadI32()
+        {
+            ReadAll(i32in, 0, 4);
+            return (int)(((i32in[0] & 0xff) << 24) | ((i32in[1] & 0xff) << 16) | ((i32in[2] & 0xff) << 8) | ((i32in[3] & 0xff)));
+        }
 
 #pragma warning disable 675
 
         private byte[] i64in = new byte[8];
-		public override long ReadI64()
-		{
-			ReadAll(i64in, 0, 8);
+        public override long ReadI64()
+        {
+            ReadAll(i64in, 0, 8);
             unchecked {
               return (long)(
                   ((long)(i64in[0] & 0xff) << 56) |
@@ -361,35 +361,35 @@
 #pragma warning restore 675
 
         public override double ReadDouble()
-		{
+        {
 #if !SILVERLIGHT
-			return BitConverter.Int64BitsToDouble(ReadI64());
+            return BitConverter.Int64BitsToDouble(ReadI64());
 #else
             var value = ReadI64();
             var bytes = BitConverter.GetBytes(value);
             return BitConverter.ToDouble(bytes, 0);
 #endif
-		}
+        }
 
-		public override byte[] ReadBinary()
-		{
-			int size = ReadI32();
-			byte[] buf = new byte[size];
-			trans.ReadAll(buf, 0, size);
-			return buf;
-		}
-		private  string ReadStringBody(int size)
-		{
-			byte[] buf = new byte[size];
-			trans.ReadAll(buf, 0, size);
-			return Encoding.UTF8.GetString(buf, 0, buf.Length);
-		}
+        public override byte[] ReadBinary()
+        {
+            int size = ReadI32();
+            byte[] buf = new byte[size];
+            trans.ReadAll(buf, 0, size);
+            return buf;
+        }
+        private  string ReadStringBody(int size)
+        {
+            byte[] buf = new byte[size];
+            trans.ReadAll(buf, 0, size);
+            return Encoding.UTF8.GetString(buf, 0, buf.Length);
+        }
 
-		private int ReadAll(byte[] buf, int off, int len)
-		{
-			return trans.ReadAll(buf, off, len);
-		}
+        private int ReadAll(byte[] buf, int off, int len)
+        {
+            return trans.ReadAll(buf, off, len);
+        }
 
-		#endregion
-	}
+        #endregion
+    }
 }
diff --git a/lib/csharp/src/Protocol/TCompactProtocol.cs b/lib/csharp/src/Protocol/TCompactProtocol.cs
index c992e9b..2b4f6f1 100644
--- a/lib/csharp/src/Protocol/TCompactProtocol.cs
+++ b/lib/csharp/src/Protocol/TCompactProtocol.cs
@@ -64,7 +64,7 @@
             public const byte STRUCT = 0x0C;
         }
 
-        /** 
+        /**
          * Used to keep track of the last field for the current and previous structs,
          * so we can do the delta stuff.
          */
@@ -73,13 +73,13 @@
         private short lastFieldId_ = 0;
 
         /**
-         * If we encounter a boolean field begin, save the TField here so it can 
+         * If we encounter a boolean field begin, save the TField here so it can
          * have the value incorporated.
          */
         private Nullable<TField> booleanField_;
 
         /**
-         * If we Read a field header, and it's a boolean field, save the boolean 
+         * If we Read a field header, and it's a boolean field, save the boolean
          * value here so that ReadBool can use it.
          */
         private  Nullable<Boolean> boolValue_;
@@ -88,8 +88,8 @@
         #region CompactProtocol Factory
 
         /**
-		  * Factory
-		  */
+          * Factory
+          */
         public class Factory : TProtocolFactory
         {
             public Factory() { }
@@ -128,8 +128,8 @@
         #region Write Methods
 
 
-        /** 
-         * Writes a byte without any possibility of all that field header nonsense. 
+        /**
+         * Writes a byte without any possibility of all that field header nonsense.
          * Used internally by other writing methods that know they need to Write a byte.
          */
         private byte[] byteDirectBuffer = new byte[1];
@@ -139,7 +139,7 @@
             trans.Write(byteDirectBuffer);
         }
 
-        /** 
+        /**
          * Writes a byte without any possibility of all that field header nonsense.
          */
         private void WriteByteDirect(int n)
@@ -187,7 +187,7 @@
         }
 
         /**
-         * Write a struct begin. This doesn't actually put anything on the wire. We 
+         * Write a struct begin. This doesn't actually put anything on the wire. We
          * use it as an opportunity to put special placeholder markers on the field
          * stack so we can get the field id deltas correct.
          */
@@ -227,8 +227,8 @@
         }
 
         /**
-         * The workhorse of WriteFieldBegin. It has the option of doing a 
-         * 'type override' of the type header. This is used specifically in the 
+         * The workhorse of WriteFieldBegin. It has the option of doing a
+         * 'type override' of the type header. This is used specifically in the
          * boolean field case.
          */
         private void WriteFieldBeginInternal(TField field, byte typeOverride)
@@ -264,7 +264,7 @@
         }
 
         /**
-         * Write a map header. If the map is empty, omit the key and value type 
+         * Write a map header. If the map is empty, omit the key and value type
          * headers, as we don't need any additional information to skip it.
          */
         public override void WriteMapBegin(TMap map)
@@ -280,7 +280,7 @@
             }
         }
 
-        /** 
+        /**
          * Write a list header.
          */
         public override void WriteListBegin(TList list)
@@ -297,9 +297,9 @@
         }
 
         /**
-         * Write a boolean value. Potentially, this could be a boolean field, in 
+         * Write a boolean value. Potentially, this could be a boolean field, in
          * which case the field header info isn't written yet. If so, decide what the
-         * right type header is for the value and then Write the field header. 
+         * right type header is for the value and then Write the field header.
          * Otherwise, Write a single byte.
          */
         public override void WriteBool(Boolean b)
@@ -317,7 +317,7 @@
             }
         }
 
-        /** 
+        /**
          * Write a byte. Nothing to see here!
          */
         public override void WriteByte(sbyte b)
@@ -369,7 +369,7 @@
         }
 
         /**
-         * Write a byte array, using a varint for the size. 
+         * Write a byte array, using a varint for the size.
          */
         public override void WriteBinary(byte[] bin)
         {
@@ -383,9 +383,9 @@
         }
 
         //
-        // These methods are called by structs, but don't actually have any wire 
+        // These methods are called by structs, but don't actually have any wire
         // output or purpose.
-        // 
+        //
 
         public override void WriteMessageEnd() { }
         public override void WriteMapEnd() { }
@@ -398,7 +398,7 @@
         //
 
         /**
-         * Abstract method for writing the start of lists and sets. List and sets on 
+         * Abstract method for writing the start of lists and sets. List and sets on
          * the wire differ only by the type indicator.
          */
         protected void WriteCollectionBegin(TType elemType, int size)
@@ -438,7 +438,7 @@
         }
 
         /**
-         * Convert l into a zigzag long. This allows negative numbers to be 
+         * Convert l into a zigzag long. This allows negative numbers to be
          * represented compactly as a varint.
          */
         private ulong longToZigzag(long n)
@@ -447,7 +447,7 @@
         }
 
         /**
-         * Convert n into a zigzag int. This allows negative numbers to be 
+         * Convert n into a zigzag int. This allows negative numbers to be
          * represented compactly as a varint.
          */
         private uint intToZigZag(int n)
@@ -456,7 +456,7 @@
         }
 
         /**
-         * Convert a long into little-endian bytes in buf starting at off and going 
+         * Convert a long into little-endian bytes in buf starting at off and going
          * until off+7.
          */
         private void fixedLongToBytes(long n, byte[] buf, int off)
@@ -476,7 +476,7 @@
         #region ReadMethods
 
         /**
-   * Read a message header. 
+   * Read a message header.
    */
         public override TMessage ReadMessageBegin()
         {
@@ -509,7 +509,7 @@
         }
 
         /**
-         * Doesn't actually consume any wire data, just removes the last field for 
+         * Doesn't actually consume any wire data, just removes the last field for
          * this struct from the field stack.
          */
         public override void ReadStructEnd()
@@ -519,7 +519,7 @@
         }
 
         /**
-         * Read a field header off the wire. 
+         * Read a field header off the wire.
          */
         public override TField ReadFieldBegin()
         {
@@ -560,7 +560,7 @@
             return field;
         }
 
-        /** 
+        /**
          * Read a map header off the wire. If the size is zero, skip Reading the key
          * and value type. This means that 0-length maps will yield TMaps without the
          * "correct" types.
@@ -573,7 +573,7 @@
         }
 
         /**
-         * Read a list header off the wire. If the list size is 0-14, the size will 
+         * Read a list header off the wire. If the list size is 0-14, the size will
          * be packed into the element type header. If it's a longer list, the 4 MSB
          * of the element type header will be 0xF, and a varint will follow with the
          * true size.
@@ -591,7 +591,7 @@
         }
 
         /**
-         * Read a set header off the wire. If the set size is 0-14, the size will 
+         * Read a set header off the wire. If the set size is 0-14, the size will
          * be packed into the element type header. If it's a longer set, the 4 MSB
          * of the element type header will be 0xF, and a varint will follow with the
          * true size.
@@ -677,7 +677,7 @@
         }
 
         /**
-         * Read a byte[] from the wire. 
+         * Read a byte[] from the wire.
          */
         public override byte[] ReadBinary()
         {
@@ -690,7 +690,7 @@
         }
 
         /**
-         * Read a byte[] of a known length from the wire. 
+         * Read a byte[] of a known length from the wire.
          */
         private byte[] ReadBinary(int length)
         {
@@ -702,7 +702,7 @@
         }
 
         //
-        // These methods are here for the struct to call, but don't have any wire 
+        // These methods are here for the struct to call, but don't have any wire
         // encoding.
         //
         public override void ReadMessageEnd() { }
@@ -734,7 +734,7 @@
         }
 
         /**
-         * Read an i64 from the wire as a proper varint. The MSB of each byte is set 
+         * Read an i64 from the wire as a proper varint. The MSB of each byte is set
          * if there is another byte to follow. This can Read up to 10 bytes.
          */
         private ulong ReadVarint64()
@@ -748,7 +748,7 @@
                 if ((b & 0x80) != 0x80) break;
                 shift += 7;
             }
-			
+
             return result;
         }
 
@@ -766,7 +766,7 @@
             return (int)(n >> 1) ^ (-(int)(n & 1));
         }
 
-        /** 
+        /**
          * Convert from zigzag long to long.
          */
         private long zigzagToLong(ulong n)
@@ -775,7 +775,7 @@
         }
 
         /**
-         * Note that it's important that the mask bytes are long literals, 
+         * Note that it's important that the mask bytes are long literals,
          * otherwise they'll default to ints, and when you shift an int left 56 bits,
          * you just get a messed up int.
          */
@@ -803,7 +803,7 @@
         }
 
         /**
-         * Given a TCompactProtocol.Types constant, convert it to its corresponding 
+         * Given a TCompactProtocol.Types constant, convert it to its corresponding
          * TType value.
          */
         private TType getTType(byte type)
diff --git a/lib/csharp/src/Protocol/TField.cs b/lib/csharp/src/Protocol/TField.cs
index fa10584..8179557 100644
--- a/lib/csharp/src/Protocol/TField.cs
+++ b/lib/csharp/src/Protocol/TField.cs
@@ -27,36 +27,36 @@
 
 namespace Thrift.Protocol
 {
-	public struct TField
-	{
-		private string name;
-		private TType type;
-		private short id;
+    public struct TField
+    {
+        private string name;
+        private TType type;
+        private short id;
 
-		public TField(string name, TType type, short id)
-			:this()
-		{
-			this.name = name;
-			this.type = type;
-			this.id = id;
-		}
+        public TField(string name, TType type, short id)
+            :this()
+        {
+            this.name = name;
+            this.type = type;
+            this.id = id;
+        }
 
-		public string Name
-		{
-			get { return name; }
-			set { name = value; }
-		}
+        public string Name
+        {
+            get { return name; }
+            set { name = value; }
+        }
 
-		public TType Type
-		{
-			get { return type; }
-			set { type = value; }
-		}
+        public TType Type
+        {
+            get { return type; }
+            set { type = value; }
+        }
 
-		public short ID
-		{
-			get { return id; }
-			set { id = value; }
-		}
-	}
+        public short ID
+        {
+            get { return id; }
+            set { id = value; }
+        }
+    }
 }
diff --git a/lib/csharp/src/Protocol/TJSONProtocol.cs b/lib/csharp/src/Protocol/TJSONProtocol.cs
index e1d0e78..2e8d99f 100644
--- a/lib/csharp/src/Protocol/TJSONProtocol.cs
+++ b/lib/csharp/src/Protocol/TJSONProtocol.cs
@@ -27,1064 +27,1064 @@
 
 namespace Thrift.Protocol
 {
-	/// <summary>
-	/// JSON protocol implementation for thrift.
-	///
-	/// This is a full-featured protocol supporting Write and Read.
-	///
-	/// Please see the C++ class header for a detailed description of the
-	/// protocol's wire format.
-	///
-	/// Adapted from the Java version.
-	/// </summary>
-	public class TJSONProtocol : TProtocol
-	{
-		/// <summary>
-		/// Factory for JSON protocol objects
-		/// </summary>
-		public class Factory : TProtocolFactory
-		{
-			public TProtocol GetProtocol(TTransport trans)
-			{
-				return new TJSONProtocol(trans);
-			}
-		}
+    /// <summary>
+    /// JSON protocol implementation for thrift.
+    ///
+    /// This is a full-featured protocol supporting Write and Read.
+    ///
+    /// Please see the C++ class header for a detailed description of the
+    /// protocol's wire format.
+    ///
+    /// Adapted from the Java version.
+    /// </summary>
+    public class TJSONProtocol : TProtocol
+    {
+        /// <summary>
+        /// Factory for JSON protocol objects
+        /// </summary>
+        public class Factory : TProtocolFactory
+        {
+            public TProtocol GetProtocol(TTransport trans)
+            {
+                return new TJSONProtocol(trans);
+            }
+        }
 
-		private static byte[] COMMA = new byte[] { (byte)',' };
-		private static byte[] COLON = new byte[] { (byte)':' };
-		private static byte[] LBRACE = new byte[] { (byte)'{' };
-		private static byte[] RBRACE = new byte[] { (byte)'}' };
-		private static byte[] LBRACKET = new byte[] { (byte)'[' };
-		private static byte[] RBRACKET = new byte[] { (byte)']' };
-		private static byte[] QUOTE = new byte[] { (byte)'"' };
-		private static byte[] BACKSLASH = new byte[] { (byte)'\\' };
+        private static byte[] COMMA = new byte[] { (byte)',' };
+        private static byte[] COLON = new byte[] { (byte)':' };
+        private static byte[] LBRACE = new byte[] { (byte)'{' };
+        private static byte[] RBRACE = new byte[] { (byte)'}' };
+        private static byte[] LBRACKET = new byte[] { (byte)'[' };
+        private static byte[] RBRACKET = new byte[] { (byte)']' };
+        private static byte[] QUOTE = new byte[] { (byte)'"' };
+        private static byte[] BACKSLASH = new byte[] { (byte)'\\' };
 
-		private byte[] ESCSEQ = new byte[] { (byte)'\\', (byte)'u', (byte)'0', (byte)'0' };
+        private byte[] ESCSEQ = new byte[] { (byte)'\\', (byte)'u', (byte)'0', (byte)'0' };
 
-		private const long VERSION = 1;
-		private byte[] JSON_CHAR_TABLE = {
-	0,  0,  0,  0,  0,  0,  0,  0,(byte)'b',(byte)'t',(byte)'n',  0,(byte)'f',(byte)'r',  0,  0, 
-	0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 
-	1,  1,(byte)'"',  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
+        private const long VERSION = 1;
+        private byte[] JSON_CHAR_TABLE = {
+    0,  0,  0,  0,  0,  0,  0,  0,(byte)'b',(byte)'t',(byte)'n',  0,(byte)'f',(byte)'r',  0,  0,
+    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
+    1,  1,(byte)'"',  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
   };
 
-		private char[] ESCAPE_CHARS = "\"\\/bfnrt".ToCharArray();
+        private char[] ESCAPE_CHARS = "\"\\/bfnrt".ToCharArray();
 
-		private byte[] ESCAPE_CHAR_VALS = {
-	(byte)'"', (byte)'\\', (byte)'/', (byte)'\b', (byte)'\f', (byte)'\n', (byte)'\r', (byte)'\t',
+        private byte[] ESCAPE_CHAR_VALS = {
+    (byte)'"', (byte)'\\', (byte)'/', (byte)'\b', (byte)'\f', (byte)'\n', (byte)'\r', (byte)'\t',
   };
 
-		private const int DEF_STRING_SIZE = 16;
+        private const int DEF_STRING_SIZE = 16;
 
-		private static byte[] NAME_BOOL = new byte[] { (byte)'t', (byte)'f' };
-		private static byte[] NAME_BYTE = new byte[] { (byte)'i', (byte)'8' };
-		private static byte[] NAME_I16 = new byte[] { (byte)'i', (byte)'1', (byte)'6' };
-		private static byte[] NAME_I32 = new byte[] { (byte)'i', (byte)'3', (byte)'2' };
-		private static byte[] NAME_I64 = new byte[] { (byte)'i', (byte)'6', (byte)'4' };
-		private static byte[] NAME_DOUBLE = new byte[] { (byte)'d', (byte)'b', (byte)'l' };
-		private static byte[] NAME_STRUCT = new byte[] { (byte)'r', (byte)'e', (byte)'c' };
-		private static byte[] NAME_STRING = new byte[] { (byte)'s', (byte)'t', (byte)'r' };
-		private static byte[] NAME_MAP = new byte[] { (byte)'m', (byte)'a', (byte)'p' };
-		private static byte[] NAME_LIST = new byte[] { (byte)'l', (byte)'s', (byte)'t' };
-		private static byte[] NAME_SET = new byte[] { (byte)'s', (byte)'e', (byte)'t' };
+        private static byte[] NAME_BOOL = new byte[] { (byte)'t', (byte)'f' };
+        private static byte[] NAME_BYTE = new byte[] { (byte)'i', (byte)'8' };
+        private static byte[] NAME_I16 = new byte[] { (byte)'i', (byte)'1', (byte)'6' };
+        private static byte[] NAME_I32 = new byte[] { (byte)'i', (byte)'3', (byte)'2' };
+        private static byte[] NAME_I64 = new byte[] { (byte)'i', (byte)'6', (byte)'4' };
+        private static byte[] NAME_DOUBLE = new byte[] { (byte)'d', (byte)'b', (byte)'l' };
+        private static byte[] NAME_STRUCT = new byte[] { (byte)'r', (byte)'e', (byte)'c' };
+        private static byte[] NAME_STRING = new byte[] { (byte)'s', (byte)'t', (byte)'r' };
+        private static byte[] NAME_MAP = new byte[] { (byte)'m', (byte)'a', (byte)'p' };
+        private static byte[] NAME_LIST = new byte[] { (byte)'l', (byte)'s', (byte)'t' };
+        private static byte[] NAME_SET = new byte[] { (byte)'s', (byte)'e', (byte)'t' };
 
-		private static byte[] GetTypeNameForTypeID(TType typeID)
-		{
-			switch (typeID)
-			{
-				case TType.Bool:
-					return NAME_BOOL;
-				case TType.Byte:
-					return NAME_BYTE;
-				case TType.I16:
-					return NAME_I16;
-				case TType.I32:
-					return NAME_I32;
-				case TType.I64:
-					return NAME_I64;
-				case TType.Double:
-					return NAME_DOUBLE;
-				case TType.String:
-					return NAME_STRING;
-				case TType.Struct:
-					return NAME_STRUCT;
-				case TType.Map:
-					return NAME_MAP;
-				case TType.Set:
-					return NAME_SET;
-				case TType.List:
-					return NAME_LIST;
-				default:
-					throw new TProtocolException(TProtocolException.NOT_IMPLEMENTED,
-												 "Unrecognized type");
-			}
-		}
+        private static byte[] GetTypeNameForTypeID(TType typeID)
+        {
+            switch (typeID)
+            {
+                case TType.Bool:
+                    return NAME_BOOL;
+                case TType.Byte:
+                    return NAME_BYTE;
+                case TType.I16:
+                    return NAME_I16;
+                case TType.I32:
+                    return NAME_I32;
+                case TType.I64:
+                    return NAME_I64;
+                case TType.Double:
+                    return NAME_DOUBLE;
+                case TType.String:
+                    return NAME_STRING;
+                case TType.Struct:
+                    return NAME_STRUCT;
+                case TType.Map:
+                    return NAME_MAP;
+                case TType.Set:
+                    return NAME_SET;
+                case TType.List:
+                    return NAME_LIST;
+                default:
+                    throw new TProtocolException(TProtocolException.NOT_IMPLEMENTED,
+                                                 "Unrecognized type");
+            }
+        }
 
-		private static TType GetTypeIDForTypeName(byte[] name)
-		{
-			TType result = TType.Stop;
-			if (name.Length > 1)
-			{
-				switch (name[0])
-				{
-					case (byte)'d':
-						result = TType.Double;
-						break;
-					case (byte)'i':
-						switch (name[1])
-						{
-							case (byte)'8':
-								result = TType.Byte;
-								break;
-							case (byte)'1':
-								result = TType.I16;
-								break;
-							case (byte)'3':
-								result = TType.I32;
-								break;
-							case (byte)'6':
-								result = TType.I64;
-								break;
-						}
-						break;
-					case (byte)'l':
-						result = TType.List;
-						break;
-					case (byte)'m':
-						result = TType.Map;
-						break;
-					case (byte)'r':
-						result = TType.Struct;
-						break;
-					case (byte)'s':
-						if (name[1] == (byte)'t')
-						{
-							result = TType.String;
-						}
-						else if (name[1] == (byte)'e')
-						{
-							result = TType.Set;
-						}
-						break;
-					case (byte)'t':
-						result = TType.Bool;
-						break;
-				}
-			}
-			if (result == TType.Stop)
-			{
-				throw new TProtocolException(TProtocolException.NOT_IMPLEMENTED,
-											 "Unrecognized type");
-			}
-			return result;
-		}
+        private static TType GetTypeIDForTypeName(byte[] name)
+        {
+            TType result = TType.Stop;
+            if (name.Length > 1)
+            {
+                switch (name[0])
+                {
+                    case (byte)'d':
+                        result = TType.Double;
+                        break;
+                    case (byte)'i':
+                        switch (name[1])
+                        {
+                            case (byte)'8':
+                                result = TType.Byte;
+                                break;
+                            case (byte)'1':
+                                result = TType.I16;
+                                break;
+                            case (byte)'3':
+                                result = TType.I32;
+                                break;
+                            case (byte)'6':
+                                result = TType.I64;
+                                break;
+                        }
+                        break;
+                    case (byte)'l':
+                        result = TType.List;
+                        break;
+                    case (byte)'m':
+                        result = TType.Map;
+                        break;
+                    case (byte)'r':
+                        result = TType.Struct;
+                        break;
+                    case (byte)'s':
+                        if (name[1] == (byte)'t')
+                        {
+                            result = TType.String;
+                        }
+                        else if (name[1] == (byte)'e')
+                        {
+                            result = TType.Set;
+                        }
+                        break;
+                    case (byte)'t':
+                        result = TType.Bool;
+                        break;
+                }
+            }
+            if (result == TType.Stop)
+            {
+                throw new TProtocolException(TProtocolException.NOT_IMPLEMENTED,
+                                             "Unrecognized type");
+            }
+            return result;
+        }
 
-		///<summary>
-		/// Base class for tracking JSON contexts that may require
-		/// inserting/Reading additional JSON syntax characters
-		/// This base context does nothing.
-		///</summary>
-		protected class JSONBaseContext
-		{
-			protected TJSONProtocol proto;
+        ///<summary>
+        /// Base class for tracking JSON contexts that may require
+        /// inserting/Reading additional JSON syntax characters
+        /// This base context does nothing.
+        ///</summary>
+        protected class JSONBaseContext
+        {
+            protected TJSONProtocol proto;
 
-			public JSONBaseContext(TJSONProtocol proto)
-			{
-				this.proto = proto;
-			}
+            public JSONBaseContext(TJSONProtocol proto)
+            {
+                this.proto = proto;
+            }
 
-			public virtual void Write() { }
+            public virtual void Write() { }
 
-			public virtual void Read() { }
+            public virtual void Read() { }
 
-			public virtual bool EscapeNumbers() { return false; }
-		}
+            public virtual bool EscapeNumbers() { return false; }
+        }
 
-		///<summary>
-		/// Context for JSON lists. Will insert/Read commas before each item except
-		/// for the first one
-		///</summary>
-		protected class JSONListContext : JSONBaseContext
-		{
-			public JSONListContext(TJSONProtocol protocol)
-				: base(protocol)
-			{
+        ///<summary>
+        /// Context for JSON lists. Will insert/Read commas before each item except
+        /// for the first one
+        ///</summary>
+        protected class JSONListContext : JSONBaseContext
+        {
+            public JSONListContext(TJSONProtocol protocol)
+                : base(protocol)
+            {
 
-			}
+            }
 
-			private bool first = true;
+            private bool first = true;
 
-			public override void Write()
-			{
-				if (first)
-				{
-					first = false;
-				}
-				else
-				{
-					proto.trans.Write(COMMA);
-				}
-			}
+            public override void Write()
+            {
+                if (first)
+                {
+                    first = false;
+                }
+                else
+                {
+                    proto.trans.Write(COMMA);
+                }
+            }
 
-			public override void Read()
-			{
-				if (first)
-				{
-					first = false;
-				}
-				else
-				{
-					proto.ReadJSONSyntaxChar(COMMA);
-				}
-			}
-		}
+            public override void Read()
+            {
+                if (first)
+                {
+                    first = false;
+                }
+                else
+                {
+                    proto.ReadJSONSyntaxChar(COMMA);
+                }
+            }
+        }
 
-		///<summary>
-		/// Context for JSON records. Will insert/Read colons before the value portion
-		/// of each record pair, and commas before each key except the first. In
-		/// addition, will indicate that numbers in the key position need to be
-		/// escaped in quotes (since JSON keys must be strings).
-		///</summary>
-		protected class JSONPairContext : JSONBaseContext
-		{
-			public JSONPairContext(TJSONProtocol proto)
-				: base(proto)
-			{
+        ///<summary>
+        /// Context for JSON records. Will insert/Read colons before the value portion
+        /// of each record pair, and commas before each key except the first. In
+        /// addition, will indicate that numbers in the key position need to be
+        /// escaped in quotes (since JSON keys must be strings).
+        ///</summary>
+        protected class JSONPairContext : JSONBaseContext
+        {
+            public JSONPairContext(TJSONProtocol proto)
+                : base(proto)
+            {
 
-			}
+            }
 
-			private bool first = true;
-			private bool colon = true;
+            private bool first = true;
+            private bool colon = true;
 
-			public override void Write()
-			{
-				if (first)
-				{
-					first = false;
-					colon = true;
-				}
-				else
-				{
-					proto.trans.Write(colon ? COLON : COMMA);
-					colon = !colon;
-				}
-			}
+            public override void Write()
+            {
+                if (first)
+                {
+                    first = false;
+                    colon = true;
+                }
+                else
+                {
+                    proto.trans.Write(colon ? COLON : COMMA);
+                    colon = !colon;
+                }
+            }
 
-			public override void Read()
-			{
-				if (first)
-				{
-					first = false;
-					colon = true;
-				}
-				else
-				{
-					proto.ReadJSONSyntaxChar(colon ? COLON : COMMA);
-					colon = !colon;
-				}
-			}
+            public override void Read()
+            {
+                if (first)
+                {
+                    first = false;
+                    colon = true;
+                }
+                else
+                {
+                    proto.ReadJSONSyntaxChar(colon ? COLON : COMMA);
+                    colon = !colon;
+                }
+            }
 
-			public override bool EscapeNumbers()
-			{
-				return colon;
-			}
-		}
+            public override bool EscapeNumbers()
+            {
+                return colon;
+            }
+        }
 
-		///<summary>
-		/// Holds up to one byte from the transport
-		///</summary>
-		protected class LookaheadReader
-		{
-			protected TJSONProtocol proto;
+        ///<summary>
+        /// Holds up to one byte from the transport
+        ///</summary>
+        protected class LookaheadReader
+        {
+            protected TJSONProtocol proto;
 
-			public LookaheadReader(TJSONProtocol proto)
-			{
-				this.proto = proto;
-			}
+            public LookaheadReader(TJSONProtocol proto)
+            {
+                this.proto = proto;
+            }
 
-			private bool hasData;
-			private byte[] data = new byte[1];
+            private bool hasData;
+            private byte[] data = new byte[1];
 
-			///<summary>
-			/// Return and consume the next byte to be Read, either taking it from the
-			/// data buffer if present or getting it from the transport otherwise.
-			///</summary>
-			public byte Read()
-			{
-				if (hasData)
-				{
-					hasData = false;
-				}
-				else
-				{
-					proto.trans.ReadAll(data, 0, 1);
-				}
-				return data[0];
-			}
+            ///<summary>
+            /// Return and consume the next byte to be Read, either taking it from the
+            /// data buffer if present or getting it from the transport otherwise.
+            ///</summary>
+            public byte Read()
+            {
+                if (hasData)
+                {
+                    hasData = false;
+                }
+                else
+                {
+                    proto.trans.ReadAll(data, 0, 1);
+                }
+                return data[0];
+            }
 
-			///<summary>
-			/// Return the next byte to be Read without consuming, filling the data
-			/// buffer if it has not been filled alReady.
-			///</summary>
-			public byte Peek()
-			{
-				if (!hasData)
-				{
-					proto.trans.ReadAll(data, 0, 1);
-				}
-				hasData = true;
-				return data[0];
-			}
-		}
+            ///<summary>
+            /// Return the next byte to be Read without consuming, filling the data
+            /// buffer if it has not been filled alReady.
+            ///</summary>
+            public byte Peek()
+            {
+                if (!hasData)
+                {
+                    proto.trans.ReadAll(data, 0, 1);
+                }
+                hasData = true;
+                return data[0];
+            }
+        }
 
-		// Default encoding
-		protected Encoding utf8Encoding = UTF8Encoding.UTF8;
+        // Default encoding
+        protected Encoding utf8Encoding = UTF8Encoding.UTF8;
 
-		// Stack of nested contexts that we may be in
-		protected Stack<JSONBaseContext> contextStack = new Stack<JSONBaseContext>();
+        // Stack of nested contexts that we may be in
+        protected Stack<JSONBaseContext> contextStack = new Stack<JSONBaseContext>();
 
-		// Current context that we are in
-		protected JSONBaseContext context;
+        // Current context that we are in
+        protected JSONBaseContext context;
 
-		// Reader that manages a 1-byte buffer
-		protected LookaheadReader reader;
+        // Reader that manages a 1-byte buffer
+        protected LookaheadReader reader;
 
-		///<summary>
-		/// Push a new JSON context onto the stack.
-		///</summary>
-		protected void PushContext(JSONBaseContext c)
-		{
-			contextStack.Push(context);
-			context = c;
-		}
+        ///<summary>
+        /// Push a new JSON context onto the stack.
+        ///</summary>
+        protected void PushContext(JSONBaseContext c)
+        {
+            contextStack.Push(context);
+            context = c;
+        }
 
-		///<summary>
-		/// Pop the last JSON context off the stack
-		///</summary>
-		protected void PopContext()
-		{
-			context = contextStack.Pop();
-		}
+        ///<summary>
+        /// Pop the last JSON context off the stack
+        ///</summary>
+        protected void PopContext()
+        {
+            context = contextStack.Pop();
+        }
 
-		///<summary>
-		/// TJSONProtocol Constructor
-		///</summary>
-		public TJSONProtocol(TTransport trans)
-			: base(trans)
-		{
-			context = new JSONBaseContext(this);
-			reader = new LookaheadReader(this);
-		}
+        ///<summary>
+        /// TJSONProtocol Constructor
+        ///</summary>
+        public TJSONProtocol(TTransport trans)
+            : base(trans)
+        {
+            context = new JSONBaseContext(this);
+            reader = new LookaheadReader(this);
+        }
 
-		// Temporary buffer used by several methods
-		private byte[] tempBuffer = new byte[4];
+        // Temporary buffer used by several methods
+        private byte[] tempBuffer = new byte[4];
 
-		///<summary>
-		/// Read a byte that must match b[0]; otherwise an exception is thrown.
-		/// Marked protected to avoid synthetic accessor in JSONListContext.Read
-		/// and JSONPairContext.Read
-		///</summary>
-		protected void ReadJSONSyntaxChar(byte[] b)
-		{
-			byte ch = reader.Read();
-			if (ch != b[0])
-			{
-				throw new TProtocolException(TProtocolException.INVALID_DATA,
-											 "Unexpected character:" + (char)ch);
-			}
-		}
+        ///<summary>
+        /// Read a byte that must match b[0]; otherwise an exception is thrown.
+        /// Marked protected to avoid synthetic accessor in JSONListContext.Read
+        /// and JSONPairContext.Read
+        ///</summary>
+        protected void ReadJSONSyntaxChar(byte[] b)
+        {
+            byte ch = reader.Read();
+            if (ch != b[0])
+            {
+                throw new TProtocolException(TProtocolException.INVALID_DATA,
+                                             "Unexpected character:" + (char)ch);
+            }
+        }
 
-		///<summary>
-		/// Convert a byte containing a hex char ('0'-'9' or 'a'-'f') into its
-		/// corresponding hex value
-		///</summary>
-		private static byte HexVal(byte ch)
-		{
-			if ((ch >= '0') && (ch <= '9'))
-			{
-				return (byte)((char)ch - '0');
-			}
-			else if ((ch >= 'a') && (ch <= 'f'))
-			{
-				ch += 10;
-				return (byte)((char)ch - 'a');
-			}
-			else
-			{
-				throw new TProtocolException(TProtocolException.INVALID_DATA,
-											 "Expected hex character");
-			}
-		}
+        ///<summary>
+        /// Convert a byte containing a hex char ('0'-'9' or 'a'-'f') into its
+        /// corresponding hex value
+        ///</summary>
+        private static byte HexVal(byte ch)
+        {
+            if ((ch >= '0') && (ch <= '9'))
+            {
+                return (byte)((char)ch - '0');
+            }
+            else if ((ch >= 'a') && (ch <= 'f'))
+            {
+                ch += 10;
+                return (byte)((char)ch - 'a');
+            }
+            else
+            {
+                throw new TProtocolException(TProtocolException.INVALID_DATA,
+                                             "Expected hex character");
+            }
+        }
 
-		///<summary>
-		/// Convert a byte containing a hex value to its corresponding hex character
-		///</summary>
-		private static byte HexChar(byte val)
-		{
-			val &= 0x0F;
-			if (val < 10)
-			{
-				return (byte)((char)val + '0');
-			}
-			else
-			{
-				val -= 10;
-				return (byte)((char)val + 'a');
-			}
-		}
+        ///<summary>
+        /// Convert a byte containing a hex value to its corresponding hex character
+        ///</summary>
+        private static byte HexChar(byte val)
+        {
+            val &= 0x0F;
+            if (val < 10)
+            {
+                return (byte)((char)val + '0');
+            }
+            else
+            {
+                val -= 10;
+                return (byte)((char)val + 'a');
+            }
+        }
 
-		///<summary>
-		/// Write the bytes in array buf as a JSON characters, escaping as needed
-		///</summary>
-		private void WriteJSONString(byte[] b)
-		{
-			context.Write();
-			trans.Write(QUOTE);
-			int len = b.Length;
-			for (int i = 0; i < len; i++)
-			{
-				if ((b[i] & 0x00FF) >= 0x30)
-				{
-					if (b[i] == BACKSLASH[0])
-					{
-						trans.Write(BACKSLASH);
-						trans.Write(BACKSLASH);
-					}
-					else
-					{
-						trans.Write(b, i, 1);
-					}
-				}
-				else
-				{
-					tempBuffer[0] = JSON_CHAR_TABLE[b[i]];
-					if (tempBuffer[0] == 1)
-					{
-						trans.Write(b, i, 1);
-					}
-					else if (tempBuffer[0] > 1)
-					{
-						trans.Write(BACKSLASH);
-						trans.Write(tempBuffer, 0, 1);
-					}
-					else
-					{
-						trans.Write(ESCSEQ);
-						tempBuffer[0] = HexChar((byte)(b[i] >> 4));
-						tempBuffer[1] = HexChar(b[i]);
-						trans.Write(tempBuffer, 0, 2);
-					}
-				}
-			}
-			trans.Write(QUOTE);
-		}
+        ///<summary>
+        /// Write the bytes in array buf as a JSON characters, escaping as needed
+        ///</summary>
+        private void WriteJSONString(byte[] b)
+        {
+            context.Write();
+            trans.Write(QUOTE);
+            int len = b.Length;
+            for (int i = 0; i < len; i++)
+            {
+                if ((b[i] & 0x00FF) >= 0x30)
+                {
+                    if (b[i] == BACKSLASH[0])
+                    {
+                        trans.Write(BACKSLASH);
+                        trans.Write(BACKSLASH);
+                    }
+                    else
+                    {
+                        trans.Write(b, i, 1);
+                    }
+                }
+                else
+                {
+                    tempBuffer[0] = JSON_CHAR_TABLE[b[i]];
+                    if (tempBuffer[0] == 1)
+                    {
+                        trans.Write(b, i, 1);
+                    }
+                    else if (tempBuffer[0] > 1)
+                    {
+                        trans.Write(BACKSLASH);
+                        trans.Write(tempBuffer, 0, 1);
+                    }
+                    else
+                    {
+                        trans.Write(ESCSEQ);
+                        tempBuffer[0] = HexChar((byte)(b[i] >> 4));
+                        tempBuffer[1] = HexChar(b[i]);
+                        trans.Write(tempBuffer, 0, 2);
+                    }
+                }
+            }
+            trans.Write(QUOTE);
+        }
 
-		///<summary>
-		/// Write out number as a JSON value. If the context dictates so, it will be
-		/// wrapped in quotes to output as a JSON string.
-		///</summary>
-		private void WriteJSONInteger(long num)
-		{
-			context.Write();
-			String str = num.ToString();
+        ///<summary>
+        /// Write out number as a JSON value. If the context dictates so, it will be
+        /// wrapped in quotes to output as a JSON string.
+        ///</summary>
+        private void WriteJSONInteger(long num)
+        {
+            context.Write();
+            String str = num.ToString();
 
-			bool escapeNum = context.EscapeNumbers();
-			if (escapeNum)
-				trans.Write(QUOTE);
+            bool escapeNum = context.EscapeNumbers();
+            if (escapeNum)
+                trans.Write(QUOTE);
 
-			trans.Write(utf8Encoding.GetBytes(str));
+            trans.Write(utf8Encoding.GetBytes(str));
 
-			if (escapeNum)
-				trans.Write(QUOTE);
-		}
+            if (escapeNum)
+                trans.Write(QUOTE);
+        }
 
-		///<summary>
-		/// Write out a double as a JSON value. If it is NaN or infinity or if the
-		/// context dictates escaping, Write out as JSON string.
-		///</summary>
-		private void WriteJSONDouble(double num)
-		{
-			context.Write();
-			String str = num.ToString(CultureInfo.InvariantCulture);
-			bool special = false;
+        ///<summary>
+        /// Write out a double as a JSON value. If it is NaN or infinity or if the
+        /// context dictates escaping, Write out as JSON string.
+        ///</summary>
+        private void WriteJSONDouble(double num)
+        {
+            context.Write();
+            String str = num.ToString(CultureInfo.InvariantCulture);
+            bool special = false;
 
-			switch (str[0])
-			{
-				case 'N': // NaN
-				case 'I': // Infinity
-					special = true;
-					break;
-				case '-':
-					if (str[1] == 'I')
-					{ // -Infinity
-						special = true;
-					}
-					break;
-			}
+            switch (str[0])
+            {
+                case 'N': // NaN
+                case 'I': // Infinity
+                    special = true;
+                    break;
+                case '-':
+                    if (str[1] == 'I')
+                    { // -Infinity
+                        special = true;
+                    }
+                    break;
+            }
 
-			bool escapeNum = special || context.EscapeNumbers();
+            bool escapeNum = special || context.EscapeNumbers();
 
-			if (escapeNum)
-				trans.Write(QUOTE);
+            if (escapeNum)
+                trans.Write(QUOTE);
 
-			trans.Write(utf8Encoding.GetBytes(str));
+            trans.Write(utf8Encoding.GetBytes(str));
 
-			if (escapeNum)
-				trans.Write(QUOTE);
-		}
-		///<summary>
-		/// Write out contents of byte array b as a JSON string with base-64 encoded
-		/// data
-		///</summary>
-		private void WriteJSONBase64(byte[] b)
-		{
-			context.Write();
-			trans.Write(QUOTE);
+            if (escapeNum)
+                trans.Write(QUOTE);
+        }
+        ///<summary>
+        /// Write out contents of byte array b as a JSON string with base-64 encoded
+        /// data
+        ///</summary>
+        private void WriteJSONBase64(byte[] b)
+        {
+            context.Write();
+            trans.Write(QUOTE);
 
-			int len = b.Length;
-			int off = 0;
+            int len = b.Length;
+            int off = 0;
 
-			while (len >= 3)
-			{
-				// Encode 3 bytes at a time
-				TBase64Utils.encode(b, off, 3, tempBuffer, 0);
-				trans.Write(tempBuffer, 0, 4);
-				off += 3;
-				len -= 3;
-			}
-			if (len > 0)
-			{
-				// Encode remainder
-				TBase64Utils.encode(b, off, len, tempBuffer, 0);
-				trans.Write(tempBuffer, 0, len + 1);
-			}
+            while (len >= 3)
+            {
+                // Encode 3 bytes at a time
+                TBase64Utils.encode(b, off, 3, tempBuffer, 0);
+                trans.Write(tempBuffer, 0, 4);
+                off += 3;
+                len -= 3;
+            }
+            if (len > 0)
+            {
+                // Encode remainder
+                TBase64Utils.encode(b, off, len, tempBuffer, 0);
+                trans.Write(tempBuffer, 0, len + 1);
+            }
 
-			trans.Write(QUOTE);
-		}
+            trans.Write(QUOTE);
+        }
 
-		private void WriteJSONObjectStart()
-		{
-			context.Write();
-			trans.Write(LBRACE);
-			PushContext(new JSONPairContext(this));
-		}
+        private void WriteJSONObjectStart()
+        {
+            context.Write();
+            trans.Write(LBRACE);
+            PushContext(new JSONPairContext(this));
+        }
 
-		private void WriteJSONObjectEnd()
-		{
-			PopContext();
-			trans.Write(RBRACE);
-		}
+        private void WriteJSONObjectEnd()
+        {
+            PopContext();
+            trans.Write(RBRACE);
+        }
 
-		private void WriteJSONArrayStart()
-		{
-			context.Write();
-			trans.Write(LBRACKET);
-			PushContext(new JSONListContext(this));
-		}
+        private void WriteJSONArrayStart()
+        {
+            context.Write();
+            trans.Write(LBRACKET);
+            PushContext(new JSONListContext(this));
+        }
 
-		private void WriteJSONArrayEnd()
-		{
-			PopContext();
-			trans.Write(RBRACKET);
-		}
+        private void WriteJSONArrayEnd()
+        {
+            PopContext();
+            trans.Write(RBRACKET);
+        }
 
-		public override void WriteMessageBegin(TMessage message)
-		{
-			WriteJSONArrayStart();
-			WriteJSONInteger(VERSION);
+        public override void WriteMessageBegin(TMessage message)
+        {
+            WriteJSONArrayStart();
+            WriteJSONInteger(VERSION);
 
-			byte[] b = utf8Encoding.GetBytes(message.Name);
-			WriteJSONString(b);
+            byte[] b = utf8Encoding.GetBytes(message.Name);
+            WriteJSONString(b);
 
-			WriteJSONInteger((long)message.Type);
-			WriteJSONInteger(message.SeqID);
-		}
+            WriteJSONInteger((long)message.Type);
+            WriteJSONInteger(message.SeqID);
+        }
 
-		public override void WriteMessageEnd()
-		{
-			WriteJSONArrayEnd();
-		}
+        public override void WriteMessageEnd()
+        {
+            WriteJSONArrayEnd();
+        }
 
-		public override void WriteStructBegin(TStruct str)
-		{
-			WriteJSONObjectStart();
-		}
+        public override void WriteStructBegin(TStruct str)
+        {
+            WriteJSONObjectStart();
+        }
 
-		public override void WriteStructEnd()
-		{
-			WriteJSONObjectEnd();
-		}
+        public override void WriteStructEnd()
+        {
+            WriteJSONObjectEnd();
+        }
 
-		public override void WriteFieldBegin(TField field)
-		{
-			WriteJSONInteger(field.ID);
-			WriteJSONObjectStart();
-			WriteJSONString(GetTypeNameForTypeID(field.Type));
-		}
+        public override void WriteFieldBegin(TField field)
+        {
+            WriteJSONInteger(field.ID);
+            WriteJSONObjectStart();
+            WriteJSONString(GetTypeNameForTypeID(field.Type));
+        }
 
-		public override void WriteFieldEnd()
-		{
-			WriteJSONObjectEnd();
-		}
+        public override void WriteFieldEnd()
+        {
+            WriteJSONObjectEnd();
+        }
 
-		public override void WriteFieldStop() { }
+        public override void WriteFieldStop() { }
 
-		public override void WriteMapBegin(TMap map)
-		{
-			WriteJSONArrayStart();
-			WriteJSONString(GetTypeNameForTypeID(map.KeyType));
-			WriteJSONString(GetTypeNameForTypeID(map.ValueType));
-			WriteJSONInteger(map.Count);
-			WriteJSONObjectStart();
-		}
+        public override void WriteMapBegin(TMap map)
+        {
+            WriteJSONArrayStart();
+            WriteJSONString(GetTypeNameForTypeID(map.KeyType));
+            WriteJSONString(GetTypeNameForTypeID(map.ValueType));
+            WriteJSONInteger(map.Count);
+            WriteJSONObjectStart();
+        }
 
-		public override void WriteMapEnd()
-		{
-			WriteJSONObjectEnd();
-			WriteJSONArrayEnd();
-		}
+        public override void WriteMapEnd()
+        {
+            WriteJSONObjectEnd();
+            WriteJSONArrayEnd();
+        }
 
-		public override void WriteListBegin(TList list)
-		{
-			WriteJSONArrayStart();
-			WriteJSONString(GetTypeNameForTypeID(list.ElementType));
-			WriteJSONInteger(list.Count);
-		}
+        public override void WriteListBegin(TList list)
+        {
+            WriteJSONArrayStart();
+            WriteJSONString(GetTypeNameForTypeID(list.ElementType));
+            WriteJSONInteger(list.Count);
+        }
 
-		public override void WriteListEnd()
-		{
-			WriteJSONArrayEnd();
-		}
+        public override void WriteListEnd()
+        {
+            WriteJSONArrayEnd();
+        }
 
-		public override void WriteSetBegin(TSet set)
-		{
-			WriteJSONArrayStart();
-			WriteJSONString(GetTypeNameForTypeID(set.ElementType));
-			WriteJSONInteger(set.Count);
-		}
+        public override void WriteSetBegin(TSet set)
+        {
+            WriteJSONArrayStart();
+            WriteJSONString(GetTypeNameForTypeID(set.ElementType));
+            WriteJSONInteger(set.Count);
+        }
 
-		public override void WriteSetEnd()
-		{
-			WriteJSONArrayEnd();
-		}
+        public override void WriteSetEnd()
+        {
+            WriteJSONArrayEnd();
+        }
 
-		public override void WriteBool(bool b)
-		{
-			WriteJSONInteger(b ? (long)1 : (long)0);
-		}
+        public override void WriteBool(bool b)
+        {
+            WriteJSONInteger(b ? (long)1 : (long)0);
+        }
 
-		public override void WriteByte(sbyte b)
-		{
-			WriteJSONInteger((long)b);
-		}
+        public override void WriteByte(sbyte b)
+        {
+            WriteJSONInteger((long)b);
+        }
 
-		public override void WriteI16(short i16)
-		{
-			WriteJSONInteger((long)i16);
-		}
+        public override void WriteI16(short i16)
+        {
+            WriteJSONInteger((long)i16);
+        }
 
-		public override void WriteI32(int i32)
-		{
-			WriteJSONInteger((long)i32);
-		}
+        public override void WriteI32(int i32)
+        {
+            WriteJSONInteger((long)i32);
+        }
 
-		public override void WriteI64(long i64)
-		{
-			WriteJSONInteger(i64);
-		}
+        public override void WriteI64(long i64)
+        {
+            WriteJSONInteger(i64);
+        }
 
-		public override void WriteDouble(double dub)
-		{
-			WriteJSONDouble(dub);
-		}
+        public override void WriteDouble(double dub)
+        {
+            WriteJSONDouble(dub);
+        }
 
-		public override void WriteString(String str)
-		{
-			byte[] b = utf8Encoding.GetBytes(str);
-			WriteJSONString(b);
-		}
+        public override void WriteString(String str)
+        {
+            byte[] b = utf8Encoding.GetBytes(str);
+            WriteJSONString(b);
+        }
 
-		public override void WriteBinary(byte[] bin)
-		{
-			WriteJSONBase64(bin);
-		}
+        public override void WriteBinary(byte[] bin)
+        {
+            WriteJSONBase64(bin);
+        }
 
-		/**
-		 * Reading methods.
-		 */
+        /**
+         * Reading methods.
+         */
 
-		///<summary>
-		/// Read in a JSON string, unescaping as appropriate.. Skip Reading from the
-		/// context if skipContext is true.
-		///</summary>
-		private byte[] ReadJSONString(bool skipContext)
-		{
-			MemoryStream buffer = new MemoryStream();
+        ///<summary>
+        /// Read in a JSON string, unescaping as appropriate.. Skip Reading from the
+        /// context if skipContext is true.
+        ///</summary>
+        private byte[] ReadJSONString(bool skipContext)
+        {
+            MemoryStream buffer = new MemoryStream();
 
 
-			if (!skipContext)
-			{
-				context.Read();
-			}
-			ReadJSONSyntaxChar(QUOTE);
-			while (true)
-			{
-				byte ch = reader.Read();
-				if (ch == QUOTE[0])
-				{
-					break;
-				}
+            if (!skipContext)
+            {
+                context.Read();
+            }
+            ReadJSONSyntaxChar(QUOTE);
+            while (true)
+            {
+                byte ch = reader.Read();
+                if (ch == QUOTE[0])
+                {
+                    break;
+                }
 
-				// escaped?
-				if (ch != ESCSEQ[0])
-				{
-					buffer.Write(new byte[] { (byte)ch }, 0, 1);
-					continue;
-				}
+                // escaped?
+                if (ch != ESCSEQ[0])
+                {
+                    buffer.Write(new byte[] { (byte)ch }, 0, 1);
+                    continue;
+                }
 
-				// distinguish between \uXXXX and \?
-				ch = reader.Read();
-				if (ch != ESCSEQ[1])  // control chars like \n
-				{
-					int off = Array.IndexOf(ESCAPE_CHARS, (char)ch);
-					if (off == -1)
-					{
-						throw new TProtocolException(TProtocolException.INVALID_DATA,
-														"Expected control char");
-					}
-					ch = ESCAPE_CHAR_VALS[off];
-					buffer.Write(new byte[] { (byte)ch }, 0, 1);
-					continue;
-				}
+                // distinguish between \uXXXX and \?
+                ch = reader.Read();
+                if (ch != ESCSEQ[1])  // control chars like \n
+                {
+                    int off = Array.IndexOf(ESCAPE_CHARS, (char)ch);
+                    if (off == -1)
+                    {
+                        throw new TProtocolException(TProtocolException.INVALID_DATA,
+                                                        "Expected control char");
+                    }
+                    ch = ESCAPE_CHAR_VALS[off];
+                    buffer.Write(new byte[] { (byte)ch }, 0, 1);
+                    continue;
+                }
 
 
-				// it's \uXXXX
-				trans.ReadAll(tempBuffer, 0, 4);
-				var wch = (short)((HexVal((byte)tempBuffer[0]) << 12) +
-								  (HexVal((byte)tempBuffer[1]) << 8) +
-								  (HexVal((byte)tempBuffer[2]) << 4) + 
-								   HexVal(tempBuffer[3]));
-				var tmp = utf8Encoding.GetBytes(new char[] { (char)wch });
-				buffer.Write(tmp, 0, tmp.Length);
-			}
-			return buffer.ToArray();
-		}
+                // it's \uXXXX
+                trans.ReadAll(tempBuffer, 0, 4);
+                var wch = (short)((HexVal((byte)tempBuffer[0]) << 12) +
+                                  (HexVal((byte)tempBuffer[1]) << 8) +
+                                  (HexVal((byte)tempBuffer[2]) << 4) +
+                                   HexVal(tempBuffer[3]));
+                var tmp = utf8Encoding.GetBytes(new char[] { (char)wch });
+                buffer.Write(tmp, 0, tmp.Length);
+            }
+            return buffer.ToArray();
+        }
 
-		///<summary>
-		/// Return true if the given byte could be a valid part of a JSON number.
-		///</summary>
-		private bool IsJSONNumeric(byte b)
-		{
-			switch (b)
-			{
-				case (byte)'+':
-				case (byte)'-':
-				case (byte)'.':
-				case (byte)'0':
-				case (byte)'1':
-				case (byte)'2':
-				case (byte)'3':
-				case (byte)'4':
-				case (byte)'5':
-				case (byte)'6':
-				case (byte)'7':
-				case (byte)'8':
-				case (byte)'9':
-				case (byte)'E':
-				case (byte)'e':
-					return true;
-			}
-			return false;
-		}
+        ///<summary>
+        /// Return true if the given byte could be a valid part of a JSON number.
+        ///</summary>
+        private bool IsJSONNumeric(byte b)
+        {
+            switch (b)
+            {
+                case (byte)'+':
+                case (byte)'-':
+                case (byte)'.':
+                case (byte)'0':
+                case (byte)'1':
+                case (byte)'2':
+                case (byte)'3':
+                case (byte)'4':
+                case (byte)'5':
+                case (byte)'6':
+                case (byte)'7':
+                case (byte)'8':
+                case (byte)'9':
+                case (byte)'E':
+                case (byte)'e':
+                    return true;
+            }
+            return false;
+        }
 
-		///<summary>
-		/// Read in a sequence of characters that are all valid in JSON numbers. Does
-		/// not do a complete regex check to validate that this is actually a number.
-		////</summary>
-		private String ReadJSONNumericChars()
-		{
-			StringBuilder strbld = new StringBuilder();
-			while (true)
-			{
-				byte ch = reader.Peek();
-				if (!IsJSONNumeric(ch))
-				{
-					break;
-				}
-				strbld.Append((char)reader.Read());
-			}
-			return strbld.ToString();
-		}
+        ///<summary>
+        /// Read in a sequence of characters that are all valid in JSON numbers. Does
+        /// not do a complete regex check to validate that this is actually a number.
+        ////</summary>
+        private String ReadJSONNumericChars()
+        {
+            StringBuilder strbld = new StringBuilder();
+            while (true)
+            {
+                byte ch = reader.Peek();
+                if (!IsJSONNumeric(ch))
+                {
+                    break;
+                }
+                strbld.Append((char)reader.Read());
+            }
+            return strbld.ToString();
+        }
 
-		///<summary>
-		/// Read in a JSON number. If the context dictates, Read in enclosing quotes.
-		///</summary>
-		private long ReadJSONInteger()
-		{
-			context.Read();
-			if (context.EscapeNumbers())
-			{
-				ReadJSONSyntaxChar(QUOTE);
-			}
-			String str = ReadJSONNumericChars();
-			if (context.EscapeNumbers())
-			{
-				ReadJSONSyntaxChar(QUOTE);
-			}
-			try
-			{
-				return Int64.Parse(str);
-			}
-			catch (FormatException)
-			{
-				throw new TProtocolException(TProtocolException.INVALID_DATA,
-											 "Bad data encounted in numeric data");
-			}
-		}
+        ///<summary>
+        /// Read in a JSON number. If the context dictates, Read in enclosing quotes.
+        ///</summary>
+        private long ReadJSONInteger()
+        {
+            context.Read();
+            if (context.EscapeNumbers())
+            {
+                ReadJSONSyntaxChar(QUOTE);
+            }
+            String str = ReadJSONNumericChars();
+            if (context.EscapeNumbers())
+            {
+                ReadJSONSyntaxChar(QUOTE);
+            }
+            try
+            {
+                return Int64.Parse(str);
+            }
+            catch (FormatException)
+            {
+                throw new TProtocolException(TProtocolException.INVALID_DATA,
+                                             "Bad data encounted in numeric data");
+            }
+        }
 
-		///<summary>
-		/// Read in a JSON double value. Throw if the value is not wrapped in quotes
-		/// when expected or if wrapped in quotes when not expected.
-		///</summary>
-		private double ReadJSONDouble()
-		{
-			context.Read();
-			if (reader.Peek() == QUOTE[0])
-			{
-				byte[] arr = ReadJSONString(true);
-				double dub = Double.Parse(utf8Encoding.GetString(arr,0,arr.Length), CultureInfo.InvariantCulture);
+        ///<summary>
+        /// Read in a JSON double value. Throw if the value is not wrapped in quotes
+        /// when expected or if wrapped in quotes when not expected.
+        ///</summary>
+        private double ReadJSONDouble()
+        {
+            context.Read();
+            if (reader.Peek() == QUOTE[0])
+            {
+                byte[] arr = ReadJSONString(true);
+                double dub = Double.Parse(utf8Encoding.GetString(arr,0,arr.Length), CultureInfo.InvariantCulture);
 
-				if (!context.EscapeNumbers() && !Double.IsNaN(dub) &&
-					!Double.IsInfinity(dub))
-				{
-					// Throw exception -- we should not be in a string in this case
-					throw new TProtocolException(TProtocolException.INVALID_DATA,
-												 "Numeric data unexpectedly quoted");
-				}
-				return dub;
-			}
-			else
-			{
-				if (context.EscapeNumbers())
-				{
-					// This will throw - we should have had a quote if escapeNum == true
-					ReadJSONSyntaxChar(QUOTE);
-				}
-				try
-				{
-					return Double.Parse(ReadJSONNumericChars(), CultureInfo.InvariantCulture);
-				}
-				catch (FormatException)
-				{
-					throw new TProtocolException(TProtocolException.INVALID_DATA,
-												 "Bad data encounted in numeric data");
-				}
-			}
-		}
+                if (!context.EscapeNumbers() && !Double.IsNaN(dub) &&
+                    !Double.IsInfinity(dub))
+                {
+                    // Throw exception -- we should not be in a string in this case
+                    throw new TProtocolException(TProtocolException.INVALID_DATA,
+                                                 "Numeric data unexpectedly quoted");
+                }
+                return dub;
+            }
+            else
+            {
+                if (context.EscapeNumbers())
+                {
+                    // This will throw - we should have had a quote if escapeNum == true
+                    ReadJSONSyntaxChar(QUOTE);
+                }
+                try
+                {
+                    return Double.Parse(ReadJSONNumericChars(), CultureInfo.InvariantCulture);
+                }
+                catch (FormatException)
+                {
+                    throw new TProtocolException(TProtocolException.INVALID_DATA,
+                                                 "Bad data encounted in numeric data");
+                }
+            }
+        }
 
-		//<summary>
-		/// Read in a JSON string containing base-64 encoded data and decode it.
-		///</summary>
-		private byte[] ReadJSONBase64()
-		{
-			byte[] b = ReadJSONString(false);
-			int len = b.Length;
-			int off = 0;
-			int size = 0;
-			// reduce len to ignore fill bytes 
-			while ((len > 0) && (b[len - 1] == '='))
-			{
-				--len;
-			}
-			// read & decode full byte triplets = 4 source bytes
-			while (len > 4)
-			{
-				// Decode 4 bytes at a time
-				TBase64Utils.decode(b, off, 4, b, size); // NB: decoded in place
-				off += 4;
-				len -= 4;
-				size += 3;
-			}
-			// Don't decode if we hit the end or got a single leftover byte (invalid
-			// base64 but legal for skip of regular string type)
-			if (len > 1)
-			{
-				// Decode remainder
-				TBase64Utils.decode(b, off, len, b, size); // NB: decoded in place
-				size += len - 1;
-			}
-			// Sadly we must copy the byte[] (any way around this?)
-			byte[] result = new byte[size];
-			Array.Copy(b, 0, result, 0, size);
-			return result;
-		}
+        //<summary>
+        /// Read in a JSON string containing base-64 encoded data and decode it.
+        ///</summary>
+        private byte[] ReadJSONBase64()
+        {
+            byte[] b = ReadJSONString(false);
+            int len = b.Length;
+            int off = 0;
+            int size = 0;
+            // reduce len to ignore fill bytes
+            while ((len > 0) && (b[len - 1] == '='))
+            {
+                --len;
+            }
+            // read & decode full byte triplets = 4 source bytes
+            while (len > 4)
+            {
+                // Decode 4 bytes at a time
+                TBase64Utils.decode(b, off, 4, b, size); // NB: decoded in place
+                off += 4;
+                len -= 4;
+                size += 3;
+            }
+            // Don't decode if we hit the end or got a single leftover byte (invalid
+            // base64 but legal for skip of regular string type)
+            if (len > 1)
+            {
+                // Decode remainder
+                TBase64Utils.decode(b, off, len, b, size); // NB: decoded in place
+                size += len - 1;
+            }
+            // Sadly we must copy the byte[] (any way around this?)
+            byte[] result = new byte[size];
+            Array.Copy(b, 0, result, 0, size);
+            return result;
+        }
 
-		private void ReadJSONObjectStart()
-		{
-			context.Read();
-			ReadJSONSyntaxChar(LBRACE);
-			PushContext(new JSONPairContext(this));
-		}
+        private void ReadJSONObjectStart()
+        {
+            context.Read();
+            ReadJSONSyntaxChar(LBRACE);
+            PushContext(new JSONPairContext(this));
+        }
 
-		private void ReadJSONObjectEnd()
-		{
-			ReadJSONSyntaxChar(RBRACE);
-			PopContext();
-		}
+        private void ReadJSONObjectEnd()
+        {
+            ReadJSONSyntaxChar(RBRACE);
+            PopContext();
+        }
 
-		private void ReadJSONArrayStart()
-		{
-			context.Read();
-			ReadJSONSyntaxChar(LBRACKET);
-			PushContext(new JSONListContext(this));
-		}
+        private void ReadJSONArrayStart()
+        {
+            context.Read();
+            ReadJSONSyntaxChar(LBRACKET);
+            PushContext(new JSONListContext(this));
+        }
 
-		private void ReadJSONArrayEnd()
-		{
-			ReadJSONSyntaxChar(RBRACKET);
-			PopContext();
-		}
+        private void ReadJSONArrayEnd()
+        {
+            ReadJSONSyntaxChar(RBRACKET);
+            PopContext();
+        }
 
-		public override TMessage ReadMessageBegin()
-		{
-			TMessage message = new TMessage();
-			ReadJSONArrayStart();
-			if (ReadJSONInteger() != VERSION)
-			{
-				throw new TProtocolException(TProtocolException.BAD_VERSION,
-											 "Message contained bad version.");
-			}
+        public override TMessage ReadMessageBegin()
+        {
+            TMessage message = new TMessage();
+            ReadJSONArrayStart();
+            if (ReadJSONInteger() != VERSION)
+            {
+                throw new TProtocolException(TProtocolException.BAD_VERSION,
+                                             "Message contained bad version.");
+            }
 
             var buf = ReadJSONString(false);
-			message.Name = utf8Encoding.GetString(buf,0,buf.Length);
-			message.Type = (TMessageType)ReadJSONInteger();
-			message.SeqID = (int)ReadJSONInteger();
-			return message;
-		}
+            message.Name = utf8Encoding.GetString(buf,0,buf.Length);
+            message.Type = (TMessageType)ReadJSONInteger();
+            message.SeqID = (int)ReadJSONInteger();
+            return message;
+        }
 
-		public override void ReadMessageEnd()
-		{
-			ReadJSONArrayEnd();
-		}
+        public override void ReadMessageEnd()
+        {
+            ReadJSONArrayEnd();
+        }
 
-		public override TStruct ReadStructBegin()
-		{
-			ReadJSONObjectStart();
-			return new TStruct();
-		}
+        public override TStruct ReadStructBegin()
+        {
+            ReadJSONObjectStart();
+            return new TStruct();
+        }
 
-		public override void ReadStructEnd()
-		{
-			ReadJSONObjectEnd();
-		}
+        public override void ReadStructEnd()
+        {
+            ReadJSONObjectEnd();
+        }
 
-		public override TField ReadFieldBegin()
-		{
-			TField field = new TField();
-			byte ch = reader.Peek();
-			if (ch == RBRACE[0])
-			{
-				field.Type = TType.Stop;
-			}
-			else
-			{
-				field.ID = (short)ReadJSONInteger();
-				ReadJSONObjectStart();
-				field.Type = GetTypeIDForTypeName(ReadJSONString(false));
-			}
-			return field;
-		}
+        public override TField ReadFieldBegin()
+        {
+            TField field = new TField();
+            byte ch = reader.Peek();
+            if (ch == RBRACE[0])
+            {
+                field.Type = TType.Stop;
+            }
+            else
+            {
+                field.ID = (short)ReadJSONInteger();
+                ReadJSONObjectStart();
+                field.Type = GetTypeIDForTypeName(ReadJSONString(false));
+            }
+            return field;
+        }
 
-		public override void ReadFieldEnd()
-		{
-			ReadJSONObjectEnd();
-		}
+        public override void ReadFieldEnd()
+        {
+            ReadJSONObjectEnd();
+        }
 
-		public override TMap ReadMapBegin()
-		{
-			TMap map = new TMap();
-			ReadJSONArrayStart();
-			map.KeyType = GetTypeIDForTypeName(ReadJSONString(false));
-			map.ValueType = GetTypeIDForTypeName(ReadJSONString(false));
-			map.Count = (int)ReadJSONInteger();
-			ReadJSONObjectStart();
-			return map;
-		}
+        public override TMap ReadMapBegin()
+        {
+            TMap map = new TMap();
+            ReadJSONArrayStart();
+            map.KeyType = GetTypeIDForTypeName(ReadJSONString(false));
+            map.ValueType = GetTypeIDForTypeName(ReadJSONString(false));
+            map.Count = (int)ReadJSONInteger();
+            ReadJSONObjectStart();
+            return map;
+        }
 
-		public override void ReadMapEnd()
-		{
-			ReadJSONObjectEnd();
-			ReadJSONArrayEnd();
-		}
+        public override void ReadMapEnd()
+        {
+            ReadJSONObjectEnd();
+            ReadJSONArrayEnd();
+        }
 
-		public override TList ReadListBegin()
-		{
-			TList list = new TList();
-			ReadJSONArrayStart();
-			list.ElementType = GetTypeIDForTypeName(ReadJSONString(false));
-			list.Count = (int)ReadJSONInteger();
-			return list;
-		}
+        public override TList ReadListBegin()
+        {
+            TList list = new TList();
+            ReadJSONArrayStart();
+            list.ElementType = GetTypeIDForTypeName(ReadJSONString(false));
+            list.Count = (int)ReadJSONInteger();
+            return list;
+        }
 
-		public override void ReadListEnd()
-		{
-			ReadJSONArrayEnd();
-		}
+        public override void ReadListEnd()
+        {
+            ReadJSONArrayEnd();
+        }
 
-		public override TSet ReadSetBegin()
-		{
-			TSet set = new TSet();
-			ReadJSONArrayStart();
-			set.ElementType = GetTypeIDForTypeName(ReadJSONString(false));
-			set.Count = (int)ReadJSONInteger();
-			return set;
-		}
+        public override TSet ReadSetBegin()
+        {
+            TSet set = new TSet();
+            ReadJSONArrayStart();
+            set.ElementType = GetTypeIDForTypeName(ReadJSONString(false));
+            set.Count = (int)ReadJSONInteger();
+            return set;
+        }
 
-		public override void ReadSetEnd()
-		{
-			ReadJSONArrayEnd();
-		}
+        public override void ReadSetEnd()
+        {
+            ReadJSONArrayEnd();
+        }
 
-		public override bool ReadBool()
-		{
-			return (ReadJSONInteger() == 0 ? false : true);
-		}
+        public override bool ReadBool()
+        {
+            return (ReadJSONInteger() == 0 ? false : true);
+        }
 
-		public override sbyte ReadByte()
-		{
-			return (sbyte)ReadJSONInteger();
-		}
+        public override sbyte ReadByte()
+        {
+            return (sbyte)ReadJSONInteger();
+        }
 
-		public override short ReadI16()
-		{
-			return (short)ReadJSONInteger();
-		}
+        public override short ReadI16()
+        {
+            return (short)ReadJSONInteger();
+        }
 
-		public override int ReadI32()
-		{
-			return (int)ReadJSONInteger();
-		}
+        public override int ReadI32()
+        {
+            return (int)ReadJSONInteger();
+        }
 
-		public override long ReadI64()
-		{
-			return (long)ReadJSONInteger();
-		}
+        public override long ReadI64()
+        {
+            return (long)ReadJSONInteger();
+        }
 
-		public override double ReadDouble()
-		{
-			return ReadJSONDouble();
-		}
+        public override double ReadDouble()
+        {
+            return ReadJSONDouble();
+        }
 
-		public override String ReadString()
-		{
+        public override String ReadString()
+        {
             var buf = ReadJSONString(false);
-			return utf8Encoding.GetString(buf,0,buf.Length);
-		}
+            return utf8Encoding.GetString(buf,0,buf.Length);
+        }
 
-		public override byte[] ReadBinary()
-		{
-			return ReadJSONBase64();
-		}
+        public override byte[] ReadBinary()
+        {
+            return ReadJSONBase64();
+        }
 
-	}
+    }
 }
diff --git a/lib/csharp/src/Protocol/TList.cs b/lib/csharp/src/Protocol/TList.cs
index a651eb1..0c8f214 100644
--- a/lib/csharp/src/Protocol/TList.cs
+++ b/lib/csharp/src/Protocol/TList.cs
@@ -27,28 +27,28 @@
 
 namespace Thrift.Protocol
 {
-	public struct TList
-	{
-		private TType elementType;
-		private int count;
+    public struct TList
+    {
+        private TType elementType;
+        private int count;
 
-		public TList(TType elementType, int count)
-			:this()
-		{
-			this.elementType = elementType;
-			this.count = count;
-		}
+        public TList(TType elementType, int count)
+            :this()
+        {
+            this.elementType = elementType;
+            this.count = count;
+        }
 
-		public TType ElementType
-		{
-			get { return elementType; }
-			set { elementType = value; }
-		}
+        public TType ElementType
+        {
+            get { return elementType; }
+            set { elementType = value; }
+        }
 
-		public int Count
-		{
-			get { return count; }
-			set { count = value; }
-		}
-	}
+        public int Count
+        {
+            get { return count; }
+            set { count = value; }
+        }
+    }
 }
diff --git a/lib/csharp/src/Protocol/TMap.cs b/lib/csharp/src/Protocol/TMap.cs
index 5c8d650..aba9d3a 100644
--- a/lib/csharp/src/Protocol/TMap.cs
+++ b/lib/csharp/src/Protocol/TMap.cs
@@ -27,36 +27,36 @@
 
 namespace Thrift.Protocol
 {
-	public struct TMap
-	{
-		private TType keyType;
-		private TType valueType;
-		private int count;
+    public struct TMap
+    {
+        private TType keyType;
+        private TType valueType;
+        private int count;
 
-		public TMap(TType keyType, TType valueType, int count)
-			:this()
-		{
-			this.keyType = keyType;
-			this.valueType = valueType;
-			this.count = count;
-		}
+        public TMap(TType keyType, TType valueType, int count)
+            :this()
+        {
+            this.keyType = keyType;
+            this.valueType = valueType;
+            this.count = count;
+        }
 
-		public TType KeyType
-		{
-			get { return keyType; }
-			set { keyType = value; }
-		}
+        public TType KeyType
+        {
+            get { return keyType; }
+            set { keyType = value; }
+        }
 
-		public TType ValueType
-		{
-			get { return valueType; }
-			set { valueType = value; }
-		}
+        public TType ValueType
+        {
+            get { return valueType; }
+            set { valueType = value; }
+        }
 
-		public int Count
-		{
-			get { return count; }
-			set { count = value; }
-		}
-	}
+        public int Count
+        {
+            get { return count; }
+            set { count = value; }
+        }
+    }
 }
diff --git a/lib/csharp/src/Protocol/TMessage.cs b/lib/csharp/src/Protocol/TMessage.cs
index 8e96da5..348263c 100644
--- a/lib/csharp/src/Protocol/TMessage.cs
+++ b/lib/csharp/src/Protocol/TMessage.cs
@@ -27,36 +27,36 @@
 
 namespace Thrift.Protocol
 {
-	public struct TMessage
-	{
-		private string name;
-		private TMessageType type;
-		private int seqID;
+    public struct TMessage
+    {
+        private string name;
+        private TMessageType type;
+        private int seqID;
 
-		public TMessage(string name, TMessageType type, int seqid)
-			:this()
-		{
-			this.name = name;
-			this.type = type;
-			this.seqID = seqid;
-		}
+        public TMessage(string name, TMessageType type, int seqid)
+            :this()
+        {
+            this.name = name;
+            this.type = type;
+            this.seqID = seqid;
+        }
 
-		public string Name
-		{
-			get { return name; }
-			set { name = value; }
-		}
+        public string Name
+        {
+            get { return name; }
+            set { name = value; }
+        }
 
-		public TMessageType Type
-		{
-			get { return type; }
-			set { type = value; }
-		}
+        public TMessageType Type
+        {
+            get { return type; }
+            set { type = value; }
+        }
 
-		public int SeqID
-		{
-			get { return seqID; }
-			set { seqID = value; }
-		}
-	}
+        public int SeqID
+        {
+            get { return seqID; }
+            set { seqID = value; }
+        }
+    }
 }
diff --git a/lib/csharp/src/Protocol/TMessageType.cs b/lib/csharp/src/Protocol/TMessageType.cs
index ab07cf6..c7091fe 100644
--- a/lib/csharp/src/Protocol/TMessageType.cs
+++ b/lib/csharp/src/Protocol/TMessageType.cs
@@ -21,11 +21,11 @@
 
 namespace Thrift.Protocol
 {
-	public enum TMessageType
-	{
-		Call = 1,
-		Reply = 2,
-		Exception = 3,
-		Oneway = 4
-	}
+    public enum TMessageType
+    {
+        Call = 1,
+        Reply = 2,
+        Exception = 3,
+        Oneway = 4
+    }
 }
diff --git a/lib/csharp/src/Protocol/TMultiplexedProcessor.cs b/lib/csharp/src/Protocol/TMultiplexedProcessor.cs
index 4ce8d62..050b162 100644
--- a/lib/csharp/src/Protocol/TMultiplexedProcessor.cs
+++ b/lib/csharp/src/Protocol/TMultiplexedProcessor.cs
@@ -27,12 +27,12 @@
 using System.Collections.Generic;
 using System.IO;
 
-namespace Thrift.Protocol 
+namespace Thrift.Protocol
 {
 
     /**
      * TMultiplexedProcessor is a TProcessor allowing a single TServer to provide multiple services.
-     * To do so, you instantiate the processor and then register additional processors with it, 
+     * To do so, you instantiate the processor and then register additional processors with it,
      * as shown in the following example:
      *
      *     TMultiplexedProcessor processor = new TMultiplexedProcessor();
@@ -50,26 +50,26 @@
      *
      *     server.serve();
      */
-    public class TMultiplexedProcessor : TProcessor 
+    public class TMultiplexedProcessor : TProcessor
     {
         private Dictionary<String,TProcessor> ServiceProcessorMap = new Dictionary<String,TProcessor>();
 
         /**
-         * 'Register' a service with this TMultiplexedProcessor. This allows us to broker 
+         * 'Register' a service with this TMultiplexedProcessor. This allows us to broker
          * requests to individual services by using the service name to select them at request time.
          *
-         * Args: 
+         * Args:
          * - serviceName    Name of a service, has to be identical to the name
          *                  declared in the Thrift IDL, e.g. "WeatherReport".
-         * - processor      Implementation of a service, ususally referred to as "handlers", 
+         * - processor      Implementation of a service, ususally referred to as "handlers",
          *                  e.g. WeatherReportHandler implementing WeatherReport.Iface.
          */
-        public void RegisterProcessor(String serviceName, TProcessor processor) 
+        public void RegisterProcessor(String serviceName, TProcessor processor)
         {
             ServiceProcessorMap.Add(serviceName, processor);
         }
 
-        
+
         private void Fail( TProtocol oprot, TMessage message, TApplicationException.ExceptionType extype, string etxt)
         {
             TApplicationException appex = new TApplicationException( extype, etxt);
@@ -81,8 +81,8 @@
             oprot.WriteMessageEnd();
             oprot.Transport.Flush();
         }
-            
-        
+
+
         /**
          * This implementation of process performs the following steps:
          *
@@ -91,11 +91,11 @@
          * - Using the service name to locate the appropriate processor.
          * - Dispatch to the processor, with a decorated instance of TProtocol
          *    that allows readMessageBegin() to return the original TMessage.
-         *  
-         * Throws an exception if 
-         * - the message type is not CALL or ONEWAY, 
-         * - the service name was not found in the message, or 
-         * - the service name has not been RegisterProcessor()ed.  
+         *
+         * Throws an exception if
+         * - the message type is not CALL or ONEWAY,
+         * - the service name was not found in the message, or
+         * - the service name has not been RegisterProcessor()ed.
          */
         public bool Process(TProtocol iprot, TProtocol oprot)
         {
@@ -160,17 +160,17 @@
          *  to allow them to call readMessageBegin() and get a TMessage in exactly
          *  the standard format, without the service name prepended to TMessage.name.
          */
-        private class StoredMessageProtocol : TProtocolDecorator 
+        private class StoredMessageProtocol : TProtocolDecorator
         {
             TMessage MsgBegin;
 
-            public StoredMessageProtocol(TProtocol protocol, TMessage messageBegin) 
+            public StoredMessageProtocol(TProtocol protocol, TMessage messageBegin)
                 :base(protocol)
             {
                 this.MsgBegin = messageBegin;
             }
 
-            public override TMessage ReadMessageBegin()  
+            public override TMessage ReadMessageBegin()
             {
                 return MsgBegin;
             }
diff --git a/lib/csharp/src/Protocol/TMultiplexedProtocol.cs b/lib/csharp/src/Protocol/TMultiplexedProtocol.cs
index ccd7fcf..1e2af83 100644
--- a/lib/csharp/src/Protocol/TMultiplexedProtocol.cs
+++ b/lib/csharp/src/Protocol/TMultiplexedProtocol.cs
@@ -26,22 +26,22 @@
 using Thrift.Transport;
 using System.Collections.Generic;
 
-namespace Thrift.Protocol 
+namespace Thrift.Protocol
 {
 
     /**
-     * TMultiplexedProtocol is a protocol-independent concrete decorator that allows a Thrift 
-     * client to communicate with a multiplexing Thrift server, by prepending the service name 
+     * TMultiplexedProtocol is a protocol-independent concrete decorator that allows a Thrift
+     * client to communicate with a multiplexing Thrift server, by prepending the service name
      * to the function name during function calls.
      *
-     * NOTE: THIS IS NOT TO BE USED BY SERVERS.  
+     * NOTE: THIS IS NOT TO BE USED BY SERVERS.
      * On the server, use TMultiplexedProcessor to handle requests from a multiplexing client.
      *
      * This example uses a single socket transport to invoke two services:
      *
      *     TSocket transport = new TSocket("localhost", 9090);
      *     transport.open();
-     *     
+     *
      *     TBinaryProtocol protocol = new TBinaryProtocol(transport);
      *
      *     TMultiplexedProtocol mp = new TMultiplexedProtocol(protocol, "Calculator");
@@ -54,7 +54,7 @@
      *     System.out.println(service2.getTemperature());
      *
      */
-    public class TMultiplexedProtocol : TProtocolDecorator 
+    public class TMultiplexedProtocol : TProtocolDecorator
     {
 
         /** Used to delimit the service name from the function name */
@@ -72,7 +72,7 @@
          *  protocol        Your communication protocol of choice, e.g. TBinaryProtocol
          *  serviceName     The service name of the service communicating via this protocol.
          */
-        public TMultiplexedProtocol(TProtocol protocol, String serviceName) 
+        public TMultiplexedProtocol(TProtocol protocol, String serviceName)
             : base(protocol)
         {
             ServiceName = serviceName;
@@ -83,7 +83,7 @@
          * Args:
          *   tMessage     The original message.
          */
-        public override void WriteMessageBegin(TMessage tMessage) 
+        public override void WriteMessageBegin(TMessage tMessage)
         {
             switch(tMessage.Type)
             {
diff --git a/lib/csharp/src/Protocol/TProtocol.cs b/lib/csharp/src/Protocol/TProtocol.cs
index 70920d4..1f5bd81 100644
--- a/lib/csharp/src/Protocol/TProtocol.cs
+++ b/lib/csharp/src/Protocol/TProtocol.cs
@@ -27,19 +27,19 @@
 
 namespace Thrift.Protocol
 {
-	public abstract class TProtocol : IDisposable
-	{
-		protected TTransport trans;
+    public abstract class TProtocol : IDisposable
+    {
+        protected TTransport trans;
 
-		protected TProtocol(TTransport trans)
-		{
-			this.trans = trans;
-		}
+        protected TProtocol(TTransport trans)
+        {
+            this.trans = trans;
+        }
 
-		public TTransport Transport
-		{
-			get { return trans; }
-		}
+        public TTransport Transport
+        {
+            get { return trans; }
+        }
 
         #region " IDisposable Support "
         private bool _IsDisposed;
@@ -64,52 +64,52 @@
         }
         #endregion
 
-		public abstract void WriteMessageBegin(TMessage message);
-		public abstract void WriteMessageEnd();
-		public abstract void WriteStructBegin(TStruct struc);
-		public abstract void WriteStructEnd();
-		public abstract void WriteFieldBegin(TField field);
-		public abstract void WriteFieldEnd();
-		public abstract void WriteFieldStop();
-		public abstract void WriteMapBegin(TMap map);
-		public abstract void WriteMapEnd();
-		public abstract void WriteListBegin(TList list);
-		public abstract void WriteListEnd();
-		public abstract void WriteSetBegin(TSet set);
-		public abstract void WriteSetEnd();
-		public abstract void WriteBool(bool b);
-		public abstract void WriteByte(sbyte b);
-		public abstract void WriteI16(short i16);
-		public abstract void WriteI32(int i32);
-		public abstract void WriteI64(long i64);
-		public abstract void WriteDouble(double d);
-		public virtual void WriteString(string s) {
-			WriteBinary(Encoding.UTF8.GetBytes(s));
-		}
-		public abstract void WriteBinary(byte[] b);
+        public abstract void WriteMessageBegin(TMessage message);
+        public abstract void WriteMessageEnd();
+        public abstract void WriteStructBegin(TStruct struc);
+        public abstract void WriteStructEnd();
+        public abstract void WriteFieldBegin(TField field);
+        public abstract void WriteFieldEnd();
+        public abstract void WriteFieldStop();
+        public abstract void WriteMapBegin(TMap map);
+        public abstract void WriteMapEnd();
+        public abstract void WriteListBegin(TList list);
+        public abstract void WriteListEnd();
+        public abstract void WriteSetBegin(TSet set);
+        public abstract void WriteSetEnd();
+        public abstract void WriteBool(bool b);
+        public abstract void WriteByte(sbyte b);
+        public abstract void WriteI16(short i16);
+        public abstract void WriteI32(int i32);
+        public abstract void WriteI64(long i64);
+        public abstract void WriteDouble(double d);
+        public virtual void WriteString(string s) {
+            WriteBinary(Encoding.UTF8.GetBytes(s));
+        }
+        public abstract void WriteBinary(byte[] b);
 
-		public abstract TMessage ReadMessageBegin();
-		public abstract void ReadMessageEnd();
-		public abstract TStruct ReadStructBegin();
-		public abstract void ReadStructEnd();
-		public abstract TField ReadFieldBegin();
-		public abstract void ReadFieldEnd();
-		public abstract TMap ReadMapBegin();
-		public abstract void ReadMapEnd();
-		public abstract TList ReadListBegin();
-		public abstract void ReadListEnd();
-		public abstract TSet ReadSetBegin();
-		public abstract void ReadSetEnd();
-		public abstract bool ReadBool();
-		public abstract sbyte ReadByte();
-		public abstract short ReadI16();
-		public abstract int ReadI32();
-		public abstract long ReadI64();
-		public abstract double ReadDouble();
-		public virtual string ReadString() {
+        public abstract TMessage ReadMessageBegin();
+        public abstract void ReadMessageEnd();
+        public abstract TStruct ReadStructBegin();
+        public abstract void ReadStructEnd();
+        public abstract TField ReadFieldBegin();
+        public abstract void ReadFieldEnd();
+        public abstract TMap ReadMapBegin();
+        public abstract void ReadMapEnd();
+        public abstract TList ReadListBegin();
+        public abstract void ReadListEnd();
+        public abstract TSet ReadSetBegin();
+        public abstract void ReadSetEnd();
+        public abstract bool ReadBool();
+        public abstract sbyte ReadByte();
+        public abstract short ReadI16();
+        public abstract int ReadI32();
+        public abstract long ReadI64();
+        public abstract double ReadDouble();
+        public virtual string ReadString() {
             var buf = ReadBinary();
             return Encoding.UTF8.GetString(buf, 0, buf.Length);
         }
-		public abstract byte[] ReadBinary();
-	}
+        public abstract byte[] ReadBinary();
+    }
 }
diff --git a/lib/csharp/src/Protocol/TProtocolDecorator.cs b/lib/csharp/src/Protocol/TProtocolDecorator.cs
index 218a5c1..7bc34ef 100644
--- a/lib/csharp/src/Protocol/TProtocolDecorator.cs
+++ b/lib/csharp/src/Protocol/TProtocolDecorator.cs
@@ -26,19 +26,19 @@
 using Thrift.Transport;
 using System.Collections.Generic;
 
-namespace Thrift.Protocol 
+namespace Thrift.Protocol
 {
 
     /**
-     * TProtocolDecorator forwards all requests to an enclosed TProtocol instance, 
-     * providing a way to author concise concrete decorator subclasses.  While it has 
-     * no abstract methods, it is marked abstract as a reminder that by itself, 
+     * TProtocolDecorator forwards all requests to an enclosed TProtocol instance,
+     * providing a way to author concise concrete decorator subclasses.  While it has
+     * no abstract methods, it is marked abstract as a reminder that by itself,
      * it does not modify the behaviour of the enclosed TProtocol.
      *
      * See p.175 of Design Patterns (by Gamma et al.)
      * See TMultiplexedProtocol
      */
-    public abstract class TProtocolDecorator : TProtocol 
+    public abstract class TProtocolDecorator : TProtocol
     {
         private TProtocol WrappedProtocol;
 
@@ -46,14 +46,14 @@
          * Encloses the specified protocol.
          * @param protocol All operations will be forward to this protocol.  Must be non-null.
          */
-        public TProtocolDecorator(TProtocol protocol) 
+        public TProtocolDecorator(TProtocol protocol)
             : base( protocol.Transport)
         {
-            
+
             WrappedProtocol = protocol;
         }
 
-        public override void WriteMessageBegin(TMessage tMessage) 
+        public override void WriteMessageBegin(TMessage tMessage)
         {
             WrappedProtocol.WriteMessageBegin(tMessage);
         }
@@ -88,7 +88,7 @@
             WrappedProtocol.WriteFieldStop();
         }
 
-        public override void WriteMapBegin(TMap tMap) 
+        public override void WriteMapBegin(TMap tMap)
         {
             WrappedProtocol.WriteMapBegin(tMap);
         }
@@ -98,7 +98,7 @@
             WrappedProtocol.WriteMapEnd();
         }
 
-        public override void WriteListBegin(TList tList)  
+        public override void WriteListBegin(TList tList)
         {
             WrappedProtocol.WriteListBegin(tList);
         }
@@ -108,7 +108,7 @@
             WrappedProtocol.WriteListEnd();
         }
 
-        public override void WriteSetBegin(TSet tSet)  
+        public override void WriteSetBegin(TSet tSet)
         {
             WrappedProtocol.WriteSetBegin(tSet);
         }
@@ -118,7 +118,7 @@
             WrappedProtocol.WriteSetEnd();
         }
 
-        public override void WriteBool(bool b)  
+        public override void WriteBool(bool b)
         {
             WrappedProtocol.WriteBool(b);
         }
diff --git a/lib/csharp/src/Protocol/TProtocolException.cs b/lib/csharp/src/Protocol/TProtocolException.cs
index 05eb2db..76c749d 100644
--- a/lib/csharp/src/Protocol/TProtocolException.cs
+++ b/lib/csharp/src/Protocol/TProtocolException.cs
@@ -25,43 +25,43 @@
 
 namespace Thrift.Protocol
 {
-	public class TProtocolException : TException
-	{
-		public const int UNKNOWN = 0;
-		public const int INVALID_DATA = 1;
-		public const int NEGATIVE_SIZE = 2;
-		public const int SIZE_LIMIT = 3;
-		public const int BAD_VERSION = 4;
-		public const int NOT_IMPLEMENTED = 5;
-		public const int DEPTH_LIMIT = 6;
+    public class TProtocolException : TException
+    {
+        public const int UNKNOWN = 0;
+        public const int INVALID_DATA = 1;
+        public const int NEGATIVE_SIZE = 2;
+        public const int SIZE_LIMIT = 3;
+        public const int BAD_VERSION = 4;
+        public const int NOT_IMPLEMENTED = 5;
+        public const int DEPTH_LIMIT = 6;
 
-		protected int type_ = UNKNOWN;
+        protected int type_ = UNKNOWN;
 
-		public TProtocolException()
-			: base()
-		{
-		}
+        public TProtocolException()
+            : base()
+        {
+        }
 
-		public TProtocolException(int type)
-			: base()
-		{
-			type_ = type;
-		}
+        public TProtocolException(int type)
+            : base()
+        {
+            type_ = type;
+        }
 
-		public TProtocolException(int type, String message)
-			: base(message)
-		{
-			type_ = type;
-		}
+        public TProtocolException(int type, String message)
+            : base(message)
+        {
+            type_ = type;
+        }
 
-		public TProtocolException(String message)
-			: base(message)
-		{
-		}
+        public TProtocolException(String message)
+            : base(message)
+        {
+        }
 
-		public int getType()
-		{
-			return type_;
-		}
-	}
+        public int getType()
+        {
+            return type_;
+        }
+    }
 }
diff --git a/lib/csharp/src/Protocol/TProtocolFactory.cs b/lib/csharp/src/Protocol/TProtocolFactory.cs
index ebc7367..71360a1 100644
--- a/lib/csharp/src/Protocol/TProtocolFactory.cs
+++ b/lib/csharp/src/Protocol/TProtocolFactory.cs
@@ -26,8 +26,8 @@
 
 namespace Thrift.Protocol
 {
-	public interface TProtocolFactory
-	{
-		TProtocol GetProtocol(TTransport trans);
-	}
+    public interface TProtocolFactory
+    {
+        TProtocol GetProtocol(TTransport trans);
+    }
 }
diff --git a/lib/csharp/src/Protocol/TProtocolUtil.cs b/lib/csharp/src/Protocol/TProtocolUtil.cs
index 82cd3e3..91140d3 100644
--- a/lib/csharp/src/Protocol/TProtocolUtil.cs
+++ b/lib/csharp/src/Protocol/TProtocolUtil.cs
@@ -25,74 +25,74 @@
 
 namespace Thrift.Protocol
 {
-	public static class TProtocolUtil
-	{
-		public static void Skip(TProtocol prot, TType type)
-		{
-			switch (type)
-			{
-				case TType.Bool:
-					prot.ReadBool();
-					break;
-				case TType.Byte:
-					prot.ReadByte();
-					break;
-				case TType.I16:
-					prot.ReadI16();
-					break;
-				case TType.I32:
-					prot.ReadI32();
-					break;
-				case TType.I64:
-					prot.ReadI64();
-					break;
-				case TType.Double:
-					prot.ReadDouble();
-					break;
-				case TType.String:
-					// Don't try to decode the string, just skip it.
-					prot.ReadBinary();
-					break;
-				case TType.Struct:
-					prot.ReadStructBegin();
-					while (true)
-					{
-						TField field = prot.ReadFieldBegin();
-						if (field.Type == TType.Stop)
-						{
-							break;
-						}
-						Skip(prot, field.Type);
-						prot.ReadFieldEnd();
-					}
-					prot.ReadStructEnd();
-					break;
-				case TType.Map:
-					TMap map = prot.ReadMapBegin();
-					for (int i = 0; i < map.Count; i++)
-					{
-						Skip(prot, map.KeyType);
-						Skip(prot, map.ValueType);
-					}
-					prot.ReadMapEnd();
-					break;
-				case TType.Set:
-					TSet set = prot.ReadSetBegin();
-					for (int i = 0; i < set.Count; i++)
-					{
-						Skip(prot, set.ElementType);
-					}
-					prot.ReadSetEnd();
-					break;
-				case TType.List:
-					TList list = prot.ReadListBegin();
-					for (int i = 0; i < list.Count; i++)
-					{
-						Skip(prot, list.ElementType);
-					}
-					prot.ReadListEnd();
-					break;
-			}
-		}
-	}
+    public static class TProtocolUtil
+    {
+        public static void Skip(TProtocol prot, TType type)
+        {
+            switch (type)
+            {
+                case TType.Bool:
+                    prot.ReadBool();
+                    break;
+                case TType.Byte:
+                    prot.ReadByte();
+                    break;
+                case TType.I16:
+                    prot.ReadI16();
+                    break;
+                case TType.I32:
+                    prot.ReadI32();
+                    break;
+                case TType.I64:
+                    prot.ReadI64();
+                    break;
+                case TType.Double:
+                    prot.ReadDouble();
+                    break;
+                case TType.String:
+                    // Don't try to decode the string, just skip it.
+                    prot.ReadBinary();
+                    break;
+                case TType.Struct:
+                    prot.ReadStructBegin();
+                    while (true)
+                    {
+                        TField field = prot.ReadFieldBegin();
+                        if (field.Type == TType.Stop)
+                        {
+                            break;
+                        }
+                        Skip(prot, field.Type);
+                        prot.ReadFieldEnd();
+                    }
+                    prot.ReadStructEnd();
+                    break;
+                case TType.Map:
+                    TMap map = prot.ReadMapBegin();
+                    for (int i = 0; i < map.Count; i++)
+                    {
+                        Skip(prot, map.KeyType);
+                        Skip(prot, map.ValueType);
+                    }
+                    prot.ReadMapEnd();
+                    break;
+                case TType.Set:
+                    TSet set = prot.ReadSetBegin();
+                    for (int i = 0; i < set.Count; i++)
+                    {
+                        Skip(prot, set.ElementType);
+                    }
+                    prot.ReadSetEnd();
+                    break;
+                case TType.List:
+                    TList list = prot.ReadListBegin();
+                    for (int i = 0; i < list.Count; i++)
+                    {
+                        Skip(prot, list.ElementType);
+                    }
+                    prot.ReadListEnd();
+                    break;
+            }
+        }
+    }
 }
diff --git a/lib/csharp/src/Protocol/TSet.cs b/lib/csharp/src/Protocol/TSet.cs
index 68e5286..a918ab5 100644
--- a/lib/csharp/src/Protocol/TSet.cs
+++ b/lib/csharp/src/Protocol/TSet.cs
@@ -27,33 +27,33 @@
 
 namespace Thrift.Protocol
 {
-	public struct TSet
-	{
-		private TType elementType;
-		private int count;
+    public struct TSet
+    {
+        private TType elementType;
+        private int count;
 
-		public TSet(TType elementType, int count)
-			:this()
-		{
-			this.elementType = elementType;
-			this.count = count;
-		}
+        public TSet(TType elementType, int count)
+            :this()
+        {
+            this.elementType = elementType;
+            this.count = count;
+        }
 
-		public TSet(TList list)
-			: this(list.ElementType, list.Count)
-		{
-		}
+        public TSet(TList list)
+            : this(list.ElementType, list.Count)
+        {
+        }
 
-		public TType ElementType
-		{
-			get { return elementType; }
-			set { elementType = value; }
-		}
+        public TType ElementType
+        {
+            get { return elementType; }
+            set { elementType = value; }
+        }
 
-		public int Count
-		{
-			get { return count; }
-			set { count = value; }
-		}
-	}
+        public int Count
+        {
+            get { return count; }
+            set { count = value; }
+        }
+    }
 }
diff --git a/lib/csharp/src/Protocol/TStruct.cs b/lib/csharp/src/Protocol/TStruct.cs
index 37d1106..f4844a4 100644
--- a/lib/csharp/src/Protocol/TStruct.cs
+++ b/lib/csharp/src/Protocol/TStruct.cs
@@ -27,20 +27,20 @@
 
 namespace Thrift.Protocol
 {
-	public struct TStruct
-	{
-		private string name;
+    public struct TStruct
+    {
+        private string name;
 
-		public TStruct(string name)
-			:this()
-		{
-			this.name = name;
-		}
+        public TStruct(string name)
+            :this()
+        {
+            this.name = name;
+        }
 
-		public string Name
-		{
-			get { return name; }
-			set { name = value; }
-		}
-	}
+        public string Name
+        {
+            get { return name; }
+            set { name = value; }
+        }
+    }
 }
diff --git a/lib/csharp/src/Protocol/TType.cs b/lib/csharp/src/Protocol/TType.cs
index efc7bef..9ce915e 100644
--- a/lib/csharp/src/Protocol/TType.cs
+++ b/lib/csharp/src/Protocol/TType.cs
@@ -25,20 +25,20 @@
 
 namespace Thrift.Protocol
 {
-	public enum TType : byte
-	{
-		Stop = 0,
-		Void = 1,
-		Bool = 2,
-		Byte = 3,
-		Double = 4,
-		I16 = 6,
-		I32 = 8,
-		I64 = 10,
-		String = 11,
-		Struct = 12,
-		Map = 13,
-		Set = 14,
-		List = 15
-	}
+    public enum TType : byte
+    {
+        Stop = 0,
+        Void = 1,
+        Bool = 2,
+        Byte = 3,
+        Double = 4,
+        I16 = 6,
+        I32 = 8,
+        I64 = 10,
+        String = 11,
+        Struct = 12,
+        Map = 13,
+        Set = 14,
+        List = 15
+    }
 }
diff --git a/lib/csharp/src/Server/TSimpleServer.cs b/lib/csharp/src/Server/TSimpleServer.cs
index 42e0cbe..36bbe9d 100644
--- a/lib/csharp/src/Server/TSimpleServer.cs
+++ b/lib/csharp/src/Server/TSimpleServer.cs
@@ -118,7 +118,7 @@
                   //Process client requests until client disconnects
                   while (true)
                   {
-                    if (!inputTransport.Peek()) 
+                    if (!inputTransport.Peek())
                       break;
 
                     //Fire processContext server event
diff --git a/lib/csharp/src/Server/TThreadPoolServer.cs b/lib/csharp/src/Server/TThreadPoolServer.cs
index 8542b6d..aff5733 100644
--- a/lib/csharp/src/Server/TThreadPoolServer.cs
+++ b/lib/csharp/src/Server/TThreadPoolServer.cs
@@ -172,7 +172,7 @@
         //Process client requests until client disconnects
         while (true)
         {
-          if (!inputTransport.Peek()) 
+          if (!inputTransport.Peek())
             break;
 
           //Fire processContext server event
diff --git a/lib/csharp/src/Server/TThreadedServer.cs b/lib/csharp/src/Server/TThreadedServer.cs
index 87bff31..9e96371 100644
--- a/lib/csharp/src/Server/TThreadedServer.cs
+++ b/lib/csharp/src/Server/TThreadedServer.cs
@@ -204,7 +204,7 @@
             //Process client requests until client disconnects
             while (true)
             {
-              if (!inputTransport.Peek()) 
+              if (!inputTransport.Peek())
                 break;
 
               //Fire processContext server event
diff --git a/lib/csharp/src/TApplicationException.cs b/lib/csharp/src/TApplicationException.cs
index 4a1b2d2..4c0d3a3 100644
--- a/lib/csharp/src/TApplicationException.cs
+++ b/lib/csharp/src/TApplicationException.cs
@@ -26,116 +26,116 @@
 
 namespace Thrift
 {
-	public class TApplicationException : TException
-	{
-		protected ExceptionType type;
+    public class TApplicationException : TException
+    {
+        protected ExceptionType type;
 
-		public TApplicationException()
-		{
-		}
+        public TApplicationException()
+        {
+        }
 
-		public TApplicationException(ExceptionType type)
-		{
-			this.type = type;
-		}
+        public TApplicationException(ExceptionType type)
+        {
+            this.type = type;
+        }
 
-		public TApplicationException(ExceptionType type, string message)
-			: base(message)
-		{
-			this.type = type;
-		}
+        public TApplicationException(ExceptionType type, string message)
+            : base(message)
+        {
+            this.type = type;
+        }
 
-		public static TApplicationException Read(TProtocol iprot)
-		{
-			TField field;
+        public static TApplicationException Read(TProtocol iprot)
+        {
+            TField field;
 
-			string message = null;
-			ExceptionType type = ExceptionType.Unknown;
+            string message = null;
+            ExceptionType type = ExceptionType.Unknown;
 
-			iprot.ReadStructBegin();
-			while (true)
-			{
-				field = iprot.ReadFieldBegin();
-				if (field.Type == TType.Stop)
-				{
-					break;
-				}
+            iprot.ReadStructBegin();
+            while (true)
+            {
+                field = iprot.ReadFieldBegin();
+                if (field.Type == TType.Stop)
+                {
+                    break;
+                }
 
-				switch (field.ID)
-				{
-					case 1:
-						if (field.Type == TType.String)
-						{
-							message = iprot.ReadString();
-						}
-						else
-						{
-							TProtocolUtil.Skip(iprot, field.Type);
-						}
-						break;
-					case 2:
-						if (field.Type == TType.I32)
-						{
-							type = (ExceptionType)iprot.ReadI32();
-						}
-						else
-						{
-							TProtocolUtil.Skip(iprot, field.Type);
-						}
-						break;
-					default:
-						TProtocolUtil.Skip(iprot, field.Type);
-						break;
-				}
+                switch (field.ID)
+                {
+                    case 1:
+                        if (field.Type == TType.String)
+                        {
+                            message = iprot.ReadString();
+                        }
+                        else
+                        {
+                            TProtocolUtil.Skip(iprot, field.Type);
+                        }
+                        break;
+                    case 2:
+                        if (field.Type == TType.I32)
+                        {
+                            type = (ExceptionType)iprot.ReadI32();
+                        }
+                        else
+                        {
+                            TProtocolUtil.Skip(iprot, field.Type);
+                        }
+                        break;
+                    default:
+                        TProtocolUtil.Skip(iprot, field.Type);
+                        break;
+                }
 
-				iprot.ReadFieldEnd();
-			}
+                iprot.ReadFieldEnd();
+            }
 
-			iprot.ReadStructEnd();
+            iprot.ReadStructEnd();
 
-			return new TApplicationException(type, message);
-		}
+            return new TApplicationException(type, message);
+        }
 
-		public void Write(TProtocol oprot)
-		{
-			TStruct struc = new TStruct("TApplicationException");
-			TField field = new TField();
+        public void Write(TProtocol oprot)
+        {
+            TStruct struc = new TStruct("TApplicationException");
+            TField field = new TField();
 
-			oprot.WriteStructBegin(struc);
+            oprot.WriteStructBegin(struc);
 
-			if (!String.IsNullOrEmpty(Message))
-			{
-				field.Name = "message";
-				field.Type = TType.String;
-				field.ID = 1;
-				oprot.WriteFieldBegin(field);
-				oprot.WriteString(Message);
-				oprot.WriteFieldEnd();
-			}
+            if (!String.IsNullOrEmpty(Message))
+            {
+                field.Name = "message";
+                field.Type = TType.String;
+                field.ID = 1;
+                oprot.WriteFieldBegin(field);
+                oprot.WriteString(Message);
+                oprot.WriteFieldEnd();
+            }
 
-			field.Name = "type";
-			field.Type = TType.I32;
-			field.ID = 2;
-			oprot.WriteFieldBegin(field);
-			oprot.WriteI32((int)type);
-			oprot.WriteFieldEnd();
-			oprot.WriteFieldStop();
-			oprot.WriteStructEnd();
-		}
+            field.Name = "type";
+            field.Type = TType.I32;
+            field.ID = 2;
+            oprot.WriteFieldBegin(field);
+            oprot.WriteI32((int)type);
+            oprot.WriteFieldEnd();
+            oprot.WriteFieldStop();
+            oprot.WriteStructEnd();
+        }
 
-		public enum ExceptionType
-		{
-			Unknown,
-			UnknownMethod,
-			InvalidMessageType,
-			WrongMethodName,
-			BadSequenceID,
-			MissingResult,
-			InternalError,
-			ProtocolError,
-			InvalidTransform,
-			InvalidProtocol,
-			UnsupportedClientType
-		}
-	}
+        public enum ExceptionType
+        {
+            Unknown,
+            UnknownMethod,
+            InvalidMessageType,
+            WrongMethodName,
+            BadSequenceID,
+            MissingResult,
+            InternalError,
+            ProtocolError,
+            InvalidTransform,
+            InvalidProtocol,
+            UnsupportedClientType
+        }
+    }
 }
diff --git a/lib/csharp/src/TException.cs b/lib/csharp/src/TException.cs
index a99bfa8..65509ec 100644
--- a/lib/csharp/src/TException.cs
+++ b/lib/csharp/src/TException.cs
@@ -25,16 +25,16 @@
 
 namespace Thrift
 {
-	public class TException : Exception
-	{
-		public TException()
-		{
-		}
+    public class TException : Exception
+    {
+        public TException()
+        {
+        }
 
-		public TException( string message)
-			: base(message)
-		{
-		}
+        public TException( string message)
+            : base(message)
+        {
+        }
 
-	}
+    }
 }
diff --git a/lib/csharp/src/TProcessor.cs b/lib/csharp/src/TProcessor.cs
index dc1b795..71ce755 100644
--- a/lib/csharp/src/TProcessor.cs
+++ b/lib/csharp/src/TProcessor.cs
@@ -26,8 +26,8 @@
 
 namespace Thrift
 {
-	public interface TProcessor
-	{
-		bool Process(TProtocol iprot, TProtocol oprot);
-	}
+    public interface TProcessor
+    {
+        bool Process(TProtocol iprot, TProtocol oprot);
+    }
 }
diff --git a/lib/csharp/src/Thrift.WP7.csproj b/lib/csharp/src/Thrift.WP7.csproj
index d35adf4..ee4942f 100644
--- a/lib/csharp/src/Thrift.WP7.csproj
+++ b/lib/csharp/src/Thrift.WP7.csproj
@@ -108,7 +108,7 @@
   <Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.$(TargetFrameworkProfile).Overrides.targets" />
   <Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.CSharp.targets" />
   <ProjectExtensions />
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
        Other similar extension points exist, see Microsoft.Common.targets.
   <Target Name="BeforeBuild">
   </Target>
diff --git a/lib/csharp/src/Thrift.sln b/lib/csharp/src/Thrift.sln
index ee0a3e7..dd8437d 100644
--- a/lib/csharp/src/Thrift.sln
+++ b/lib/csharp/src/Thrift.sln
@@ -4,35 +4,35 @@
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Thrift", "Thrift.csproj", "{499EB63C-D74C-47E8-AE48-A2FC94538E9D}"
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ThriftTest", "..\test\ThriftTest\ThriftTest.csproj", "{48DD757F-CA95-4DD7-BDA4-58DB6F108C2C}"
-	ProjectSection(ProjectDependencies) = postProject
-		{499EB63C-D74C-47E8-AE48-A2FC94538E9D} = {499EB63C-D74C-47E8-AE48-A2FC94538E9D}
-	EndProjectSection
+    ProjectSection(ProjectDependencies) = postProject
+        {499EB63C-D74C-47E8-AE48-A2FC94538E9D} = {499EB63C-D74C-47E8-AE48-A2FC94538E9D}
+    EndProjectSection
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ThriftMSBuildTask", "..\ThriftMSBuildTask\ThriftMSBuildTask.csproj", "{EC0A0231-66EA-4593-A792-C6CA3BB8668E}"
 EndProject
 Global
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|Any CPU = Debug|Any CPU
-		Release|Any CPU = Release|Any CPU
-	EndGlobalSection
-	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{499EB63C-D74C-47E8-AE48-A2FC94538E9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{499EB63C-D74C-47E8-AE48-A2FC94538E9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{499EB63C-D74C-47E8-AE48-A2FC94538E9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{499EB63C-D74C-47E8-AE48-A2FC94538E9D}.Release|Any CPU.Build.0 = Release|Any CPU
-		{48DD757F-CA95-4DD7-BDA4-58DB6F108C2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{48DD757F-CA95-4DD7-BDA4-58DB6F108C2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{48DD757F-CA95-4DD7-BDA4-58DB6F108C2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{48DD757F-CA95-4DD7-BDA4-58DB6F108C2C}.Release|Any CPU.Build.0 = Release|Any CPU
-		{EC0A0231-66EA-4593-A792-C6CA3BB8668E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{EC0A0231-66EA-4593-A792-C6CA3BB8668E}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{EC0A0231-66EA-4593-A792-C6CA3BB8668E}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{EC0A0231-66EA-4593-A792-C6CA3BB8668E}.Release|Any CPU.Build.0 = Release|Any CPU
-	EndGlobalSection
-	GlobalSection(MonoDevelopProperties) = preSolution
-		StartupItem = Thrift.csproj
-	EndGlobalSection
-	GlobalSection(SolutionProperties) = preSolution
-		HideSolutionNode = FALSE
-	EndGlobalSection
+    GlobalSection(SolutionConfigurationPlatforms) = preSolution
+        Debug|Any CPU = Debug|Any CPU
+        Release|Any CPU = Release|Any CPU
+    EndGlobalSection
+    GlobalSection(ProjectConfigurationPlatforms) = postSolution
+        {499EB63C-D74C-47E8-AE48-A2FC94538E9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+        {499EB63C-D74C-47E8-AE48-A2FC94538E9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+        {499EB63C-D74C-47E8-AE48-A2FC94538E9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+        {499EB63C-D74C-47E8-AE48-A2FC94538E9D}.Release|Any CPU.Build.0 = Release|Any CPU
+        {48DD757F-CA95-4DD7-BDA4-58DB6F108C2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+        {48DD757F-CA95-4DD7-BDA4-58DB6F108C2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+        {48DD757F-CA95-4DD7-BDA4-58DB6F108C2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+        {48DD757F-CA95-4DD7-BDA4-58DB6F108C2C}.Release|Any CPU.Build.0 = Release|Any CPU
+        {EC0A0231-66EA-4593-A792-C6CA3BB8668E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+        {EC0A0231-66EA-4593-A792-C6CA3BB8668E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+        {EC0A0231-66EA-4593-A792-C6CA3BB8668E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+        {EC0A0231-66EA-4593-A792-C6CA3BB8668E}.Release|Any CPU.Build.0 = Release|Any CPU
+    EndGlobalSection
+    GlobalSection(MonoDevelopProperties) = preSolution
+        StartupItem = Thrift.csproj
+    EndGlobalSection
+    GlobalSection(SolutionProperties) = preSolution
+        HideSolutionNode = FALSE
+    EndGlobalSection
 EndGlobal
diff --git a/lib/csharp/src/Transport/TBufferedTransport.cs b/lib/csharp/src/Transport/TBufferedTransport.cs
index 6cb0457..89b9ca7 100644
--- a/lib/csharp/src/Transport/TBufferedTransport.cs
+++ b/lib/csharp/src/Transport/TBufferedTransport.cs
@@ -23,85 +23,85 @@
 namespace Thrift.Transport
 {
   public class TBufferedTransport : TTransport, IDisposable
-	{
-		private BufferedStream inputBuffer;
-		private BufferedStream outputBuffer;
-		private int bufSize;
-		private TStreamTransport transport;
+    {
+        private BufferedStream inputBuffer;
+        private BufferedStream outputBuffer;
+        private int bufSize;
+        private TStreamTransport transport;
 
-		public TBufferedTransport(TStreamTransport transport)
-			:this(transport, 1024)
-		{
+        public TBufferedTransport(TStreamTransport transport)
+            :this(transport, 1024)
+        {
 
-		}
+        }
 
-		public TBufferedTransport(TStreamTransport transport, int bufSize)
-		{
-			this.bufSize = bufSize;
-			this.transport = transport;
-			InitBuffers();
-		}
+        public TBufferedTransport(TStreamTransport transport, int bufSize)
+        {
+            this.bufSize = bufSize;
+            this.transport = transport;
+            InitBuffers();
+        }
 
-		private void InitBuffers()
-		{
-			if (transport.InputStream != null)
-			{
-				inputBuffer = new BufferedStream(transport.InputStream, bufSize);
-			}
-			if (transport.OutputStream != null)
-			{
-				outputBuffer = new BufferedStream(transport.OutputStream, bufSize);
-			}
-		}
+        private void InitBuffers()
+        {
+            if (transport.InputStream != null)
+            {
+                inputBuffer = new BufferedStream(transport.InputStream, bufSize);
+            }
+            if (transport.OutputStream != null)
+            {
+                outputBuffer = new BufferedStream(transport.OutputStream, bufSize);
+            }
+        }
 
-		private void CloseBuffers()
-		{
-			if (inputBuffer != null && inputBuffer.CanRead)
-			{
-				inputBuffer.Close();
-			}
-			if (outputBuffer != null && outputBuffer.CanWrite)
-			{
-				outputBuffer.Close();
-			}
-		}
+        private void CloseBuffers()
+        {
+            if (inputBuffer != null && inputBuffer.CanRead)
+            {
+                inputBuffer.Close();
+            }
+            if (outputBuffer != null && outputBuffer.CanWrite)
+            {
+                outputBuffer.Close();
+            }
+        }
 
-		public TTransport UnderlyingTransport
-		{
-			get { return transport; }
-		}
+        public TTransport UnderlyingTransport
+        {
+            get { return transport; }
+        }
 
-		public override bool IsOpen
-		{
-			get { return transport.IsOpen; }
-		}
+        public override bool IsOpen
+        {
+            get { return transport.IsOpen; }
+        }
 
-		public override void Open()
-		{
-			transport.Open();
-			InitBuffers();
-		}
+        public override void Open()
+        {
+            transport.Open();
+            InitBuffers();
+        }
 
-		public override void Close()
-		{
-			CloseBuffers();
-			transport.Close();
-		}
+        public override void Close()
+        {
+            CloseBuffers();
+            transport.Close();
+        }
 
-		public override int Read(byte[] buf, int off, int len)
-		{
-			return inputBuffer.Read(buf, off, len);
-		}
+        public override int Read(byte[] buf, int off, int len)
+        {
+            return inputBuffer.Read(buf, off, len);
+        }
 
-		public override void Write(byte[] buf, int off, int len)
-		{
-			outputBuffer.Write(buf, off, len);
-		}
+        public override void Write(byte[] buf, int off, int len)
+        {
+            outputBuffer.Write(buf, off, len);
+        }
 
-		public override void Flush()
-		{
-			outputBuffer.Flush();
-		}
+        public override void Flush()
+        {
+            outputBuffer.Flush();
+        }
 
     #region " IDisposable Support "
     private bool _IsDisposed;
diff --git a/lib/csharp/src/Transport/TFramedTransport.cs b/lib/csharp/src/Transport/TFramedTransport.cs
index aefbc09..8af227f 100644
--- a/lib/csharp/src/Transport/TFramedTransport.cs
+++ b/lib/csharp/src/Transport/TFramedTransport.cs
@@ -20,147 +20,147 @@
 using System.IO;
 
 namespace Thrift.Transport
-{ 
+{
   public class TFramedTransport : TTransport, IDisposable
-	{
-		protected TTransport transport = null;
-		protected MemoryStream writeBuffer;
-		protected MemoryStream readBuffer = null;
+    {
+        protected TTransport transport = null;
+        protected MemoryStream writeBuffer;
+        protected MemoryStream readBuffer = null;
 
-		private const int header_size = 4;
-		private static byte[] header_dummy = new byte[header_size]; // used as header placeholder while initilizing new write buffer
+        private const int header_size = 4;
+        private static byte[] header_dummy = new byte[header_size]; // used as header placeholder while initilizing new write buffer
 
-		public class Factory : TTransportFactory
-		{
-			public override TTransport GetTransport(TTransport trans)
-			{
-				return new TFramedTransport(trans);
-			}
-		}
+        public class Factory : TTransportFactory
+        {
+            public override TTransport GetTransport(TTransport trans)
+            {
+                return new TFramedTransport(trans);
+            }
+        }
 
-		protected TFramedTransport()
-		{
-			InitWriteBuffer();
-		}
+        protected TFramedTransport()
+        {
+            InitWriteBuffer();
+        }
 
-		public TFramedTransport(TTransport transport) : this()
-		{
-			this.transport = transport;
-		}
+        public TFramedTransport(TTransport transport) : this()
+        {
+            this.transport = transport;
+        }
 
-		public override void Open()
-		{
-			transport.Open();
-		}
+        public override void Open()
+        {
+            transport.Open();
+        }
 
-		public override bool IsOpen
-		{
-			get
-			{
-				return transport.IsOpen;
-			}
-		}
+        public override bool IsOpen
+        {
+            get
+            {
+                return transport.IsOpen;
+            }
+        }
 
-		public override void Close()
-		{
-			transport.Close();
-		}
+        public override void Close()
+        {
+            transport.Close();
+        }
 
-		public override int Read(byte[] buf, int off, int len)
-		{
-			if (readBuffer != null)
-			{
-				int got = readBuffer.Read(buf, off, len);
-				if (got > 0)
-				{
-					return got;
-				}
-			}
+        public override int Read(byte[] buf, int off, int len)
+        {
+            if (readBuffer != null)
+            {
+                int got = readBuffer.Read(buf, off, len);
+                if (got > 0)
+                {
+                    return got;
+                }
+            }
 
-			// Read another frame of data
-			ReadFrame();
+            // Read another frame of data
+            ReadFrame();
 
-			return readBuffer.Read(buf, off, len);
-		}
+            return readBuffer.Read(buf, off, len);
+        }
 
-		private void ReadFrame()
-		{
-			byte[] i32rd = new byte[header_size];
-			transport.ReadAll(i32rd, 0, header_size);
-			int size = DecodeFrameSize(i32rd);
+        private void ReadFrame()
+        {
+            byte[] i32rd = new byte[header_size];
+            transport.ReadAll(i32rd, 0, header_size);
+            int size = DecodeFrameSize(i32rd);
 
-			byte[] buff = new byte[size];
-			transport.ReadAll(buff, 0, size);
-			readBuffer = new MemoryStream(buff);
-		}
+            byte[] buff = new byte[size];
+            transport.ReadAll(buff, 0, size);
+            readBuffer = new MemoryStream(buff);
+        }
 
-		public override void Write(byte[] buf, int off, int len)
-		{
-			writeBuffer.Write(buf, off, len);
-		}
+        public override void Write(byte[] buf, int off, int len)
+        {
+            writeBuffer.Write(buf, off, len);
+        }
 
-		public override void Flush()
-		{
-			byte[] buf = writeBuffer.GetBuffer();
-			int len = (int)writeBuffer.Length;
-			int data_len = len - header_size;
-			if ( data_len < 0 )
-				throw new System.InvalidOperationException (); // logic error actually
+        public override void Flush()
+        {
+            byte[] buf = writeBuffer.GetBuffer();
+            int len = (int)writeBuffer.Length;
+            int data_len = len - header_size;
+            if ( data_len < 0 )
+                throw new System.InvalidOperationException (); // logic error actually
 
-			InitWriteBuffer();
+            InitWriteBuffer();
 
-			// Inject message header into the reserved buffer space
-			EncodeFrameSize(data_len,ref buf);
+            // Inject message header into the reserved buffer space
+            EncodeFrameSize(data_len,ref buf);
 
-			// Send the entire message at once
-			transport.Write(buf, 0, len);
+            // Send the entire message at once
+            transport.Write(buf, 0, len);
 
-			transport.Flush();
-		}
+            transport.Flush();
+        }
 
-		private void InitWriteBuffer ()
-		{
-			// Create new buffer instance
-			writeBuffer = new MemoryStream(1024);
+        private void InitWriteBuffer ()
+        {
+            // Create new buffer instance
+            writeBuffer = new MemoryStream(1024);
 
-			// Reserve space for message header to be put right before sending it out
-			writeBuffer.Write ( header_dummy, 0, header_size );
-		}
-		
-		private static void EncodeFrameSize(int frameSize, ref byte[] buf) 
-		{
-			buf[0] = (byte)(0xff & (frameSize >> 24));
-			buf[1] = (byte)(0xff & (frameSize >> 16));
-			buf[2] = (byte)(0xff & (frameSize >> 8));
-			buf[3] = (byte)(0xff & (frameSize));
-		}
-		
-		private static int DecodeFrameSize(byte[] buf)
-		{
-			return 
-				((buf[0] & 0xff) << 24) |
-				((buf[1] & 0xff) << 16) |
-				((buf[2] & 0xff) <<  8) |
-				((buf[3] & 0xff));
-		}
+            // Reserve space for message header to be put right before sending it out
+            writeBuffer.Write ( header_dummy, 0, header_size );
+        }
+
+        private static void EncodeFrameSize(int frameSize, ref byte[] buf)
+        {
+            buf[0] = (byte)(0xff & (frameSize >> 24));
+            buf[1] = (byte)(0xff & (frameSize >> 16));
+            buf[2] = (byte)(0xff & (frameSize >> 8));
+            buf[3] = (byte)(0xff & (frameSize));
+        }
+
+        private static int DecodeFrameSize(byte[] buf)
+        {
+            return
+                ((buf[0] & 0xff) << 24) |
+                ((buf[1] & 0xff) << 16) |
+                ((buf[2] & 0xff) <<  8) |
+                ((buf[3] & 0xff));
+        }
 
 
-		#region " IDisposable Support "
-		private bool _IsDisposed;
-		
-		// IDisposable
-		protected override void Dispose(bool disposing)
-		{
-			if (!_IsDisposed)
-			{
-				if (disposing)
-				{
-					if (readBuffer != null)
-						readBuffer.Dispose();
-				}
-			}
-			_IsDisposed = true;
-		}
-		#endregion
-	}
+        #region " IDisposable Support "
+        private bool _IsDisposed;
+
+        // IDisposable
+        protected override void Dispose(bool disposing)
+        {
+            if (!_IsDisposed)
+            {
+                if (disposing)
+                {
+                    if (readBuffer != null)
+                        readBuffer.Dispose();
+                }
+            }
+            _IsDisposed = true;
+        }
+        #endregion
+    }
 }
diff --git a/lib/csharp/src/Transport/THttpClient.cs b/lib/csharp/src/Transport/THttpClient.cs
index 1581e83..a56a3e8 100644
--- a/lib/csharp/src/Transport/THttpClient.cs
+++ b/lib/csharp/src/Transport/THttpClient.cs
@@ -7,7 +7,7 @@
  * "License"); you may not use this file except in compliance
  * with the License. You may obtain a copy of the License at
  *
- *	 http://www.apache.org/licenses/LICENSE-2.0
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
@@ -15,8 +15,8 @@
  * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
- * 
- * 
+ *
+ *
  */
 
 using System;
@@ -48,40 +48,40 @@
         private IWebProxy proxy = WebRequest.DefaultWebProxy;
 #endif
 
-        public THttpClient(Uri u) 
+        public THttpClient(Uri u)
             : this(u, Enumerable.Empty<X509Certificate>())
-		{
-		}
+        {
+        }
 
-	    public THttpClient(Uri u, IEnumerable<X509Certificate> certificates)
-	    {
-	        uri = u;
+        public THttpClient(Uri u, IEnumerable<X509Certificate> certificates)
+        {
+            uri = u;
             this.certificates = (certificates ?? Enumerable.Empty<X509Certificate>()).ToArray();
-	    }
+        }
 
         public int ConnectTimeout
-		{
-			set
-			{
-			   connectTimeout = value;
-			}
-		}
+        {
+            set
+            {
+               connectTimeout = value;
+            }
+        }
 
-		public int ReadTimeout
-		{
-			set
-			{
-				readTimeout = value;
-			}
-		}
+        public int ReadTimeout
+        {
+            set
+            {
+                readTimeout = value;
+            }
+        }
 
-		public IDictionary<String, String> CustomHeaders
-		{
-			get
-			{
-				return customHeaders;
-			}
-		}
+        public IDictionary<String, String> CustomHeaders
+        {
+            get
+            {
+                return customHeaders;
+            }
+        }
 
 #if !SILVERLIGHT
         public IWebProxy Proxy
@@ -93,162 +93,162 @@
         }
 #endif
 
-		public override bool IsOpen
-		{
-			get
-			{
-				return true;
-			}
-		}
+        public override bool IsOpen
+        {
+            get
+            {
+                return true;
+            }
+        }
 
-		public override void Open()
-		{
-		}
+        public override void Open()
+        {
+        }
 
-		public override void Close()
-		{
-			if (inputStream != null)
-			{
-				inputStream.Close();
-				inputStream = null;
-			}
-			if (outputStream != null)
-			{
-				outputStream.Close();
-				outputStream = null;
-			}
-		}
+        public override void Close()
+        {
+            if (inputStream != null)
+            {
+                inputStream.Close();
+                inputStream = null;
+            }
+            if (outputStream != null)
+            {
+                outputStream.Close();
+                outputStream = null;
+            }
+        }
 
-		public override int Read(byte[] buf, int off, int len)
-		{
-			if (inputStream == null)
-			{
-				throw new TTransportException(TTransportException.ExceptionType.NotOpen, "No request has been sent");
-			}
+        public override int Read(byte[] buf, int off, int len)
+        {
+            if (inputStream == null)
+            {
+                throw new TTransportException(TTransportException.ExceptionType.NotOpen, "No request has been sent");
+            }
 
-			try
-			{
-				int ret = inputStream.Read(buf, off, len);
+            try
+            {
+                int ret = inputStream.Read(buf, off, len);
 
-				if (ret == -1)
-				{
-					throw new TTransportException(TTransportException.ExceptionType.EndOfFile, "No more data available");
-				}
+                if (ret == -1)
+                {
+                    throw new TTransportException(TTransportException.ExceptionType.EndOfFile, "No more data available");
+                }
 
-				return ret;
-			}
-			catch (IOException iox)
-			{ 
-				throw new TTransportException(TTransportException.ExceptionType.Unknown, iox.ToString());
-			}
-		}
+                return ret;
+            }
+            catch (IOException iox)
+            {
+                throw new TTransportException(TTransportException.ExceptionType.Unknown, iox.ToString());
+            }
+        }
 
-		public override void Write(byte[] buf, int off, int len)
-		{
-			outputStream.Write(buf, off, len);
-		}
+        public override void Write(byte[] buf, int off, int len)
+        {
+            outputStream.Write(buf, off, len);
+        }
 
 #if !SILVERLIGHT
-		public override void Flush()
-		{
-			try 
-			{
-				SendRequest();
-			}
-			finally
-			{
-				outputStream = new MemoryStream();
-			}
-		}
+        public override void Flush()
+        {
+            try
+            {
+                SendRequest();
+            }
+            finally
+            {
+                outputStream = new MemoryStream();
+            }
+        }
 
-		private void SendRequest()
-		{
-			try
-			{
-				HttpWebRequest connection = CreateRequest();
+        private void SendRequest()
+        {
+            try
+            {
+                HttpWebRequest connection = CreateRequest();
 
-				byte[] data = outputStream.ToArray();
-				connection.ContentLength = data.Length;
+                byte[] data = outputStream.ToArray();
+                connection.ContentLength = data.Length;
 
-				using (Stream requestStream = connection.GetRequestStream())
-				{
-					requestStream.Write(data, 0, data.Length);
+                using (Stream requestStream = connection.GetRequestStream())
+                {
+                    requestStream.Write(data, 0, data.Length);
 
-					// Resolve HTTP hang that can happens after successive calls by making sure
-					// that we release the response and response stream. To support this, we copy
-					// the response to a memory stream.
-					using (var response = connection.GetResponse())
-					{
-						using (var responseStream = response.GetResponseStream())
-						{
-							// Copy the response to a memory stream so that we can
-							// cleanly close the response and response stream.
-							inputStream = new MemoryStream();
-							byte[] buffer = new byte[8096];
-							int bytesRead;
-							while ((bytesRead = responseStream.Read(buffer, 0, buffer.Length)) > 0)
-							{
-								inputStream.Write (buffer, 0, bytesRead);
-							}
-							inputStream.Seek(0, 0);
-						}
-					}
-				}
-			}
-			catch (IOException iox)
-			{
-				throw new TTransportException(TTransportException.ExceptionType.Unknown, iox.ToString());
-			}
-			catch (WebException wx)
-			{
-				throw new TTransportException(TTransportException.ExceptionType.Unknown, "Couldn't connect to server: " + wx);
-			}
-		}
+                    // Resolve HTTP hang that can happens after successive calls by making sure
+                    // that we release the response and response stream. To support this, we copy
+                    // the response to a memory stream.
+                    using (var response = connection.GetResponse())
+                    {
+                        using (var responseStream = response.GetResponseStream())
+                        {
+                            // Copy the response to a memory stream so that we can
+                            // cleanly close the response and response stream.
+                            inputStream = new MemoryStream();
+                            byte[] buffer = new byte[8096];
+                            int bytesRead;
+                            while ((bytesRead = responseStream.Read(buffer, 0, buffer.Length)) > 0)
+                            {
+                                inputStream.Write (buffer, 0, bytesRead);
+                            }
+                            inputStream.Seek(0, 0);
+                        }
+                    }
+                }
+            }
+            catch (IOException iox)
+            {
+                throw new TTransportException(TTransportException.ExceptionType.Unknown, iox.ToString());
+            }
+            catch (WebException wx)
+            {
+                throw new TTransportException(TTransportException.ExceptionType.Unknown, "Couldn't connect to server: " + wx);
+            }
+        }
 #endif
-		private HttpWebRequest CreateRequest()
-		{
-			HttpWebRequest connection = (HttpWebRequest)WebRequest.Create(uri);
+        private HttpWebRequest CreateRequest()
+        {
+            HttpWebRequest connection = (HttpWebRequest)WebRequest.Create(uri);
 
 
 #if !SILVERLIGHT
-			// Adding certificates through code is not supported with WP7 Silverlight
-			// see "Windows Phone 7 and Certificates_FINAL_121610.pdf"
-		    connection.ClientCertificates.AddRange(certificates);
+            // Adding certificates through code is not supported with WP7 Silverlight
+            // see "Windows Phone 7 and Certificates_FINAL_121610.pdf"
+            connection.ClientCertificates.AddRange(certificates);
 
-			if (connectTimeout > 0)
-			{
-				connection.Timeout = connectTimeout;
-			}
-			if (readTimeout > 0)
-			{
-				connection.ReadWriteTimeout = readTimeout;
-			}
+            if (connectTimeout > 0)
+            {
+                connection.Timeout = connectTimeout;
+            }
+            if (readTimeout > 0)
+            {
+                connection.ReadWriteTimeout = readTimeout;
+            }
 #endif
-			// Make the request
-			connection.ContentType = "application/x-thrift";
-			connection.Accept = "application/x-thrift";
-			connection.UserAgent = "C#/THttpClient";
-			connection.Method = "POST";
+            // Make the request
+            connection.ContentType = "application/x-thrift";
+            connection.Accept = "application/x-thrift";
+            connection.UserAgent = "C#/THttpClient";
+            connection.Method = "POST";
 #if !SILVERLIGHT
-			connection.ProtocolVersion = HttpVersion.Version10;
+            connection.ProtocolVersion = HttpVersion.Version10;
 #endif
 
             //add custom headers here
-			foreach (KeyValuePair<string, string> item in customHeaders)
-			{
+            foreach (KeyValuePair<string, string> item in customHeaders)
+            {
 #if !SILVERLIGHT
-				connection.Headers.Add(item.Key, item.Value);
+                connection.Headers.Add(item.Key, item.Value);
 #else
                 connection.Headers[item.Key] = item.Value;
 #endif
-			}
+            }
 
 #if !SILVERLIGHT
             connection.Proxy = proxy;
 #endif
 
             return connection;
-		}
+        }
 
         public override IAsyncResult BeginFlush(AsyncCallback callback, object state)
         {
@@ -388,12 +388,12 @@
             }
             internal void UpdateStatusToComplete()
             {
-                _isCompleted = true; //1. set _iscompleted to true 
+                _isCompleted = true; //1. set _iscompleted to true
                 lock (_locker)
                 {
                     if (_evt != null)
                     {
-                        _evt.Set(); //2. set the event, when it exists 
+                        _evt.Set(); //2. set the event, when it exists
                     }
                 }
             }
@@ -408,23 +408,23 @@
         }
 
 #region " IDisposable Support "
-		private bool _IsDisposed;
+        private bool _IsDisposed;
 
-		// IDisposable
-		protected override void Dispose(bool disposing)
-		{
-			if (!_IsDisposed)
-			{
-				if (disposing)
-				{
-					if (inputStream != null)
-						inputStream.Dispose();
-					if (outputStream != null)
-						outputStream.Dispose();
-				}
-			}
-			_IsDisposed = true;
-		}
+        // IDisposable
+        protected override void Dispose(bool disposing)
+        {
+            if (!_IsDisposed)
+            {
+                if (disposing)
+                {
+                    if (inputStream != null)
+                        inputStream.Dispose();
+                    if (outputStream != null)
+                        outputStream.Dispose();
+                }
+            }
+            _IsDisposed = true;
+        }
 #endregion
-	}
+    }
 }
diff --git a/lib/csharp/src/Transport/THttpHandler.cs b/lib/csharp/src/Transport/THttpHandler.cs
index 884f1ad..4115ef9 100644
--- a/lib/csharp/src/Transport/THttpHandler.cs
+++ b/lib/csharp/src/Transport/THttpHandler.cs
@@ -1,11 +1,23 @@
-//
-//  THttpHandler.cs
-//
-//  Authors:
-//		Fredrik Hedberg <fhedberg@availo.com>
-//
-//  Distributed under the Apache Public License
-//
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *
+ */
 
 using System;
 using System.Web;
@@ -31,7 +43,7 @@
         {
 
         }
-        
+
         public THttpHandler(TProcessor processor, TProtocolFactory protocolFactory)
             : this(processor, protocolFactory, protocolFactory)
         {
diff --git a/lib/csharp/src/Transport/TMemoryBuffer.cs b/lib/csharp/src/Transport/TMemoryBuffer.cs
index ca31fee..d8ff9dc 100644
--- a/lib/csharp/src/Transport/TMemoryBuffer.cs
+++ b/lib/csharp/src/Transport/TMemoryBuffer.cs
@@ -23,77 +23,77 @@
 using Thrift.Protocol;
 
 namespace Thrift.Transport {
-	public class TMemoryBuffer : TTransport {
+    public class TMemoryBuffer : TTransport {
 
-		private readonly MemoryStream byteStream;
+        private readonly MemoryStream byteStream;
 
-		public TMemoryBuffer() {
-			byteStream = new MemoryStream();
-		}
+        public TMemoryBuffer() {
+            byteStream = new MemoryStream();
+        }
 
-		public TMemoryBuffer(byte[] buf) {
-			byteStream = new MemoryStream(buf);
-		}
+        public TMemoryBuffer(byte[] buf) {
+            byteStream = new MemoryStream(buf);
+        }
 
-		public override void Open() {
-			/** do nothing **/
-		}
+        public override void Open() {
+            /** do nothing **/
+        }
 
-		public override void Close() {
-			/** do nothing **/
-		}
+        public override void Close() {
+            /** do nothing **/
+        }
 
-		public override int Read(byte[] buf, int off, int len) {
-			return byteStream.Read(buf, off, len);
-		}
+        public override int Read(byte[] buf, int off, int len) {
+            return byteStream.Read(buf, off, len);
+        }
 
-		public override void Write(byte[] buf, int off, int len) {
-			byteStream.Write(buf, off, len);
-		}
+        public override void Write(byte[] buf, int off, int len) {
+            byteStream.Write(buf, off, len);
+        }
 
-		public byte[] GetBuffer() {
-			return byteStream.ToArray();
-		}
+        public byte[] GetBuffer() {
+            return byteStream.ToArray();
+        }
 
 
-		public override bool IsOpen {
-			get { return true; }
-		}
+        public override bool IsOpen {
+            get { return true; }
+        }
 
-		public static byte[] Serialize(TAbstractBase s) {
-			var t = new TMemoryBuffer();
-			var p = new TBinaryProtocol(t);
+        public static byte[] Serialize(TAbstractBase s) {
+            var t = new TMemoryBuffer();
+            var p = new TBinaryProtocol(t);
 
-			s.Write(p);
+            s.Write(p);
 
-			return t.GetBuffer();
-		}
+            return t.GetBuffer();
+        }
 
-		public static T DeSerialize<T>(byte[] buf) where T : TAbstractBase {
-			var trans = new TMemoryBuffer(buf);
-			var p = new TBinaryProtocol(trans);
-			if (typeof (TBase).IsAssignableFrom(typeof (T))) {
-				var method = typeof (T).GetMethod("Read", BindingFlags.Instance | BindingFlags.Public);
-				var t = Activator.CreateInstance<T>();
-				method.Invoke(t, new object[] {p});
-				return t;
-			 } else {
-			       var method = typeof (T).GetMethod("Read", BindingFlags.Static | BindingFlags.Public);
-				return (T) method.Invoke(null, new object[] {p});
-			}
-		}
+        public static T DeSerialize<T>(byte[] buf) where T : TAbstractBase {
+            var trans = new TMemoryBuffer(buf);
+            var p = new TBinaryProtocol(trans);
+            if (typeof (TBase).IsAssignableFrom(typeof (T))) {
+                var method = typeof (T).GetMethod("Read", BindingFlags.Instance | BindingFlags.Public);
+                var t = Activator.CreateInstance<T>();
+                method.Invoke(t, new object[] {p});
+                return t;
+             } else {
+                   var method = typeof (T).GetMethod("Read", BindingFlags.Static | BindingFlags.Public);
+                return (T) method.Invoke(null, new object[] {p});
+            }
+        }
 
-		private bool _IsDisposed;
+        private bool _IsDisposed;
 
-		// IDisposable
-		protected override void Dispose(bool disposing) {
-			if (!_IsDisposed) {
-				if (disposing) {
-					if (byteStream != null)
-						byteStream.Dispose();
-				}
-			}
-			_IsDisposed = true;
-		}
-	}
+        // IDisposable
+        protected override void Dispose(bool disposing) {
+            if (!_IsDisposed) {
+                if (disposing) {
+                    if (byteStream != null)
+                        byteStream.Dispose();
+                }
+            }
+            _IsDisposed = true;
+        }
+    }
 }
\ No newline at end of file
diff --git a/lib/csharp/src/Transport/TNamedPipeClientTransport.cs b/lib/csharp/src/Transport/TNamedPipeClientTransport.cs
index 7dafdd6..9faa6e7 100644
--- a/lib/csharp/src/Transport/TNamedPipeClientTransport.cs
+++ b/lib/csharp/src/Transport/TNamedPipeClientTransport.cs
@@ -25,71 +25,71 @@
 
 namespace Thrift.Transport
 {
-	public class TNamedPipeClientTransport : TTransport
-	{
-		private NamedPipeClientStream client;
-		private string ServerName;
-		private string PipeName;
+    public class TNamedPipeClientTransport : TTransport
+    {
+        private NamedPipeClientStream client;
+        private string ServerName;
+        private string PipeName;
 
-		public TNamedPipeClientTransport(string pipe)
-		{
-			ServerName = ".";
-			PipeName = pipe;
-		}
+        public TNamedPipeClientTransport(string pipe)
+        {
+            ServerName = ".";
+            PipeName = pipe;
+        }
 
-		public TNamedPipeClientTransport(string server, string pipe)
-		{
-			ServerName = (server != "") ? server : ".";
-			PipeName = pipe;
-		}
+        public TNamedPipeClientTransport(string server, string pipe)
+        {
+            ServerName = (server != "") ? server : ".";
+            PipeName = pipe;
+        }
 
-		public override bool IsOpen
-		{
-			get { return client != null && client.IsConnected; }
-		}
+        public override bool IsOpen
+        {
+            get { return client != null && client.IsConnected; }
+        }
 
-		public override void Open()
-		{
-			if (IsOpen)
-			{
-				throw new TTransportException(TTransportException.ExceptionType.AlreadyOpen);
-			}
-			client = new NamedPipeClientStream(ServerName, PipeName, PipeDirection.InOut, PipeOptions.None);
-			client.Connect();
-		}
+        public override void Open()
+        {
+            if (IsOpen)
+            {
+                throw new TTransportException(TTransportException.ExceptionType.AlreadyOpen);
+            }
+            client = new NamedPipeClientStream(ServerName, PipeName, PipeDirection.InOut, PipeOptions.None);
+            client.Connect();
+        }
 
-		public override void Close()
-		{
-			if (client != null)
-			{
-				client.Close();
-				client = null;
-			}
-		}
+        public override void Close()
+        {
+            if (client != null)
+            {
+                client.Close();
+                client = null;
+            }
+        }
 
-		public override int Read(byte[] buf, int off, int len)
-		{
-			if (client == null)
-			{
-				throw new TTransportException(TTransportException.ExceptionType.NotOpen);
-			}
+        public override int Read(byte[] buf, int off, int len)
+        {
+            if (client == null)
+            {
+                throw new TTransportException(TTransportException.ExceptionType.NotOpen);
+            }
 
-			return client.Read(buf, off, len);
-		}
+            return client.Read(buf, off, len);
+        }
 
-		public override void Write(byte[] buf, int off, int len)
-		{
-			if (client == null)
-			{
-				throw new TTransportException(TTransportException.ExceptionType.NotOpen);
-			}
+        public override void Write(byte[] buf, int off, int len)
+        {
+            if (client == null)
+            {
+                throw new TTransportException(TTransportException.ExceptionType.NotOpen);
+            }
 
-			client.Write(buf, off, len);
-		}
+            client.Write(buf, off, len);
+        }
 
-		protected override void Dispose(bool disposing)
-		{
-			client.Dispose();
-		}
-	}
+        protected override void Dispose(bool disposing)
+        {
+            client.Dispose();
+        }
+    }
 }
\ No newline at end of file
diff --git a/lib/csharp/src/Transport/TNamedPipeServerTransport.cs b/lib/csharp/src/Transport/TNamedPipeServerTransport.cs
index 815af19..b3f34eb 100644
--- a/lib/csharp/src/Transport/TNamedPipeServerTransport.cs
+++ b/lib/csharp/src/Transport/TNamedPipeServerTransport.cs
@@ -27,110 +27,110 @@
 
 namespace Thrift.Transport
 {
-	public class TNamedPipeServerTransport : TServerTransport
-	{
-		/// <summary>
-		/// This is the address of the Pipe on the localhost.
-		/// </summary>
-		private readonly string pipeAddress;
-		NamedPipeServerStream stream = null;
+    public class TNamedPipeServerTransport : TServerTransport
+    {
+        /// <summary>
+        /// This is the address of the Pipe on the localhost.
+        /// </summary>
+        private readonly string pipeAddress;
+        NamedPipeServerStream stream = null;
 
-		public TNamedPipeServerTransport(string pipeAddress)
-		{
-			this.pipeAddress = pipeAddress;
-		}
+        public TNamedPipeServerTransport(string pipeAddress)
+        {
+            this.pipeAddress = pipeAddress;
+        }
 
-		public override void Listen()
-		{
-			// nothing to do here
-		}
+        public override void Listen()
+        {
+            // nothing to do here
+        }
 
-		public override void Close()
-		{
-			if (stream != null)
-			{
-				try
-				{
-					stream.Close();
-					stream.Dispose();
-				}
-				finally
-				{
-					stream = null;
-				}
-			}
-		}
+        public override void Close()
+        {
+            if (stream != null)
+            {
+                try
+                {
+                    stream.Close();
+                    stream.Dispose();
+                }
+                finally
+                {
+                    stream = null;
+                }
+            }
+        }
 
-		private void EnsurePipeInstance()
-		{
-			if( stream == null)
-				stream = new NamedPipeServerStream(
-					pipeAddress, PipeDirection.InOut, 254,
-					PipeTransmissionMode.Byte,
-					PipeOptions.None, 4096, 4096 /*TODO: security*/);
-		}
+        private void EnsurePipeInstance()
+        {
+            if( stream == null)
+                stream = new NamedPipeServerStream(
+                    pipeAddress, PipeDirection.InOut, 254,
+                    PipeTransmissionMode.Byte,
+                    PipeOptions.None, 4096, 4096 /*TODO: security*/);
+        }
 
-		protected override TTransport AcceptImpl()
-		{
-			try
-			{
-				EnsurePipeInstance();
-				stream.WaitForConnection();
-				var trans = new ServerTransport(stream);
-				stream = null;  // pass ownership to ServerTransport
-				return trans;
-			}
-			catch (Exception e)
-			{
-				Close();
-				throw new TTransportException(TTransportException.ExceptionType.NotOpen, e.Message);
-			}
-		}
+        protected override TTransport AcceptImpl()
+        {
+            try
+            {
+                EnsurePipeInstance();
+                stream.WaitForConnection();
+                var trans = new ServerTransport(stream);
+                stream = null;  // pass ownership to ServerTransport
+                return trans;
+            }
+            catch (Exception e)
+            {
+                Close();
+                throw new TTransportException(TTransportException.ExceptionType.NotOpen, e.Message);
+            }
+        }
 
-		private class ServerTransport : TTransport
-		{
-			private NamedPipeServerStream server;
-			public ServerTransport(NamedPipeServerStream server)
-			{
-				this.server = server;
-			}
+        private class ServerTransport : TTransport
+        {
+            private NamedPipeServerStream server;
+            public ServerTransport(NamedPipeServerStream server)
+            {
+                this.server = server;
+            }
 
-			public override bool IsOpen
-			{
-				get { return server != null && server.IsConnected; }
-			}
+            public override bool IsOpen
+            {
+                get { return server != null && server.IsConnected; }
+            }
 
-			public override void Open()
-			{
-			}
+            public override void Open()
+            {
+            }
 
-			public override void Close()
-			{
-				if (server != null) server.Close();
-			}
+            public override void Close()
+            {
+                if (server != null) server.Close();
+            }
 
-			public override int Read(byte[] buf, int off, int len)
-			{
-				if (server == null)
-				{
-					throw new TTransportException(TTransportException.ExceptionType.NotOpen);
-				}
-				return server.Read(buf, off, len);
-			}
+            public override int Read(byte[] buf, int off, int len)
+            {
+                if (server == null)
+                {
+                    throw new TTransportException(TTransportException.ExceptionType.NotOpen);
+                }
+                return server.Read(buf, off, len);
+            }
 
-			public override void Write(byte[] buf, int off, int len)
-			{
-				if (server == null)
-				{
-					throw new TTransportException(TTransportException.ExceptionType.NotOpen);
-				}
-				server.Write(buf, off, len);
-			}
+            public override void Write(byte[] buf, int off, int len)
+            {
+                if (server == null)
+                {
+                    throw new TTransportException(TTransportException.ExceptionType.NotOpen);
+                }
+                server.Write(buf, off, len);
+            }
 
-			protected override void Dispose(bool disposing)
-			{
-				server.Dispose();
-			}
-		}
-	}
+            protected override void Dispose(bool disposing)
+            {
+                server.Dispose();
+            }
+        }
+    }
 }
\ No newline at end of file
diff --git a/lib/csharp/src/Transport/TServerSocket.cs b/lib/csharp/src/Transport/TServerSocket.cs
index eefa4f9..82a367c 100644
--- a/lib/csharp/src/Transport/TServerSocket.cs
+++ b/lib/csharp/src/Transport/TServerSocket.cs
@@ -27,94 +27,94 @@
 
 namespace Thrift.Transport
 {
-	public class TServerSocket : TServerTransport
-	{
-		/**
-		* Underlying server with socket
-		*/
-		private TcpListener server = null;
+    public class TServerSocket : TServerTransport
+    {
+        /**
+        * Underlying server with socket
+        */
+        private TcpListener server = null;
 
-		/**
-		 * Port to listen on
-		 */
-		private int port = 0;
+        /**
+         * Port to listen on
+         */
+        private int port = 0;
 
-		/**
-		 * Timeout for client sockets from accept
-		 */
-		private int clientTimeout = 0;
+        /**
+         * Timeout for client sockets from accept
+         */
+        private int clientTimeout = 0;
 
-		/**
-		 * Whether or not to wrap new TSocket connections in buffers
-		 */
-		private bool useBufferedSockets = false;
+        /**
+         * Whether or not to wrap new TSocket connections in buffers
+         */
+        private bool useBufferedSockets = false;
 
-		/**
-		 * Creates a server socket from underlying socket object
-		 */
-		public TServerSocket(TcpListener listener)
-			:this(listener, 0)
-		{
-		}
+        /**
+         * Creates a server socket from underlying socket object
+         */
+        public TServerSocket(TcpListener listener)
+            :this(listener, 0)
+        {
+        }
 
-		/**
-		 * Creates a server socket from underlying socket object
-		 */
-		public TServerSocket(TcpListener listener, int clientTimeout)
-		{
-			this.server = listener;
-			this.clientTimeout = clientTimeout;
-		}
+        /**
+         * Creates a server socket from underlying socket object
+         */
+        public TServerSocket(TcpListener listener, int clientTimeout)
+        {
+            this.server = listener;
+            this.clientTimeout = clientTimeout;
+        }
 
-		/**
-		 * Creates just a port listening server socket
-		 */
-		public TServerSocket(int port)
-			: this(port, 0)
-		{
-		}
+        /**
+         * Creates just a port listening server socket
+         */
+        public TServerSocket(int port)
+            : this(port, 0)
+        {
+        }
 
-		/**
-		 * Creates just a port listening server socket
-		 */
-		public TServerSocket(int port, int clientTimeout)
-			:this(port, clientTimeout, false)
-		{
-		}
+        /**
+         * Creates just a port listening server socket
+         */
+        public TServerSocket(int port, int clientTimeout)
+            :this(port, clientTimeout, false)
+        {
+        }
 
-		public TServerSocket(int port, int clientTimeout, bool useBufferedSockets)
-		{
-			this.port = port;
-			this.clientTimeout = clientTimeout;
-			this.useBufferedSockets = useBufferedSockets;
-			try
-			{
-				// Make server socket
-				server = new TcpListener(System.Net.IPAddress.Any, this.port);
-				server.Server.NoDelay = true;
-			}
-			catch (Exception)
-			{
-				server = null;
-				throw new TTransportException("Could not create ServerSocket on port " + port + ".");
-			}
-		}
+        public TServerSocket(int port, int clientTimeout, bool useBufferedSockets)
+        {
+            this.port = port;
+            this.clientTimeout = clientTimeout;
+            this.useBufferedSockets = useBufferedSockets;
+            try
+            {
+                // Make server socket
+                server = new TcpListener(System.Net.IPAddress.Any, this.port);
+                server.Server.NoDelay = true;
+            }
+            catch (Exception)
+            {
+                server = null;
+                throw new TTransportException("Could not create ServerSocket on port " + port + ".");
+            }
+        }
 
-		public override void Listen()
-		{
-			// Make sure not to block on accept
-			if (server != null)
-			{
-				try
-				{
-					server.Start();
-				}
-				catch (SocketException sx)
-				{
-					throw new TTransportException("Could not accept on listening socket: " + sx.Message);
-				}
-			}
-		}
+        public override void Listen()
+        {
+            // Make sure not to block on accept
+            if (server != null)
+            {
+                try
+                {
+                    server.Start();
+                }
+                catch (SocketException sx)
+                {
+                    throw new TTransportException("Could not accept on listening socket: " + sx.Message);
+                }
+            }
+        }
 
         protected override TTransport AcceptImpl()
         {
@@ -142,7 +142,7 @@
                 }
                 catch (System.Exception)
                 {
-                    // If a TSocket was successfully created, then let 
+                    // If a TSocket was successfully created, then let
                     // it do proper cleanup of the TcpClient object.
                     if (result2 != null)
                         result2.Dispose();
@@ -158,19 +158,19 @@
         }
 
         public override void Close()
-		{
-			if (server != null)
-			{
-				try
-				{
-					server.Stop();
-				}
-				catch (Exception ex)
-				{
-					throw new TTransportException("WARNING: Could not close server socket: " + ex);
-				}
-				server = null;
-			}
-		}
-	}
+        {
+            if (server != null)
+            {
+                try
+                {
+                    server.Stop();
+                }
+                catch (Exception ex)
+                {
+                    throw new TTransportException("WARNING: Could not close server socket: " + ex);
+                }
+                server = null;
+            }
+        }
+    }
 }
diff --git a/lib/csharp/src/Transport/TServerTransport.cs b/lib/csharp/src/Transport/TServerTransport.cs
index c99d07f..05d7d0f 100644
--- a/lib/csharp/src/Transport/TServerTransport.cs
+++ b/lib/csharp/src/Transport/TServerTransport.cs
@@ -25,19 +25,19 @@
 
 namespace Thrift.Transport
 {
-	public abstract class TServerTransport
-	{
-		public abstract void Listen();
-		public abstract void Close();
-		protected abstract TTransport AcceptImpl();
+    public abstract class TServerTransport
+    {
+        public abstract void Listen();
+        public abstract void Close();
+        protected abstract TTransport AcceptImpl();
 
-		public TTransport Accept()
-		{
-			TTransport transport = AcceptImpl();
-			if (transport == null) {
-			  throw new TTransportException("accept() may not return NULL");
-			}
-			return transport;
-		 }
-	}
+        public TTransport Accept()
+        {
+            TTransport transport = AcceptImpl();
+            if (transport == null) {
+              throw new TTransportException("accept() may not return NULL");
+            }
+            return transport;
+         }
+    }
 }
diff --git a/lib/csharp/src/Transport/TSocket.cs b/lib/csharp/src/Transport/TSocket.cs
index 35fbe97..cf1a440 100644
--- a/lib/csharp/src/Transport/TSocket.cs
+++ b/lib/csharp/src/Transport/TSocket.cs
@@ -26,118 +26,118 @@
 
 namespace Thrift.Transport
 {
-	public class TSocket : TStreamTransport
-	{
-		private TcpClient client = null;
-		private string host = null;
-		private int port = 0;
-		private int timeout = 0;
+    public class TSocket : TStreamTransport
+    {
+        private TcpClient client = null;
+        private string host = null;
+        private int port = 0;
+        private int timeout = 0;
 
-		public TSocket(TcpClient client)
-		{
-			this.client = client;
+        public TSocket(TcpClient client)
+        {
+            this.client = client;
 
-			if (IsOpen)
-			{
-				inputStream = client.GetStream();
-				outputStream = client.GetStream();
-			}
-		}
+            if (IsOpen)
+            {
+                inputStream = client.GetStream();
+                outputStream = client.GetStream();
+            }
+        }
 
-		public TSocket(string host, int port) 
-		    : this(host, port, 0)
-		{
-		}
+        public TSocket(string host, int port)
+            : this(host, port, 0)
+        {
+        }
 
-		public TSocket(string host, int port, int timeout)
-		{
-			this.host = host;
-			this.port = port;
-			this.timeout = timeout;
+        public TSocket(string host, int port, int timeout)
+        {
+            this.host = host;
+            this.port = port;
+            this.timeout = timeout;
 
-			InitSocket();
-		}
+            InitSocket();
+        }
 
-		private void InitSocket()
-		{
-			client = new TcpClient();
-			client.ReceiveTimeout = client.SendTimeout = timeout;
-			client.Client.NoDelay = true;
-		}
+        private void InitSocket()
+        {
+            client = new TcpClient();
+            client.ReceiveTimeout = client.SendTimeout = timeout;
+            client.Client.NoDelay = true;
+        }
 
-		public int Timeout
-		{
-			set
-			{
-				client.ReceiveTimeout = client.SendTimeout = timeout = value;
-			}
-		}
+        public int Timeout
+        {
+            set
+            {
+                client.ReceiveTimeout = client.SendTimeout = timeout = value;
+            }
+        }
 
-		public TcpClient TcpClient
-		{
-			get
-			{
-				return client;
-			}
-		}
+        public TcpClient TcpClient
+        {
+            get
+            {
+                return client;
+            }
+        }
 
-		public string Host
-		{
-			get
-			{
-				return host;
-			}
-		}
+        public string Host
+        {
+            get
+            {
+                return host;
+            }
+        }
 
-		public int Port
-		{
-			get
-			{
-				return port;
-			}
-		}
+        public int Port
+        {
+            get
+            {
+                return port;
+            }
+        }
 
-		public override bool IsOpen
-		{
-			get
-			{
-				if (client == null)
-				{
-					return false;
-				}
+        public override bool IsOpen
+        {
+            get
+            {
+                if (client == null)
+                {
+                    return false;
+                }
 
-				return client.Connected;
-			}
-		}
+                return client.Connected;
+            }
+        }
 
-		public override void Open()
-		{
-			if (IsOpen)
-			{
-				throw new TTransportException(TTransportException.ExceptionType.AlreadyOpen, "Socket already connected");
-			}
+        public override void Open()
+        {
+            if (IsOpen)
+            {
+                throw new TTransportException(TTransportException.ExceptionType.AlreadyOpen, "Socket already connected");
+            }
 
-			if (String.IsNullOrEmpty(host))
-			{
-				throw new TTransportException(TTransportException.ExceptionType.NotOpen, "Cannot open null host");
-			}
+            if (String.IsNullOrEmpty(host))
+            {
+                throw new TTransportException(TTransportException.ExceptionType.NotOpen, "Cannot open null host");
+            }
 
-			if (port <= 0)
-			{
-				throw new TTransportException(TTransportException.ExceptionType.NotOpen, "Cannot open without port");
-			}
+            if (port <= 0)
+            {
+                throw new TTransportException(TTransportException.ExceptionType.NotOpen, "Cannot open without port");
+            }
 
-			if (client == null)
-			{
-				InitSocket();
-			}
+            if (client == null)
+            {
+                InitSocket();
+            }
 
-			if( timeout == 0)			// no timeout -> infinite
-			{
-				client.Connect(host, port);
-			}
-			else                        // we have a timeout -> use it
-			{
+            if( timeout == 0)            // no timeout -> infinite
+            {
+                client.Connect(host, port);
+            }
+            else                        // we have a timeout -> use it
+            {
                 ConnectHelper hlp = new ConnectHelper(client);
                 IAsyncResult asyncres = client.BeginConnect(host, port, new AsyncCallback(ConnectCallback), hlp);
                 bool bConnected = asyncres.AsyncWaitHandle.WaitOne(timeout) && client.Connected;
@@ -158,11 +158,11 @@
                     }
                     throw new TTransportException(TTransportException.ExceptionType.TimedOut, "Connect timed out");
                 }
-			}
+            }
 
-			inputStream = client.GetStream();
-			outputStream = client.GetStream();
-		}
+            inputStream = client.GetStream();
+            outputStream = client.GetStream();
+        }
 
 
         static void ConnectCallback(IAsyncResult asyncres)
@@ -171,7 +171,7 @@
             lock (hlp.Mutex)
             {
                 hlp.CallbackDone = true;
-                    
+
                 try
                 {
                     if( hlp.Client.Client != null)
@@ -182,16 +182,16 @@
                     // catch that away
                 }
 
-                if (hlp.DoCleanup) 
+                if (hlp.DoCleanup)
                 {
-                	try {
-                    	asyncres.AsyncWaitHandle.Close();
-                	} catch (Exception) {}
-                	
-                	try {
-                    	if (hlp.Client is IDisposable)
-	                        ((IDisposable)hlp.Client).Dispose();
-                	} catch (Exception) {}
+                    try {
+                        asyncres.AsyncWaitHandle.Close();
+                    } catch (Exception) {}
+
+                    try {
+                        if (hlp.Client is IDisposable)
+                            ((IDisposable)hlp.Client).Dispose();
+                    } catch (Exception) {}
                     hlp.Client = null;
                 }
             }
@@ -209,15 +209,15 @@
             }
         }
 
-		public override void Close()
-		{
-			base.Close();
-			if (client != null)
-			{
-				client.Close();
-				client = null;
-			}
-		}
+        public override void Close()
+        {
+            base.Close();
+            if (client != null)
+            {
+                client.Close();
+                client = null;
+            }
+        }
 
     #region " IDisposable Support "
     private bool _IsDisposed;
diff --git a/lib/csharp/src/Transport/TStreamTransport.cs b/lib/csharp/src/Transport/TStreamTransport.cs
index eb1d2cc..468743c 100644
--- a/lib/csharp/src/Transport/TStreamTransport.cs
+++ b/lib/csharp/src/Transport/TStreamTransport.cs
@@ -26,83 +26,83 @@
 
 namespace Thrift.Transport
 {
-	public class TStreamTransport : TTransport
-	{
-		protected Stream inputStream;
-		protected Stream outputStream;
+    public class TStreamTransport : TTransport
+    {
+        protected Stream inputStream;
+        protected Stream outputStream;
 
-		protected TStreamTransport()
-		{
-		}
+        protected TStreamTransport()
+        {
+        }
 
-		public TStreamTransport(Stream inputStream, Stream outputStream)
-		{
-			this.inputStream = inputStream;
-			this.outputStream = outputStream;
-		}
+        public TStreamTransport(Stream inputStream, Stream outputStream)
+        {
+            this.inputStream = inputStream;
+            this.outputStream = outputStream;
+        }
 
-		public Stream OutputStream
-		{
-			get { return outputStream; }
-		}
+        public Stream OutputStream
+        {
+            get { return outputStream; }
+        }
 
-		public Stream InputStream
-		{
-			get { return inputStream; }
-		}
+        public Stream InputStream
+        {
+            get { return inputStream; }
+        }
 
-		public override bool IsOpen
-		{
-			get { return true; }
-		}
+        public override bool IsOpen
+        {
+            get { return true; }
+        }
 
-		public override void Open()
-		{
-		}
+        public override void Open()
+        {
+        }
 
-		public override void Close()
-		{
-			if (inputStream != null)
-			{
-				inputStream.Close();
-				inputStream = null;
-			}
-			if (outputStream != null)
-			{
-				outputStream.Close();
-				outputStream = null;
-			}
-		}
+        public override void Close()
+        {
+            if (inputStream != null)
+            {
+                inputStream.Close();
+                inputStream = null;
+            }
+            if (outputStream != null)
+            {
+                outputStream.Close();
+                outputStream = null;
+            }
+        }
 
-		public override int Read(byte[] buf, int off, int len)
-		{
-			if (inputStream == null)
-			{
-				throw new TTransportException(TTransportException.ExceptionType.NotOpen, "Cannot read from null inputstream");
-			}
+        public override int Read(byte[] buf, int off, int len)
+        {
+            if (inputStream == null)
+            {
+                throw new TTransportException(TTransportException.ExceptionType.NotOpen, "Cannot read from null inputstream");
+            }
 
-			return inputStream.Read(buf, off, len);
-		}
+            return inputStream.Read(buf, off, len);
+        }
 
-		public override void Write(byte[] buf, int off, int len)
-		{
-			if (outputStream == null)
-			{
-				throw new TTransportException(TTransportException.ExceptionType.NotOpen, "Cannot write to null outputstream");
-			}
+        public override void Write(byte[] buf, int off, int len)
+        {
+            if (outputStream == null)
+            {
+                throw new TTransportException(TTransportException.ExceptionType.NotOpen, "Cannot write to null outputstream");
+            }
 
-			outputStream.Write(buf, off, len);
-		}
+            outputStream.Write(buf, off, len);
+        }
 
-		public override void Flush()
-		{
-			if (outputStream == null)
-			{
-				throw new TTransportException(TTransportException.ExceptionType.NotOpen, "Cannot flush null outputstream");
-			}
+        public override void Flush()
+        {
+            if (outputStream == null)
+            {
+                throw new TTransportException(TTransportException.ExceptionType.NotOpen, "Cannot flush null outputstream");
+            }
 
-			outputStream.Flush();
-		}
+            outputStream.Flush();
+        }
 
 
     #region " IDisposable Support "
diff --git a/lib/csharp/src/Transport/TTLSServerSocket.cs b/lib/csharp/src/Transport/TTLSServerSocket.cs
index 948b1d7..9753d47 100644
--- a/lib/csharp/src/Transport/TTLSServerSocket.cs
+++ b/lib/csharp/src/Transport/TTLSServerSocket.cs
@@ -23,164 +23,164 @@
 
 namespace Thrift.Transport
 {
-	/// <summary>
-	/// SSL Server Socket Wrapper Class
-	/// </summary>
-	public class TTLSServerSocket : TServerTransport
-	{
-		/// <summary>
-		/// Underlying tcp server
-		/// </summary>
-		private TcpListener server = null;
+    /// <summary>
+    /// SSL Server Socket Wrapper Class
+    /// </summary>
+    public class TTLSServerSocket : TServerTransport
+    {
+        /// <summary>
+        /// Underlying tcp server
+        /// </summary>
+        private TcpListener server = null;
 
-		/// <summary>
-		/// The port where the socket listen
-		/// </summary>
-		private int port = 0;
+        /// <summary>
+        /// The port where the socket listen
+        /// </summary>
+        private int port = 0;
 
-		/// <summary>
-		/// Timeout for the created server socket
-		/// </summary>
-		private int clientTimeout = 0;
+        /// <summary>
+        /// Timeout for the created server socket
+        /// </summary>
+        private int clientTimeout = 0;
 
-		/// <summary>
-		/// Whether or not to wrap new TSocket connections in buffers
-		/// </summary>
-		private bool useBufferedSockets = false;
+        /// <summary>
+        /// Whether or not to wrap new TSocket connections in buffers
+        /// </summary>
+        private bool useBufferedSockets = false;
 
-		/// <summary>
-		/// The servercertificate with the private- and public-key
-		/// </summary>
-		private X509Certificate serverCertificate;
+        /// <summary>
+        /// The servercertificate with the private- and public-key
+        /// </summary>
+        private X509Certificate serverCertificate;
 
 
-		/// <summary>
-		/// Initializes a new instance of the <see cref="TTLSServerSocket" /> class.
-		/// </summary>
-		/// <param name="port">The port where the server runs.</param>
-		/// <param name="certificate">The certificate object.</param>
-		public TTLSServerSocket(int port, X509Certificate2 certificate)
-			: this(port,  0, certificate)
-		{
-		}
+        /// <summary>
+        /// Initializes a new instance of the <see cref="TTLSServerSocket" /> class.
+        /// </summary>
+        /// <param name="port">The port where the server runs.</param>
+        /// <param name="certificate">The certificate object.</param>
+        public TTLSServerSocket(int port, X509Certificate2 certificate)
+            : this(port,  0, certificate)
+        {
+        }
 
-		/// <summary>
-		/// Initializes a new instance of the <see cref="TTLSServerSocket" /> class.
-		/// </summary>
-		/// <param name="port">The port where the server runs.</param>
-		/// <param name="clientTimeout">Send/receive timeout.</param>
-		/// <param name="certificate">The certificate object.</param>
-		public TTLSServerSocket(int port, int clientTimeout, X509Certificate2 certificate)
-			: this(port, clientTimeout, false, certificate)
-		{
-		}
+        /// <summary>
+        /// Initializes a new instance of the <see cref="TTLSServerSocket" /> class.
+        /// </summary>
+        /// <param name="port">The port where the server runs.</param>
+        /// <param name="clientTimeout">Send/receive timeout.</param>
+        /// <param name="certificate">The certificate object.</param>
+        public TTLSServerSocket(int port, int clientTimeout, X509Certificate2 certificate)
+            : this(port, clientTimeout, false, certificate)
+        {
+        }
 
-		/// <summary>
-		/// Initializes a new instance of the <see cref="TTLSServerSocket" /> class.
-		/// </summary>
-		/// <param name="port">The port where the server runs.</param>
-		/// <param name="clientTimeout">Send/receive timeout.</param>
-		/// <param name="useBufferedSockets">If set to <c>true</c> [use buffered sockets].</param>
-		/// <param name="certificate">The certificate object.</param>
-		public TTLSServerSocket(int port, int clientTimeout, bool useBufferedSockets, X509Certificate2 certificate)
-		{
-			if (!certificate.HasPrivateKey)
-			{
-				throw new TTransportException(TTransportException.ExceptionType.Unknown, "Your server-certificate needs to have a private key");
-			}
+        /// <summary>
+        /// Initializes a new instance of the <see cref="TTLSServerSocket" /> class.
+        /// </summary>
+        /// <param name="port">The port where the server runs.</param>
+        /// <param name="clientTimeout">Send/receive timeout.</param>
+        /// <param name="useBufferedSockets">If set to <c>true</c> [use buffered sockets].</param>
+        /// <param name="certificate">The certificate object.</param>
+        public TTLSServerSocket(int port, int clientTimeout, bool useBufferedSockets, X509Certificate2 certificate)
+        {
+            if (!certificate.HasPrivateKey)
+            {
+                throw new TTransportException(TTransportException.ExceptionType.Unknown, "Your server-certificate needs to have a private key");
+            }
 
-			this.port = port;
-			this.serverCertificate = certificate;
-			this.useBufferedSockets = useBufferedSockets;
-			try
-			{
-				// Create server socket
-				server = new TcpListener(System.Net.IPAddress.Any, this.port);
-				server.Server.NoDelay = true;
-			}
-			catch (Exception)
-			{
-				server = null;
-				throw new TTransportException("Could not create ServerSocket on port " + port + ".");
-			}
-		}
+            this.port = port;
+            this.serverCertificate = certificate;
+            this.useBufferedSockets = useBufferedSockets;
+            try
+            {
+                // Create server socket
+                server = new TcpListener(System.Net.IPAddress.Any, this.port);
+                server.Server.NoDelay = true;
+            }
+            catch (Exception)
+            {
+                server = null;
+                throw new TTransportException("Could not create ServerSocket on port " + port + ".");
+            }
+        }
 
-		/// <summary>
-		/// Starts the server.
-		/// </summary>
-		public override void Listen()
-		{
-			// Make sure accept is not blocking
-			if (this.server != null)
-			{
-				try
-				{
-					this.server.Start();
-				}
-				catch (SocketException sx)
-				{
-					throw new TTransportException("Could not accept on listening socket: " + sx.Message);
-				}
-			}
-		}
+        /// <summary>
+        /// Starts the server.
+        /// </summary>
+        public override void Listen()
+        {
+            // Make sure accept is not blocking
+            if (this.server != null)
+            {
+                try
+                {
+                    this.server.Start();
+                }
+                catch (SocketException sx)
+                {
+                    throw new TTransportException("Could not accept on listening socket: " + sx.Message);
+                }
+            }
+        }
 
-		/// <summary>
-		/// Callback for Accept Implementation
-		/// </summary>
-		/// <returns>
-		/// TTransport-object.
-		/// </returns>
-		protected override TTransport AcceptImpl()
-		{
-			if (this.server == null)
-			{
-				throw new TTransportException(TTransportException.ExceptionType.NotOpen, "No underlying server socket.");
-			}
+        /// <summary>
+        /// Callback for Accept Implementation
+        /// </summary>
+        /// <returns>
+        /// TTransport-object.
+        /// </returns>
+        protected override TTransport AcceptImpl()
+        {
+            if (this.server == null)
+            {
+                throw new TTransportException(TTransportException.ExceptionType.NotOpen, "No underlying server socket.");
+            }
 
-			try
-			{
-				TcpClient client = this.server.AcceptTcpClient();
-				client.SendTimeout = client.ReceiveTimeout = this.clientTimeout;
+            try
+            {
+                TcpClient client = this.server.AcceptTcpClient();
+                client.SendTimeout = client.ReceiveTimeout = this.clientTimeout;
 
-				//wrap the client in an SSL Socket passing in the SSL cert
-				TTLSSocket socket = new TTLSSocket(client, this.serverCertificate, true);
+                //wrap the client in an SSL Socket passing in the SSL cert
+                TTLSSocket socket = new TTLSSocket(client, this.serverCertificate, true);
 
-				socket.setupTLS();
+                socket.setupTLS();
 
-				if (useBufferedSockets)
-				{
-					TBufferedTransport trans = new TBufferedTransport(socket);
-					return trans;
-				}
-				else
-				{
-					return socket;
-				}
-				
-			}
-			catch (Exception ex)
-			{
-				throw new TTransportException(ex.ToString());
-			}
-		}
+                if (useBufferedSockets)
+                {
+                    TBufferedTransport trans = new TBufferedTransport(socket);
+                    return trans;
+                }
+                else
+                {
+                    return socket;
+                }
 
-		/// <summary>
-		/// Stops the Server
-		/// </summary>
-		public override void Close()
-		{
-			if (this.server != null)
-			{
-				try
-				{
-					this.server.Stop();
-				}
-				catch (Exception ex)  
-				{
-					throw new TTransportException("WARNING: Could not close server socket: " + ex);
-				}
-				this.server = null;
-			}
-		}
-	}
+            }
+            catch (Exception ex)
+            {
+                throw new TTransportException(ex.ToString());
+            }
+        }
+
+        /// <summary>
+        /// Stops the Server
+        /// </summary>
+        public override void Close()
+        {
+            if (this.server != null)
+            {
+                try
+                {
+                    this.server.Stop();
+                }
+                catch (Exception ex)
+                {
+                    throw new TTransportException("WARNING: Could not close server socket: " + ex);
+                }
+                this.server = null;
+            }
+        }
+    }
 }
diff --git a/lib/csharp/src/Transport/TTLSSocket.cs b/lib/csharp/src/Transport/TTLSSocket.cs
index b87576d..9e1f9f2 100644
--- a/lib/csharp/src/Transport/TTLSSocket.cs
+++ b/lib/csharp/src/Transport/TTLSSocket.cs
@@ -25,276 +25,276 @@
 
 namespace Thrift.Transport
 {
-	/// <summary>
-	/// SSL Socket Wrapper class
-	/// </summary>
-	public class TTLSSocket : TStreamTransport
-	{
-		/// <summary>
-		/// Internal TCP Client
-		/// </summary>
-		private TcpClient client = null;
+    /// <summary>
+    /// SSL Socket Wrapper class
+    /// </summary>
+    public class TTLSSocket : TStreamTransport
+    {
+        /// <summary>
+        /// Internal TCP Client
+        /// </summary>
+        private TcpClient client = null;
 
-		/// <summary>
-		/// The host
-		/// </summary>
-		private string host = null;
+        /// <summary>
+        /// The host
+        /// </summary>
+        private string host = null;
 
-		/// <summary>
-		/// The port
-		/// </summary>
-		private int port = 0;
+        /// <summary>
+        /// The port
+        /// </summary>
+        private int port = 0;
 
-		/// <summary>
-		/// The timeout for the connection
-		/// </summary>
-		private int timeout = 0;
+        /// <summary>
+        /// The timeout for the connection
+        /// </summary>
+        private int timeout = 0;
 
-		/// <summary>
-		/// Internal SSL Stream for IO
-		/// </summary>
-		private SslStream secureStream = null;
+        /// <summary>
+        /// Internal SSL Stream for IO
+        /// </summary>
+        private SslStream secureStream = null;
 
-		/// <summary>
-		/// Defines wheter or not this socket is a server socket<br/>
-		/// This is used for the TLS-authentication
-		/// </summary>
-		private bool isServer = false;
+        /// <summary>
+        /// Defines wheter or not this socket is a server socket<br/>
+        /// This is used for the TLS-authentication
+        /// </summary>
+        private bool isServer = false;
 
-		/// <summary>
-		/// The certificate
-		/// </summary>
-		private X509Certificate certificate = null;
+        /// <summary>
+        /// The certificate
+        /// </summary>
+        private X509Certificate certificate = null;
 
-		/// <summary>
-		/// User defined certificate validator.
-		/// </summary>
-		private RemoteCertificateValidationCallback certValidator = null;
+        /// <summary>
+        /// User defined certificate validator.
+        /// </summary>
+        private RemoteCertificateValidationCallback certValidator = null;
 
-		/// <summary>
-		/// Initializes a new instance of the <see cref="TTLSSocket"/> class.
-		/// </summary>
-		/// <param name="client">An already created TCP-client</param>
-		/// <param name="certificate">The certificate.</param>
-		/// <param name="isServer">if set to <c>true</c> [is server].</param>
-		public TTLSSocket(TcpClient client, X509Certificate certificate, bool isServer = false)
-		{
-			this.client = client;
-			this.certificate = certificate;
-			this.isServer = isServer;
+        /// <summary>
+        /// Initializes a new instance of the <see cref="TTLSSocket"/> class.
+        /// </summary>
+        /// <param name="client">An already created TCP-client</param>
+        /// <param name="certificate">The certificate.</param>
+        /// <param name="isServer">if set to <c>true</c> [is server].</param>
+        public TTLSSocket(TcpClient client, X509Certificate certificate, bool isServer = false)
+        {
+            this.client = client;
+            this.certificate = certificate;
+            this.isServer = isServer;
 
-			if (IsOpen)
-			{
-				base.inputStream = client.GetStream();
-				base.outputStream = client.GetStream();
-			}
-		}
+            if (IsOpen)
+            {
+                base.inputStream = client.GetStream();
+                base.outputStream = client.GetStream();
+            }
+        }
 
-		/// <summary>
-		/// Initializes a new instance of the <see cref="TTLSSocket"/> class.
-		/// </summary>
-		/// <param name="host">The host, where the socket should connect to.</param>
-		/// <param name="port">The port.</param>
-		/// <param name="certificatePath">The certificate path.</param>
-		/// <param name="certValidator">User defined cert validator.</param>
-		public TTLSSocket(string host, int port, string certificatePath, RemoteCertificateValidationCallback certValidator = null)
-			: this(host, port, 0, X509Certificate.CreateFromCertFile(certificatePath), certValidator)
-		{
-		}
+        /// <summary>
+        /// Initializes a new instance of the <see cref="TTLSSocket"/> class.
+        /// </summary>
+        /// <param name="host">The host, where the socket should connect to.</param>
+        /// <param name="port">The port.</param>
+        /// <param name="certificatePath">The certificate path.</param>
+        /// <param name="certValidator">User defined cert validator.</param>
+        public TTLSSocket(string host, int port, string certificatePath, RemoteCertificateValidationCallback certValidator = null)
+            : this(host, port, 0, X509Certificate.CreateFromCertFile(certificatePath), certValidator)
+        {
+        }
 
-		/// <summary>
-		/// Initializes a new instance of the <see cref="TTLSSocket"/> class.
-		/// </summary>
-		/// <param name="host">The host, where the socket should connect to.</param>
-		/// <param name="port">The port.</param>
-		/// <param name="certificate">The certificate.</param>
-		/// <param name="certValidator">User defined cert validator.</param>
-		public TTLSSocket(string host, int port, X509Certificate certificate, RemoteCertificateValidationCallback certValidator = null)
-			: this(host, port, 0, certificate, certValidator)
-		{
-		}
+        /// <summary>
+        /// Initializes a new instance of the <see cref="TTLSSocket"/> class.
+        /// </summary>
+        /// <param name="host">The host, where the socket should connect to.</param>
+        /// <param name="port">The port.</param>
+        /// <param name="certificate">The certificate.</param>
+        /// <param name="certValidator">User defined cert validator.</param>
+        public TTLSSocket(string host, int port, X509Certificate certificate, RemoteCertificateValidationCallback certValidator = null)
+            : this(host, port, 0, certificate, certValidator)
+        {
+        }
 
-		/// <summary>
-		/// Initializes a new instance of the <see cref="TTLSSocket"/> class.
-		/// </summary>
-		/// <param name="host">The host, where the socket should connect to.</param>
-		/// <param name="port">The port.</param>
-		/// <param name="timeout">The timeout.</param>
-		/// <param name="certificate">The certificate.</param>
-		/// <param name="certValidator">User defined cert validator.</param>
-		public TTLSSocket(string host, int port, int timeout, X509Certificate certificate, RemoteCertificateValidationCallback certValidator = null)
-		{
-			this.host = host;
-			this.port = port;
-			this.timeout = timeout;
-			this.certificate = certificate;
-			this.certValidator = certValidator;
+        /// <summary>
+        /// Initializes a new instance of the <see cref="TTLSSocket"/> class.
+        /// </summary>
+        /// <param name="host">The host, where the socket should connect to.</param>
+        /// <param name="port">The port.</param>
+        /// <param name="timeout">The timeout.</param>
+        /// <param name="certificate">The certificate.</param>
+        /// <param name="certValidator">User defined cert validator.</param>
+        public TTLSSocket(string host, int port, int timeout, X509Certificate certificate, RemoteCertificateValidationCallback certValidator = null)
+        {
+            this.host = host;
+            this.port = port;
+            this.timeout = timeout;
+            this.certificate = certificate;
+            this.certValidator = certValidator;
 
-			InitSocket();
-		}
+            InitSocket();
+        }
 
-		/// <summary>
-		/// Creates the TcpClient and sets the timeouts
-		/// </summary>
-		private void InitSocket()
-		{
-			this.client = new TcpClient();
-			client.ReceiveTimeout = client.SendTimeout = timeout;
-			client.Client.NoDelay = true;
-		}
+        /// <summary>
+        /// Creates the TcpClient and sets the timeouts
+        /// </summary>
+        private void InitSocket()
+        {
+            this.client = new TcpClient();
+            client.ReceiveTimeout = client.SendTimeout = timeout;
+            client.Client.NoDelay = true;
+        }
 
-		/// <summary>
-		/// Sets Send / Recv Timeout for IO
-		/// </summary>
-		public int Timeout
-		{
-			set
-			{
-				this.client.ReceiveTimeout = this.client.SendTimeout = this.timeout = value;
-			}
-		}
+        /// <summary>
+        /// Sets Send / Recv Timeout for IO
+        /// </summary>
+        public int Timeout
+        {
+            set
+            {
+                this.client.ReceiveTimeout = this.client.SendTimeout = this.timeout = value;
+            }
+        }
 
-		/// <summary>
-		/// Gets the TCP client.
-		/// </summary>
-		public TcpClient TcpClient
-		{
-			get
-			{
-				return client;
-			}
-		}
+        /// <summary>
+        /// Gets the TCP client.
+        /// </summary>
+        public TcpClient TcpClient
+        {
+            get
+            {
+                return client;
+            }
+        }
 
-		/// <summary>
-		/// Gets the host.
-		/// </summary>
-		public string Host
-		{
-			get
-			{
-				return host;
-			}
-		}
+        /// <summary>
+        /// Gets the host.
+        /// </summary>
+        public string Host
+        {
+            get
+            {
+                return host;
+            }
+        }
 
-		/// <summary>
-		/// Gets the port.
-		/// </summary>
-		public int Port
-		{
-			get
-			{
-				return port;
-			}
-		}
+        /// <summary>
+        /// Gets the port.
+        /// </summary>
+        public int Port
+        {
+            get
+            {
+                return port;
+            }
+        }
 
-		/// <summary>
-		/// Gets a value indicating whether TCP Client is Cpen 
-		/// </summary>
-		public override bool IsOpen
-		{
-			get
-			{
-				if (this.client == null)
-				{
-					return false;
-				}
+        /// <summary>
+        /// Gets a value indicating whether TCP Client is Cpen
+        /// </summary>
+        public override bool IsOpen
+        {
+            get
+            {
+                if (this.client == null)
+                {
+                    return false;
+                }
 
-				return this.client.Connected;
-			}
-		}
+                return this.client.Connected;
+            }
+        }
 
-		/// <summary>
-		/// Validates the certificates!<br/>
-		/// </summary>
-		/// <param name="sender">The sender-object.</param>
-		/// <param name="certificate">The used certificate.</param>
-		/// <param name="chain">The certificate chain.</param>
-		/// <param name="sslPolicyErrors">An enum, which lists all the errors from the .NET certificate check.</param>
-		/// <returns></returns>
-		private bool CertificateValidator(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslValidationErrors)
-		{
-			return (sslValidationErrors == SslPolicyErrors.None);
-		}
+        /// <summary>
+        /// Validates the certificates!<br/>
+        /// </summary>
+        /// <param name="sender">The sender-object.</param>
+        /// <param name="certificate">The used certificate.</param>
+        /// <param name="chain">The certificate chain.</param>
+        /// <param name="sslPolicyErrors">An enum, which lists all the errors from the .NET certificate check.</param>
+        /// <returns></returns>
+        private bool CertificateValidator(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslValidationErrors)
+        {
+            return (sslValidationErrors == SslPolicyErrors.None);
+        }
 
-		/// <summary>
-		/// Connects to the host and starts the routine, which sets up the TLS
-		/// </summary>
-		public override void Open()
-		{
-			if (IsOpen)
-			{
-				throw new TTransportException(TTransportException.ExceptionType.AlreadyOpen, "Socket already connected");
-			}
+        /// <summary>
+        /// Connects to the host and starts the routine, which sets up the TLS
+        /// </summary>
+        public override void Open()
+        {
+            if (IsOpen)
+            {
+                throw new TTransportException(TTransportException.ExceptionType.AlreadyOpen, "Socket already connected");
+            }
 
-			if (String.IsNullOrEmpty(host))
-			{
-				throw new TTransportException(TTransportException.ExceptionType.NotOpen, "Cannot open null host");
-			}
+            if (String.IsNullOrEmpty(host))
+            {
+                throw new TTransportException(TTransportException.ExceptionType.NotOpen, "Cannot open null host");
+            }
 
-			if (port <= 0)
-			{
-				throw new TTransportException(TTransportException.ExceptionType.NotOpen, "Cannot open without port");
-			}
+            if (port <= 0)
+            {
+                throw new TTransportException(TTransportException.ExceptionType.NotOpen, "Cannot open without port");
+            }
 
-			if (client == null)
-			{
-				InitSocket();
-			}
+            if (client == null)
+            {
+                InitSocket();
+            }
 
-			client.Connect(host, port);
+            client.Connect(host, port);
 
-			setupTLS();
-		}
+            setupTLS();
+        }
 
-		/// <summary>
-		/// Creates a TLS-stream and lays it over the existing socket
-		/// </summary>
-		public void setupTLS()
-		{
-			if (isServer)
-			{
-				// Server authentication
-				this.secureStream = new SslStream(this.client.GetStream(), false);
-				this.secureStream.AuthenticateAsServer(this.certificate, false, SslProtocols.Tls, true);
-			}
-			else
-			{
-				// Client authentication
-				X509CertificateCollection validCerts = new X509CertificateCollection();
-				validCerts.Add(certificate);
+        /// <summary>
+        /// Creates a TLS-stream and lays it over the existing socket
+        /// </summary>
+        public void setupTLS()
+        {
+            if (isServer)
+            {
+                // Server authentication
+                this.secureStream = new SslStream(this.client.GetStream(), false);
+                this.secureStream.AuthenticateAsServer(this.certificate, false, SslProtocols.Tls, true);
+            }
+            else
+            {
+                // Client authentication
+                X509CertificateCollection validCerts = new X509CertificateCollection();
+                validCerts.Add(certificate);
 
-				if (this.certValidator != null)
-				{
-					this.secureStream = new SslStream(this.client.GetStream(), false, new RemoteCertificateValidationCallback(this.certValidator));
-				}
-				else
-				{
-					this.secureStream = new SslStream(this.client.GetStream(), false, new RemoteCertificateValidationCallback(CertificateValidator));
-				}
-				this.secureStream.AuthenticateAsClient(host, validCerts, SslProtocols.Tls, true);
-			}
+                if (this.certValidator != null)
+                {
+                    this.secureStream = new SslStream(this.client.GetStream(), false, new RemoteCertificateValidationCallback(this.certValidator));
+                }
+                else
+                {
+                    this.secureStream = new SslStream(this.client.GetStream(), false, new RemoteCertificateValidationCallback(CertificateValidator));
+                }
+                this.secureStream.AuthenticateAsClient(host, validCerts, SslProtocols.Tls, true);
+            }
 
-			inputStream = this.secureStream;
-			outputStream = this.secureStream;
-		}
+            inputStream = this.secureStream;
+            outputStream = this.secureStream;
+        }
 
-		/// <summary>
-		/// Closes the SSL Socket
-		/// </summary>
-		public override void Close()
-		{
-			base.Close();
-			if (this.client != null)
-			{
-				this.client.Close();
-				this.client = null;
-			}
+        /// <summary>
+        /// Closes the SSL Socket
+        /// </summary>
+        public override void Close()
+        {
+            base.Close();
+            if (this.client != null)
+            {
+                this.client.Close();
+                this.client = null;
+            }
 
-			if (this.secureStream != null)
-			{
-				this.secureStream.Close();
-				this.secureStream = null;
-			}
-		}
-	}
+            if (this.secureStream != null)
+            {
+                this.secureStream.Close();
+                this.secureStream = null;
+            }
+        }
+    }
 }
diff --git a/lib/csharp/src/Transport/TTransport.cs b/lib/csharp/src/Transport/TTransport.cs
index 5bb8f9e..13314ec 100644
--- a/lib/csharp/src/Transport/TTransport.cs
+++ b/lib/csharp/src/Transport/TTransport.cs
@@ -25,24 +25,24 @@
 
 namespace Thrift.Transport
 {
-	public abstract class TTransport : IDisposable
-	{
-		public abstract bool IsOpen
-		{
-			get;
-		}
+    public abstract class TTransport : IDisposable
+    {
+        public abstract bool IsOpen
+        {
+            get;
+        }
 
-		private byte[] _peekBuffer = new byte[1];
+        private byte[] _peekBuffer = new byte[1];
         private bool _hasPeekByte = false;
 
         public bool Peek()
         {
             //If we already have a byte read but not consumed, do nothing.
-            if (_hasPeekByte) 
+            if (_hasPeekByte)
                 return true;
 
             //If transport closed we can't peek.
-            if (!IsOpen) 
+            if (!IsOpen)
                 return false;
 
             //Try to read one byte. If succeeds we will need to store it for the next read.
@@ -54,15 +54,15 @@
             return true;
         }
 
-		public abstract void Open();
+        public abstract void Open();
 
-		public abstract void Close();
+        public abstract void Close();
 
-		public abstract int Read(byte[] buf, int off, int len);
+        public abstract int Read(byte[] buf, int off, int len);
 
-		public int ReadAll(byte[] buf, int off, int len)
-		{
-			int got = 0;
+        public int ReadAll(byte[] buf, int off, int len)
+        {
+            int got = 0;
 
             //If we previously peeked a byte, we need to use that first.
             if (_hasPeekByte)
@@ -83,19 +83,19 @@
                 got += ret;
             }
             return got;
-		}
+        }
 
-		public virtual void Write(byte[] buf) 
-		{
-			Write (buf, 0, buf.Length);
-		}
+        public virtual void Write(byte[] buf)
+        {
+            Write (buf, 0, buf.Length);
+        }
 
-		public abstract void Write(byte[] buf, int off, int len);
+        public abstract void Write(byte[] buf, int off, int len);
 
-		public virtual void Flush()
-		{
-		}
-        
+        public virtual void Flush()
+        {
+        }
+
         public virtual IAsyncResult BeginFlush(AsyncCallback callback, object state)
         {
             throw new TTransportException(
@@ -110,16 +110,16 @@
                 "Asynchronous operations are not supported by this transport.");
         }
 
-		#region " IDisposable Support "
-		// IDisposable
-		protected abstract void Dispose(bool disposing);
+        #region " IDisposable Support "
+        // IDisposable
+        protected abstract void Dispose(bool disposing);
 
-		public void Dispose()
-		{
-			// Do not change this code.  Put cleanup code in Dispose(ByVal disposing As Boolean) above.
-			Dispose(true);
-			GC.SuppressFinalize(this);
-		}
-		#endregion
-	}
+        public void Dispose()
+        {
+            // Do not change this code.  Put cleanup code in Dispose(ByVal disposing As Boolean) above.
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+        #endregion
+    }
 }
diff --git a/lib/csharp/src/Transport/TTransportException.cs b/lib/csharp/src/Transport/TTransportException.cs
index fda0138..6dcd987 100644
--- a/lib/csharp/src/Transport/TTransportException.cs
+++ b/lib/csharp/src/Transport/TTransportException.cs
@@ -25,44 +25,44 @@
 
 namespace Thrift.Transport
 {
-	public class TTransportException : TException
-	{
-		protected ExceptionType type;
+    public class TTransportException : TException
+    {
+        protected ExceptionType type;
 
-		public TTransportException()
-			: base()
-		{
-		}
+        public TTransportException()
+            : base()
+        {
+        }
 
-		public TTransportException(ExceptionType type)
-			: this()
-		{
-			this.type = type;
-		}
+        public TTransportException(ExceptionType type)
+            : this()
+        {
+            this.type = type;
+        }
 
-		public TTransportException(ExceptionType type, string message)
-			: base(message)
-		{
-			this.type = type;
-		}
+        public TTransportException(ExceptionType type, string message)
+            : base(message)
+        {
+            this.type = type;
+        }
 
-		public TTransportException(string message)
-			: base(message)
-		{
-		}
+        public TTransportException(string message)
+            : base(message)
+        {
+        }
 
-		public ExceptionType Type
-		{
-			get { return type; }
-		}
+        public ExceptionType Type
+        {
+            get { return type; }
+        }
 
-		public enum ExceptionType
-		{
-			Unknown,
-			NotOpen,
-			AlreadyOpen,
-			TimedOut,
-			EndOfFile
-		}
-	}
+        public enum ExceptionType
+        {
+            Unknown,
+            NotOpen,
+            AlreadyOpen,
+            TimedOut,
+            EndOfFile
+        }
+    }
 }
diff --git a/lib/csharp/src/Transport/TTransportFactory.cs b/lib/csharp/src/Transport/TTransportFactory.cs
index 8f4f15d..fa10033 100644
--- a/lib/csharp/src/Transport/TTransportFactory.cs
+++ b/lib/csharp/src/Transport/TTransportFactory.cs
@@ -25,18 +25,18 @@
 
 namespace Thrift.Transport
 {
-	/// <summary>
-	/// From Mark Slee & Aditya Agarwal of Facebook:
-	/// Factory class used to create wrapped instance of Transports.
-	/// This is used primarily in servers, which get Transports from
-	/// a ServerTransport and then may want to mutate them (i.e. create
-	/// a BufferedTransport from the underlying base transport)
-	/// </summary>
-	public class TTransportFactory
-	{
-		public virtual TTransport GetTransport(TTransport trans)
-		{
-			return trans;
-		}
-	}
+    /// <summary>
+    /// From Mark Slee & Aditya Agarwal of Facebook:
+    /// Factory class used to create wrapped instance of Transports.
+    /// This is used primarily in servers, which get Transports from
+    /// a ServerTransport and then may want to mutate them (i.e. create
+    /// a BufferedTransport from the underlying base transport)
+    /// </summary>
+    public class TTransportFactory
+    {
+        public virtual TTransport GetTransport(TTransport trans)
+        {
+            return trans;
+        }
+    }
 }
diff --git a/lib/csharp/test/JSON/JSONTest.csproj b/lib/csharp/test/JSON/JSONTest.csproj
index 61e8e6c..f07d43e 100644
--- a/lib/csharp/test/JSON/JSONTest.csproj
+++ b/lib/csharp/test/JSON/JSONTest.csproj
@@ -75,7 +75,7 @@
     </ProjectReference>
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
        Other similar extension points exist, see Microsoft.Common.targets.
   <Target Name="BeforeBuild">
   </Target>
diff --git a/lib/csharp/test/JSON/Program.cs b/lib/csharp/test/JSON/Program.cs
index d66c78a..9823221 100644
--- a/lib/csharp/test/JSON/Program.cs
+++ b/lib/csharp/test/JSON/Program.cs
@@ -28,55 +28,55 @@
 
 namespace JSONTest
 {
-	class Program
-	{
-		static void Main(string[] args)
-		{
-			TestThrift2365();  // JSON binary decodes too much data
-			TestThrift2336();  // hex encoding using \uXXXX where 0xXXXX > 0xFF
-		}
+    class Program
+    {
+        static void Main(string[] args)
+        {
+            TestThrift2365();  // JSON binary decodes too much data
+            TestThrift2336();  // hex encoding using \uXXXX where 0xXXXX > 0xFF
+        }
 
 
-		public static void TestThrift2365()
-		{
-			var rnd = new Random();
-			for (var len = 0; len < 10; ++len)
-			{
-				byte[] dataWritten = new byte[len];
-				rnd.NextBytes(dataWritten);
+        public static void TestThrift2365()
+        {
+            var rnd = new Random();
+            for (var len = 0; len < 10; ++len)
+            {
+                byte[] dataWritten = new byte[len];
+                rnd.NextBytes(dataWritten);
 
-				Stream stm = new MemoryStream();
-				TTransport trans = new TStreamTransport(null, stm);
-				TProtocol prot = new TJSONProtocol(trans);
-				prot.WriteBinary(dataWritten);
+                Stream stm = new MemoryStream();
+                TTransport trans = new TStreamTransport(null, stm);
+                TProtocol prot = new TJSONProtocol(trans);
+                prot.WriteBinary(dataWritten);
 
-				stm.Position = 0;
-				trans = new TStreamTransport(stm, null);
-				prot = new TJSONProtocol(trans);
-				byte[] dataRead = prot.ReadBinary();
+                stm.Position = 0;
+                trans = new TStreamTransport(stm, null);
+                prot = new TJSONProtocol(trans);
+                byte[] dataRead = prot.ReadBinary();
 
-				Debug.Assert(dataRead.Length == dataWritten.Length);
-				for (var i = 0; i < dataRead.Length; ++i)
-					Debug.Assert(dataRead[i] == dataWritten[i]);			
-			}
-		}
+                Debug.Assert(dataRead.Length == dataWritten.Length);
+                for (var i = 0; i < dataRead.Length; ++i)
+                    Debug.Assert(dataRead[i] == dataWritten[i]);
+            }
+        }
 
 
-		public static void TestThrift2336()
-		{
-			const string RUSSIAN_TEXT = "\u0420\u0443\u0441\u0441\u043a\u043e\u0435 \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435";
-			const string RUSSIAN_JSON = "\"\\u0420\\u0443\\u0441\\u0441\\u043a\\u043e\\u0435 \\u041d\\u0430\\u0437\\u0432\\u0430\\u043d\\u0438\\u0435\"";
-			
-			// prepare buffer with JSON data
-			byte[] rawBytes = new byte[RUSSIAN_JSON.Length];
-			for (var i = 0; i < RUSSIAN_JSON.Length; ++i)
-				rawBytes[i] = (byte)(RUSSIAN_JSON[i] & (char)0xFF);  // only low bytes
+        public static void TestThrift2336()
+        {
+            const string RUSSIAN_TEXT = "\u0420\u0443\u0441\u0441\u043a\u043e\u0435 \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435";
+            const string RUSSIAN_JSON = "\"\\u0420\\u0443\\u0441\\u0441\\u043a\\u043e\\u0435 \\u041d\\u0430\\u0437\\u0432\\u0430\\u043d\\u0438\\u0435\"";
 
-			// parse and check
-			var stm = new MemoryStream(rawBytes);
-			var trans = new TStreamTransport(stm, null);
-			var prot = new TJSONProtocol(trans);
-			Debug.Assert(prot.ReadString() == RUSSIAN_TEXT, "reading JSON with hex-encoded chars > 8 bit");
-		}
-	}
+            // prepare buffer with JSON data
+            byte[] rawBytes = new byte[RUSSIAN_JSON.Length];
+            for (var i = 0; i < RUSSIAN_JSON.Length; ++i)
+                rawBytes[i] = (byte)(RUSSIAN_JSON[i] & (char)0xFF);  // only low bytes
+
+            // parse and check
+            var stm = new MemoryStream(rawBytes);
+            var trans = new TStreamTransport(stm, null);
+            var prot = new TJSONProtocol(trans);
+            Debug.Assert(prot.ReadString() == RUSSIAN_TEXT, "reading JSON with hex-encoded chars > 8 bit");
+        }
+    }
 }
diff --git a/lib/csharp/test/JSON/Properties/AssemblyInfo.cs b/lib/csharp/test/JSON/Properties/AssemblyInfo.cs
index 8629f6f..6788bc3 100644
--- a/lib/csharp/test/JSON/Properties/AssemblyInfo.cs
+++ b/lib/csharp/test/JSON/Properties/AssemblyInfo.cs
@@ -21,7 +21,7 @@
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
-// Allgemeine Informationen über eine Assembly werden über die folgenden 
+// Allgemeine Informationen über eine Assembly werden über die folgenden
 // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
 // die mit einer Assembly verknüpft sind.
 [assembly: AssemblyTitle("JSONTest")]
@@ -33,8 +33,8 @@
 [assembly: AssemblyTrademark("")]
 [assembly: AssemblyCulture("")]
 
-// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar 
-// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von 
+// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
+// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
 // COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
 [assembly: ComVisible(false)]
 
@@ -44,11 +44,11 @@
 // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
 //
 //      Hauptversion
-//      Nebenversion 
+//      Nebenversion
 //      Buildnummer
 //      Revision
 //
-// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern 
+// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
 // übernehmen, indem Sie "*" eingeben:
 // [assembly: AssemblyVersion("1.0.*")]
 [assembly: AssemblyVersion("1.0.0.0")]
diff --git a/lib/csharp/test/JSON/app.config b/lib/csharp/test/JSON/app.config
index bc39140..9c1919d 100644
--- a/lib/csharp/test/JSON/app.config
+++ b/lib/csharp/test/JSON/app.config
@@ -1,21 +1,21 @@
-<?xml version="1.0"?>

-<!--

-  Licensed to the Apache Software Foundation (ASF) under one

-  or more contributor license agreements. See the NOTICE file

-  distributed with this work for additional information

-  regarding copyright ownership. The ASF licenses this file

-  to you under the Apache License, Version 2.0 (the

-  "License"); you may not use this file except in compliance

-  with the License. You may obtain a copy of the License at

-

-    http://www.apache.org/licenses/LICENSE-2.0

-

-  Unless required by applicable law or agreed to in writing,

-  software distributed under the License is distributed on an

-  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

-  KIND, either express or implied. See the License for the

-  specific language governing permissions and limitations

-  under the License.

--->

-<configuration>

-<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<configuration>
+<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
diff --git a/lib/csharp/test/Multiplex/Client/Multiplex.Test.Client.cs b/lib/csharp/test/Multiplex/Client/Multiplex.Test.Client.cs
index 95ba5a4..ccfe21d 100644
--- a/lib/csharp/test/Multiplex/Client/Multiplex.Test.Client.cs
+++ b/lib/csharp/test/Multiplex/Client/Multiplex.Test.Client.cs
@@ -29,8 +29,8 @@
 
 namespace Test.Multiplex.Client
 {
-	public class TestClient
-	{
+    public class TestClient
+    {
         private void Run()
         {
             try
@@ -49,7 +49,7 @@
 
                 multiplex = new TMultiplexedProtocol( Protocol, Constants.NAME_AGGR);
                 Aggr.Iface aggr = new Aggr.Client( multiplex);
-                
+
                 sbyte i;
                 for( i = 1; 10 >= i; ++i)
                 {
diff --git a/lib/csharp/test/Multiplex/Multiplex.Test.Common.cs b/lib/csharp/test/Multiplex/Multiplex.Test.Common.cs
index 5296b68..a687852 100644
--- a/lib/csharp/test/Multiplex/Multiplex.Test.Common.cs
+++ b/lib/csharp/test/Multiplex/Multiplex.Test.Common.cs
@@ -30,8 +30,8 @@
 
 namespace Test.Multiplex
 {
-	public class Constants
-	{
+    public class Constants
+    {
         public const string NAME_BENCHMARKSERVICE = "BenchmarkService";
         public const string NAME_AGGR             = "Aggr";
     }
diff --git a/lib/csharp/test/Multiplex/Server/Multiplex.Test.Server.cs b/lib/csharp/test/Multiplex/Server/Multiplex.Test.Server.cs
index fbec1b7..61c2d7c 100644
--- a/lib/csharp/test/Multiplex/Server/Multiplex.Test.Server.cs
+++ b/lib/csharp/test/Multiplex/Server/Multiplex.Test.Server.cs
@@ -28,8 +28,8 @@
 
 namespace Test.Multiplex.Server
 {
-	public class TestServer
-	{
+    public class TestServer
+    {
         public interface ITestHandler
         {
             void SetServer( TServer aServer);
@@ -38,7 +38,7 @@
         protected class TestHandlerImpl : ITestHandler
         {
             private TServer Server;
-    
+
             public void SetServer( TServer aServer)
             {
                 Server = aServer;
@@ -53,7 +53,7 @@
                 int prev, next, result;
                 prev   = 0;
                 result = 1;
-                while( n > 0) 
+                while( n > 0)
                 {
                     next   = result + prev;
                     prev   = result;
@@ -110,7 +110,7 @@
                (benchHandler as ITestHandler).SetServer(null);
                (aggrHandler as ITestHandler).SetServer(null);
 
-           } 
+           }
            catch( Exception e)
            {
                Console.WriteLine( e.Message);
@@ -118,7 +118,7 @@
            Console.WriteLine( "done.");
        }
 
-        
+
        static void Main(string[] args)
        {
            Execute();
diff --git a/lib/csharp/test/Multiplex/maketest.sh b/lib/csharp/test/Multiplex/maketest.sh
index a2bcde4..1f29ee2 100755
--- a/lib/csharp/test/Multiplex/maketest.sh
+++ b/lib/csharp/test/Multiplex/maketest.sh
@@ -22,13 +22,13 @@
 ../../../../compiler/cpp/thrift --gen csharp  ../../../../contrib/async-test/aggr.thrift
 ../../../../compiler/cpp/thrift --gen csharp  ../../../rb/benchmark/Benchmark.thrift
 gmcs /t:library /out:./ThriftImpl.dll /recurse:./gen-csharp/* /reference:../../Thrift.dll Multiplex.Test.Common.cs
-gmcs  /out:MultiplexClient.exe /reference:../../Thrift.dll /reference:ThriftImpl.dll Client/Multiplex.Test.Client.cs  
-gmcs  /out:MultiplexServer.exe /reference:../../Thrift.dll /reference:ThriftImpl.dll Server/Multiplex.Test.Server.cs  
+gmcs  /out:MultiplexClient.exe /reference:../../Thrift.dll /reference:ThriftImpl.dll Client/Multiplex.Test.Client.cs
+gmcs  /out:MultiplexServer.exe /reference:../../Thrift.dll /reference:ThriftImpl.dll Server/Multiplex.Test.Server.cs
 
 
 
 export MONO_PATH=../../
 
-timeout 120 ./MultiplexServer.exe & 
+timeout 120 ./MultiplexServer.exe &
 sleep 3;
 ./MultiplexClient.exe
diff --git a/lib/csharp/test/ThriftTest/Program.cs b/lib/csharp/test/ThriftTest/Program.cs
index 4c63ca4..3bf6796 100644
--- a/lib/csharp/test/ThriftTest/Program.cs
+++ b/lib/csharp/test/ThriftTest/Program.cs
@@ -29,33 +29,33 @@
 
 namespace Test
 {
-	class Program
-	{
-		static void Main(string[] args)
-		{
-			if (args.Length == 0)
-			{
-				Console.WriteLine("must provide 'server' or 'client' arg");
-				return;
-			}
+    class Program
+    {
+        static void Main(string[] args)
+        {
+            if (args.Length == 0)
+            {
+                Console.WriteLine("must provide 'server' or 'client' arg");
+                return;
+            }
 
-			string[] subArgs = new string[args.Length - 1];
-			for(int i = 1; i < args.Length; i++)
-			{
-				subArgs[i-1] = args[i];
-			}
-			if (args[0] == "client")
-			{
-				TestClient.Execute(subArgs);
-			}
-			else if (args[0] == "server")
-			{
-				TestServer.Execute(subArgs);
-			}
-			else
-			{
-				Console.WriteLine("first argument must be 'server' or 'client'");
-			}
-		}
-	}
+            string[] subArgs = new string[args.Length - 1];
+            for(int i = 1; i < args.Length; i++)
+            {
+                subArgs[i-1] = args[i];
+            }
+            if (args[0] == "client")
+            {
+                TestClient.Execute(subArgs);
+            }
+            else if (args[0] == "server")
+            {
+                TestServer.Execute(subArgs);
+            }
+            else
+            {
+                Console.WriteLine("first argument must be 'server' or 'client'");
+            }
+        }
+    }
 }
diff --git a/lib/csharp/test/ThriftTest/TestClient.cs b/lib/csharp/test/ThriftTest/TestClient.cs
index db0fe63..cb33473 100644
--- a/lib/csharp/test/ThriftTest/TestClient.cs
+++ b/lib/csharp/test/ThriftTest/TestClient.cs
@@ -27,453 +27,453 @@
 
 namespace Test
 {
-	public class TestClient
-	{
-		private static int numIterations = 1;
-		private static string protocol = "";
+    public class TestClient
+    {
+        private static int numIterations = 1;
+        private static string protocol = "";
 
-		public static void Execute(string[] args)
-		{
-			try
-			{
-				string host = "localhost";
-				int port = 9090;
-				string url = null, pipe = null;
-				int numThreads = 1;
-				bool buffered = false, framed = false, encrypted = false;
+        public static void Execute(string[] args)
+        {
+            try
+            {
+                string host = "localhost";
+                int port = 9090;
+                string url = null, pipe = null;
+                int numThreads = 1;
+                bool buffered = false, framed = false, encrypted = false;
 
-				try
-				{
-					for (int i = 0; i < args.Length; i++)
-					{
-						if (args[i] == "-u")
-						{
-							url = args[++i];
-						}
-						else if (args[i] == "-n")
-						{
-							numIterations = Convert.ToInt32(args[++i]);
-						}
-						else if (args[i] == "-pipe")  // -pipe <name>
-						{
-							pipe = args[++i];
-							Console.WriteLine("Using named pipes transport");
-						}
-						else if (args[i].Contains("--host="))
-						{
-							host = args[i].Substring(args[i].IndexOf("=") + 1);
-						}
-						else if (args[i].Contains("--port="))
-						{
-							port = int.Parse(args[i].Substring(args[i].IndexOf("=")+1));
-						}
-						else if (args[i] == "-b" || args[i] == "--buffered" || args[i] == "--transport=buffered")
-						{
-							buffered = true;
-							Console.WriteLine("Using buffered sockets");
-						}
-						else if (args[i] == "-f" || args[i] == "--framed"  || args[i] == "--transport=framed")
-						{
-							framed = true;
-							Console.WriteLine("Using framed transport");
-						}
-						else if (args[i] == "-t")
-						{
-							numThreads = Convert.ToInt32(args[++i]);
-						}
-						else if (args[i] == "--compact" || args[i] == "--protocol=compact")
-						{
-							protocol = "compact";
-							Console.WriteLine("Using compact protocol");
-						}
-						else if (args[i] == "--json" || args[i] == "--protocol=json")
-						{
-							protocol = "json";
-							Console.WriteLine("Using JSON protocol");
-						}
-						else if (args[i] == "--ssl")
-						{
-							encrypted = true;
-							Console.WriteLine("Using encrypted transport");
-						}
-					}
-				}
-				catch (Exception e)
-				{
-					Console.WriteLine(e.StackTrace);
-				}
+                try
+                {
+                    for (int i = 0; i < args.Length; i++)
+                    {
+                        if (args[i] == "-u")
+                        {
+                            url = args[++i];
+                        }
+                        else if (args[i] == "-n")
+                        {
+                            numIterations = Convert.ToInt32(args[++i]);
+                        }
+                        else if (args[i] == "-pipe")  // -pipe <name>
+                        {
+                            pipe = args[++i];
+                            Console.WriteLine("Using named pipes transport");
+                        }
+                        else if (args[i].Contains("--host="))
+                        {
+                            host = args[i].Substring(args[i].IndexOf("=") + 1);
+                        }
+                        else if (args[i].Contains("--port="))
+                        {
+                            port = int.Parse(args[i].Substring(args[i].IndexOf("=")+1));
+                        }
+                        else if (args[i] == "-b" || args[i] == "--buffered" || args[i] == "--transport=buffered")
+                        {
+                            buffered = true;
+                            Console.WriteLine("Using buffered sockets");
+                        }
+                        else if (args[i] == "-f" || args[i] == "--framed"  || args[i] == "--transport=framed")
+                        {
+                            framed = true;
+                            Console.WriteLine("Using framed transport");
+                        }
+                        else if (args[i] == "-t")
+                        {
+                            numThreads = Convert.ToInt32(args[++i]);
+                        }
+                        else if (args[i] == "--compact" || args[i] == "--protocol=compact")
+                        {
+                            protocol = "compact";
+                            Console.WriteLine("Using compact protocol");
+                        }
+                        else if (args[i] == "--json" || args[i] == "--protocol=json")
+                        {
+                            protocol = "json";
+                            Console.WriteLine("Using JSON protocol");
+                        }
+                        else if (args[i] == "--ssl")
+                        {
+                            encrypted = true;
+                            Console.WriteLine("Using encrypted transport");
+                        }
+                    }
+                }
+                catch (Exception e)
+                {
+                    Console.WriteLine(e.StackTrace);
+                }
 
-				//issue tests on separate threads simultaneously
-				Thread[] threads = new Thread[numThreads];
-				DateTime start = DateTime.Now;
-				for (int test = 0; test < numThreads; test++)
-				{
-					Thread t = new Thread(new ParameterizedThreadStart(ClientThread));
-					threads[test] = t;
-					if (url == null)
-					{
-						// endpoint transport
-						TTransport trans = null;
-						if (pipe != null)
-							trans = new TNamedPipeClientTransport(pipe);
-						else
-						{
-							if (encrypted)
-								trans = new TTLSSocket(host, port, "../../../../../keys/client.pem");
-							else
-								trans = new TSocket(host, port);
-						}
+                //issue tests on separate threads simultaneously
+                Thread[] threads = new Thread[numThreads];
+                DateTime start = DateTime.Now;
+                for (int test = 0; test < numThreads; test++)
+                {
+                    Thread t = new Thread(new ParameterizedThreadStart(ClientThread));
+                    threads[test] = t;
+                    if (url == null)
+                    {
+                        // endpoint transport
+                        TTransport trans = null;
+                        if (pipe != null)
+                            trans = new TNamedPipeClientTransport(pipe);
+                        else
+                        {
+                            if (encrypted)
+                                trans = new TTLSSocket(host, port, "../../../../../keys/client.pem");
+                            else
+                                trans = new TSocket(host, port);
+                        }
 
-						// layered transport
-						if (buffered)
-							trans = new TBufferedTransport(trans as TStreamTransport);
-						if (framed)
-							trans = new TFramedTransport(trans);
+                        // layered transport
+                        if (buffered)
+                            trans = new TBufferedTransport(trans as TStreamTransport);
+                        if (framed)
+                            trans = new TFramedTransport(trans);
 
-						//ensure proper open/close of transport
-						trans.Open();
-						trans.Close();
-						t.Start(trans);
-					}
-					else
-					{
-						THttpClient http = new THttpClient(new Uri(url));
-						t.Start(http);
-					}
-				}
+                        //ensure proper open/close of transport
+                        trans.Open();
+                        trans.Close();
+                        t.Start(trans);
+                    }
+                    else
+                    {
+                        THttpClient http = new THttpClient(new Uri(url));
+                        t.Start(http);
+                    }
+                }
 
-				for (int test = 0; test < numThreads; test++)
-				{
-					threads[test].Join();
-				}
-				Console.Write("Total time: " + (DateTime.Now - start));
-			}
-			catch (Exception outerEx)
-			{
-				Console.WriteLine(outerEx.Message + " ST: " + outerEx.StackTrace);
-			}
+                for (int test = 0; test < numThreads; test++)
+                {
+                    threads[test].Join();
+                }
+                Console.Write("Total time: " + (DateTime.Now - start));
+            }
+            catch (Exception outerEx)
+            {
+                Console.WriteLine(outerEx.Message + " ST: " + outerEx.StackTrace);
+            }
 
-			Console.WriteLine();
-			Console.WriteLine();
-		}
+            Console.WriteLine();
+            Console.WriteLine();
+        }
 
-		public static void ClientThread(object obj)
-		{
-			TTransport transport = (TTransport)obj;
-			for (int i = 0; i < numIterations; i++)
-			{
-				ClientTest(transport);
-			}
-			transport.Close();
-		}
+        public static void ClientThread(object obj)
+        {
+            TTransport transport = (TTransport)obj;
+            for (int i = 0; i < numIterations; i++)
+            {
+                ClientTest(transport);
+            }
+            transport.Close();
+        }
 
-		public static void ClientTest(TTransport transport)
-		{
-			TProtocol proto;
-			if (protocol == "compact")
-				proto = new TCompactProtocol(transport);
-			else if (protocol == "json")
-				proto = new TJSONProtocol(transport);
-			else
-				proto = new TBinaryProtocol(transport);
+        public static void ClientTest(TTransport transport)
+        {
+            TProtocol proto;
+            if (protocol == "compact")
+                proto = new TCompactProtocol(transport);
+            else if (protocol == "json")
+                proto = new TJSONProtocol(transport);
+            else
+                proto = new TBinaryProtocol(transport);
 
-			ThriftTest.Client client = new ThriftTest.Client(proto);
-			try
-			{
-				if (!transport.IsOpen)
-				{
-					transport.Open();
-				}
-			}
-			catch (TTransportException ttx)
-			{
-				Console.WriteLine("Connect failed: " + ttx.Message);
-				return;
-			}
+            ThriftTest.Client client = new ThriftTest.Client(proto);
+            try
+            {
+                if (!transport.IsOpen)
+                {
+                    transport.Open();
+                }
+            }
+            catch (TTransportException ttx)
+            {
+                Console.WriteLine("Connect failed: " + ttx.Message);
+                return;
+            }
 
-			long start = DateTime.Now.ToFileTime();
+            long start = DateTime.Now.ToFileTime();
 
-			Console.Write("testVoid()");
-			client.testVoid();
-			Console.WriteLine(" = void");
+            Console.Write("testVoid()");
+            client.testVoid();
+            Console.WriteLine(" = void");
 
-			Console.Write("testString(\"Test\")");
-			string s = client.testString("Test");
-			Console.WriteLine(" = \"" + s + "\"");
+            Console.Write("testString(\"Test\")");
+            string s = client.testString("Test");
+            Console.WriteLine(" = \"" + s + "\"");
 
-			Console.Write("testByte(1)");
-			sbyte i8 = client.testByte((sbyte)1);
-			Console.WriteLine(" = " + i8);
+            Console.Write("testByte(1)");
+            sbyte i8 = client.testByte((sbyte)1);
+            Console.WriteLine(" = " + i8);
 
-			Console.Write("testI32(-1)");
-			int i32 = client.testI32(-1);
-			Console.WriteLine(" = " + i32);
+            Console.Write("testI32(-1)");
+            int i32 = client.testI32(-1);
+            Console.WriteLine(" = " + i32);
 
-			Console.Write("testI64(-34359738368)");
-			long i64 = client.testI64(-34359738368);
-			Console.WriteLine(" = " + i64);
+            Console.Write("testI64(-34359738368)");
+            long i64 = client.testI64(-34359738368);
+            Console.WriteLine(" = " + i64);
 
-			Console.Write("testDouble(5.325098235)");
-			double dub = client.testDouble(5.325098235);
-			Console.WriteLine(" = " + dub);
+            Console.Write("testDouble(5.325098235)");
+            double dub = client.testDouble(5.325098235);
+            Console.WriteLine(" = " + dub);
 
-			Console.Write("testStruct({\"Zero\", 1, -3, -5})");
-			Xtruct o = new Xtruct();
-			o.String_thing = "Zero";
-			o.Byte_thing = (sbyte)1;
-			o.I32_thing = -3;
-			o.I64_thing = -5;
-			Xtruct i = client.testStruct(o);
-			Console.WriteLine(" = {\"" + i.String_thing + "\", " + i.Byte_thing + ", " + i.I32_thing + ", " + i.I64_thing + "}");
+            Console.Write("testStruct({\"Zero\", 1, -3, -5})");
+            Xtruct o = new Xtruct();
+            o.String_thing = "Zero";
+            o.Byte_thing = (sbyte)1;
+            o.I32_thing = -3;
+            o.I64_thing = -5;
+            Xtruct i = client.testStruct(o);
+            Console.WriteLine(" = {\"" + i.String_thing + "\", " + i.Byte_thing + ", " + i.I32_thing + ", " + i.I64_thing + "}");
 
-			Console.Write("testNest({1, {\"Zero\", 1, -3, -5}, 5})");
-			Xtruct2 o2 = new Xtruct2();
-			o2.Byte_thing = (sbyte)1;
-			o2.Struct_thing = o;
-			o2.I32_thing = 5;
-			Xtruct2 i2 = client.testNest(o2);
-			i = i2.Struct_thing;
-			Console.WriteLine(" = {" + i2.Byte_thing + ", {\"" + i.String_thing + "\", " + i.Byte_thing + ", " + i.I32_thing + ", " + i.I64_thing + "}, " + i2.I32_thing + "}");
+            Console.Write("testNest({1, {\"Zero\", 1, -3, -5}, 5})");
+            Xtruct2 o2 = new Xtruct2();
+            o2.Byte_thing = (sbyte)1;
+            o2.Struct_thing = o;
+            o2.I32_thing = 5;
+            Xtruct2 i2 = client.testNest(o2);
+            i = i2.Struct_thing;
+            Console.WriteLine(" = {" + i2.Byte_thing + ", {\"" + i.String_thing + "\", " + i.Byte_thing + ", " + i.I32_thing + ", " + i.I64_thing + "}, " + i2.I32_thing + "}");
 
-			Dictionary<int, int> mapout = new Dictionary<int, int>();
-			for (int j = 0; j < 5; j++)
-			{
-				mapout[j] = j - 10;
-			}
-			Console.Write("testMap({");
-			bool first = true;
-			foreach (int key in mapout.Keys)
-			{
-				if (first)
-				{
-					first = false;
-				}
-				else
-				{
-					Console.Write(", ");
-				}
-				Console.Write(key + " => " + mapout[key]);
-			}
-			Console.Write("})");
+            Dictionary<int, int> mapout = new Dictionary<int, int>();
+            for (int j = 0; j < 5; j++)
+            {
+                mapout[j] = j - 10;
+            }
+            Console.Write("testMap({");
+            bool first = true;
+            foreach (int key in mapout.Keys)
+            {
+                if (first)
+                {
+                    first = false;
+                }
+                else
+                {
+                    Console.Write(", ");
+                }
+                Console.Write(key + " => " + mapout[key]);
+            }
+            Console.Write("})");
 
-			Dictionary<int, int> mapin = client.testMap(mapout);
+            Dictionary<int, int> mapin = client.testMap(mapout);
 
-			Console.Write(" = {");
-			first = true;
-			foreach (int key in mapin.Keys)
-			{
-				if (first)
-				{
-					first = false;
-				}
-				else
-				{
-					Console.Write(", ");
-				}
-				Console.Write(key + " => " + mapin[key]);
-			}
-			Console.WriteLine("}");
+            Console.Write(" = {");
+            first = true;
+            foreach (int key in mapin.Keys)
+            {
+                if (first)
+                {
+                    first = false;
+                }
+                else
+                {
+                    Console.Write(", ");
+                }
+                Console.Write(key + " => " + mapin[key]);
+            }
+            Console.WriteLine("}");
 
-			List<int> listout = new List<int>();
-			for (int j = -2; j < 3; j++)
-			{
-				listout.Add(j);
-			}
-			Console.Write("testList({");
-			first = true;
-			foreach (int j in listout)
-			{
-				if (first)
-				{
-					first = false;
-				}
-				else
-				{
-					Console.Write(", ");
-				}
-				Console.Write(j);
-			}
-			Console.Write("})");
+            List<int> listout = new List<int>();
+            for (int j = -2; j < 3; j++)
+            {
+                listout.Add(j);
+            }
+            Console.Write("testList({");
+            first = true;
+            foreach (int j in listout)
+            {
+                if (first)
+                {
+                    first = false;
+                }
+                else
+                {
+                    Console.Write(", ");
+                }
+                Console.Write(j);
+            }
+            Console.Write("})");
 
-			List<int> listin = client.testList(listout);
+            List<int> listin = client.testList(listout);
 
-			Console.Write(" = {");
-			first = true;
-			foreach (int j in listin)
-			{
-				if (first)
-				{
-					first = false;
-				}
-				else
-				{
-					Console.Write(", ");
-				}
-				Console.Write(j);
-			}
-			Console.WriteLine("}");
+            Console.Write(" = {");
+            first = true;
+            foreach (int j in listin)
+            {
+                if (first)
+                {
+                    first = false;
+                }
+                else
+                {
+                    Console.Write(", ");
+                }
+                Console.Write(j);
+            }
+            Console.WriteLine("}");
 
-			//set
-			THashSet<int> setout = new THashSet<int>();
-			for (int j = -2; j < 3; j++)
-			{
-				setout.Add(j);
-			}
-			Console.Write("testSet({");
-			first = true;
-			foreach (int j in setout)
-			{
-				if (first)
-				{
-					first = false;
-				}
-				else
-				{
-					Console.Write(", ");
-				}
-				Console.Write(j);
-			}
-			Console.Write("})");
+            //set
+            THashSet<int> setout = new THashSet<int>();
+            for (int j = -2; j < 3; j++)
+            {
+                setout.Add(j);
+            }
+            Console.Write("testSet({");
+            first = true;
+            foreach (int j in setout)
+            {
+                if (first)
+                {
+                    first = false;
+                }
+                else
+                {
+                    Console.Write(", ");
+                }
+                Console.Write(j);
+            }
+            Console.Write("})");
 
-			THashSet<int> setin = client.testSet(setout);
+            THashSet<int> setin = client.testSet(setout);
 
-			Console.Write(" = {");
-			first = true;
-			foreach (int j in setin)
-			{
-				if (first)
-				{
-					first = false;
-				}
-				else
-				{
-					Console.Write(", ");
-				}
-				Console.Write(j);
-			}
-			Console.WriteLine("}");
+            Console.Write(" = {");
+            first = true;
+            foreach (int j in setin)
+            {
+                if (first)
+                {
+                    first = false;
+                }
+                else
+                {
+                    Console.Write(", ");
+                }
+                Console.Write(j);
+            }
+            Console.WriteLine("}");
 
 
-			Console.Write("testEnum(ONE)");
-			Numberz ret = client.testEnum(Numberz.ONE);
-			Console.WriteLine(" = " + ret);
+            Console.Write("testEnum(ONE)");
+            Numberz ret = client.testEnum(Numberz.ONE);
+            Console.WriteLine(" = " + ret);
 
-			Console.Write("testEnum(TWO)");
-			ret = client.testEnum(Numberz.TWO);
-			Console.WriteLine(" = " + ret);
+            Console.Write("testEnum(TWO)");
+            ret = client.testEnum(Numberz.TWO);
+            Console.WriteLine(" = " + ret);
 
-			Console.Write("testEnum(THREE)");
-			ret = client.testEnum(Numberz.THREE);
-			Console.WriteLine(" = " + ret);
+            Console.Write("testEnum(THREE)");
+            ret = client.testEnum(Numberz.THREE);
+            Console.WriteLine(" = " + ret);
 
-			Console.Write("testEnum(FIVE)");
-			ret = client.testEnum(Numberz.FIVE);
-			Console.WriteLine(" = " + ret);
+            Console.Write("testEnum(FIVE)");
+            ret = client.testEnum(Numberz.FIVE);
+            Console.WriteLine(" = " + ret);
 
-			Console.Write("testEnum(EIGHT)");
-			ret = client.testEnum(Numberz.EIGHT);
-			Console.WriteLine(" = " + ret);
+            Console.Write("testEnum(EIGHT)");
+            ret = client.testEnum(Numberz.EIGHT);
+            Console.WriteLine(" = " + ret);
 
-			Console.Write("testTypedef(309858235082523)");
-			long uid = client.testTypedef(309858235082523L);
-			Console.WriteLine(" = " + uid);
+            Console.Write("testTypedef(309858235082523)");
+            long uid = client.testTypedef(309858235082523L);
+            Console.WriteLine(" = " + uid);
 
-			Console.Write("testMapMap(1)");
-			Dictionary<int, Dictionary<int, int>> mm = client.testMapMap(1);
-			Console.Write(" = {");
-			foreach (int key in mm.Keys)
-			{
-				Console.Write(key + " => {");
-				Dictionary<int, int> m2 = mm[key];
-				foreach (int k2 in m2.Keys)
-				{
-					Console.Write(k2 + " => " + m2[k2] + ", ");
-				}
-				Console.Write("}, ");
-			}
-			Console.WriteLine("}");
+            Console.Write("testMapMap(1)");
+            Dictionary<int, Dictionary<int, int>> mm = client.testMapMap(1);
+            Console.Write(" = {");
+            foreach (int key in mm.Keys)
+            {
+                Console.Write(key + " => {");
+                Dictionary<int, int> m2 = mm[key];
+                foreach (int k2 in m2.Keys)
+                {
+                    Console.Write(k2 + " => " + m2[k2] + ", ");
+                }
+                Console.Write("}, ");
+            }
+            Console.WriteLine("}");
 
-			Insanity insane = new Insanity();
-			insane.UserMap = new Dictionary<Numberz, long>();
-			insane.UserMap[Numberz.FIVE] = 5000L;
-			Xtruct truck = new Xtruct();
-			truck.String_thing = "Truck";
-			truck.Byte_thing = (sbyte)8;
-			truck.I32_thing = 8;
-			truck.I64_thing = 8;
-			insane.Xtructs = new List<Xtruct>();
-			insane.Xtructs.Add(truck);
-			Console.Write("testInsanity()");
-			Dictionary<long, Dictionary<Numberz, Insanity>> whoa = client.testInsanity(insane);
-			Console.Write(" = {");
-			foreach (long key in whoa.Keys)
-			{
-				Dictionary<Numberz, Insanity> val = whoa[key];
-				Console.Write(key + " => {");
+            Insanity insane = new Insanity();
+            insane.UserMap = new Dictionary<Numberz, long>();
+            insane.UserMap[Numberz.FIVE] = 5000L;
+            Xtruct truck = new Xtruct();
+            truck.String_thing = "Truck";
+            truck.Byte_thing = (sbyte)8;
+            truck.I32_thing = 8;
+            truck.I64_thing = 8;
+            insane.Xtructs = new List<Xtruct>();
+            insane.Xtructs.Add(truck);
+            Console.Write("testInsanity()");
+            Dictionary<long, Dictionary<Numberz, Insanity>> whoa = client.testInsanity(insane);
+            Console.Write(" = {");
+            foreach (long key in whoa.Keys)
+            {
+                Dictionary<Numberz, Insanity> val = whoa[key];
+                Console.Write(key + " => {");
 
-				foreach (Numberz k2 in val.Keys)
-				{
-					Insanity v2 = val[k2];
+                foreach (Numberz k2 in val.Keys)
+                {
+                    Insanity v2 = val[k2];
 
-					Console.Write(k2 + " => {");
-					Dictionary<Numberz, long> userMap = v2.UserMap;
+                    Console.Write(k2 + " => {");
+                    Dictionary<Numberz, long> userMap = v2.UserMap;
 
-					Console.Write("{");
-					if (userMap != null)
-					{
-						foreach (Numberz k3 in userMap.Keys)
-						{
-							Console.Write(k3 + " => " + userMap[k3] + ", ");
-						}
-					}
-					else
-					{
-						Console.Write("null");
-					}
-					Console.Write("}, ");
+                    Console.Write("{");
+                    if (userMap != null)
+                    {
+                        foreach (Numberz k3 in userMap.Keys)
+                        {
+                            Console.Write(k3 + " => " + userMap[k3] + ", ");
+                        }
+                    }
+                    else
+                    {
+                        Console.Write("null");
+                    }
+                    Console.Write("}, ");
 
-					List<Xtruct> xtructs = v2.Xtructs;
+                    List<Xtruct> xtructs = v2.Xtructs;
 
-					Console.Write("{");
-					if (xtructs != null)
-					{
-						foreach (Xtruct x in xtructs)
-						{
-							Console.Write("{\"" + x.String_thing + "\", " + x.Byte_thing + ", " + x.I32_thing + ", " + x.I32_thing + "}, ");
-						}
-					}
-					else
-					{
-						Console.Write("null");
-					}
-					Console.Write("}");
+                    Console.Write("{");
+                    if (xtructs != null)
+                    {
+                        foreach (Xtruct x in xtructs)
+                        {
+                            Console.Write("{\"" + x.String_thing + "\", " + x.Byte_thing + ", " + x.I32_thing + ", " + x.I32_thing + "}, ");
+                        }
+                    }
+                    else
+                    {
+                        Console.Write("null");
+                    }
+                    Console.Write("}");
 
-					Console.Write("}, ");
-				}
-				Console.Write("}, ");
-			}
-			Console.WriteLine("}");
+                    Console.Write("}, ");
+                }
+                Console.Write("}, ");
+            }
+            Console.WriteLine("}");
 
-			sbyte arg0 = 1;
-			int arg1 = 2;
-			long arg2 = long.MaxValue;
-			Dictionary<short, string> multiDict = new Dictionary<short, string>();
-			multiDict[1] = "one";
-			Numberz arg4 = Numberz.FIVE;
-			long arg5 = 5000000;
-			Console.Write("Test Multi(" + arg0 + "," + arg1 + "," + arg2 + "," + multiDict + "," + arg4 + "," + arg5 + ")");
-			Xtruct multiResponse = client.testMulti(arg0, arg1, arg2, multiDict, arg4, arg5);
-			Console.Write(" = Xtruct(byte_thing:" + multiResponse.Byte_thing + ",String_thing:" + multiResponse.String_thing
-						+ ",i32_thing:" + multiResponse.I32_thing + ",i64_thing:" + multiResponse.I64_thing + ")\n");
+            sbyte arg0 = 1;
+            int arg1 = 2;
+            long arg2 = long.MaxValue;
+            Dictionary<short, string> multiDict = new Dictionary<short, string>();
+            multiDict[1] = "one";
+            Numberz arg4 = Numberz.FIVE;
+            long arg5 = 5000000;
+            Console.Write("Test Multi(" + arg0 + "," + arg1 + "," + arg2 + "," + multiDict + "," + arg4 + "," + arg5 + ")");
+            Xtruct multiResponse = client.testMulti(arg0, arg1, arg2, multiDict, arg4, arg5);
+            Console.Write(" = Xtruct(byte_thing:" + multiResponse.Byte_thing + ",String_thing:" + multiResponse.String_thing
+                        + ",i32_thing:" + multiResponse.I32_thing + ",i64_thing:" + multiResponse.I64_thing + ")\n");
 
-			Console.WriteLine("Test Oneway(1)");
-			client.testOneway(1);
+            Console.WriteLine("Test Oneway(1)");
+            client.testOneway(1);
 
-			Console.Write("Test Calltime()");
-			var startt = DateTime.UtcNow;
-			for ( int k=0; k<1000; ++k )
-				client.testVoid();
-			Console.WriteLine(" = " + (DateTime.UtcNow - startt).TotalSeconds.ToString() + " ms a testVoid() call" );
-		}
-	}
+            Console.Write("Test Calltime()");
+            var startt = DateTime.UtcNow;
+            for ( int k=0; k<1000; ++k )
+                client.testVoid();
+            Console.WriteLine(" = " + (DateTime.UtcNow - startt).TotalSeconds.ToString() + " ms a testVoid() call" );
+        }
+    }
 }
diff --git a/lib/csharp/test/ThriftTest/TestServer.cs b/lib/csharp/test/ThriftTest/TestServer.cs
index 92ef374..d944e72 100644
--- a/lib/csharp/test/ThriftTest/TestServer.cs
+++ b/lib/csharp/test/ThriftTest/TestServer.cs
@@ -32,8 +32,8 @@
 
 namespace Test
 {
-	public class TestServer
-	{
+    public class TestServer
+    {
     public class TradeServerEventHandler : TServerEventHandler
     {
       public int callCount = 0;
@@ -56,395 +56,395 @@
       }
     };
 
-		public class TestHandler : ThriftTest.Iface
-		{
-			public TServer server;
+        public class TestHandler : ThriftTest.Iface
+        {
+            public TServer server;
 
-			public TestHandler() { }
+            public TestHandler() { }
 
-			public void testVoid()
-			{
-				Console.WriteLine("testVoid()");
-			}
+            public void testVoid()
+            {
+                Console.WriteLine("testVoid()");
+            }
 
-			public string testString(string thing)
-			{
-				Console.WriteLine("teststring(\"" + thing + "\")");
-				return thing;
-			}
+            public string testString(string thing)
+            {
+                Console.WriteLine("teststring(\"" + thing + "\")");
+                return thing;
+            }
 
-			public sbyte testByte(sbyte thing)
-			{
-				Console.WriteLine("testByte(" + thing + ")");
-				return thing;
-			}
+            public sbyte testByte(sbyte thing)
+            {
+                Console.WriteLine("testByte(" + thing + ")");
+                return thing;
+            }
 
-			public int testI32(int thing)
-			{
-				Console.WriteLine("testI32(" + thing + ")");
-				return thing;
-			}
+            public int testI32(int thing)
+            {
+                Console.WriteLine("testI32(" + thing + ")");
+                return thing;
+            }
 
-			public long testI64(long thing)
-			{
-				Console.WriteLine("testI64(" + thing + ")");
-				return thing;
-			}
+            public long testI64(long thing)
+            {
+                Console.WriteLine("testI64(" + thing + ")");
+                return thing;
+            }
 
-			public double testDouble(double thing)
-			{
-				Console.WriteLine("testDouble(" + thing + ")");
-				return thing;
-			}
+            public double testDouble(double thing)
+            {
+                Console.WriteLine("testDouble(" + thing + ")");
+                return thing;
+            }
 
-			public Xtruct testStruct(Xtruct thing)
-			{
-				Console.WriteLine("testStruct({" +
-								 "\"" + thing.String_thing + "\", " +
-								 thing.Byte_thing + ", " +
-								 thing.I32_thing + ", " +
-								 thing.I64_thing + "})");
-				return thing;
-			}
+            public Xtruct testStruct(Xtruct thing)
+            {
+                Console.WriteLine("testStruct({" +
+                                 "\"" + thing.String_thing + "\", " +
+                                 thing.Byte_thing + ", " +
+                                 thing.I32_thing + ", " +
+                                 thing.I64_thing + "})");
+                return thing;
+            }
 
-			public Xtruct2 testNest(Xtruct2 nest)
-			{
-				Xtruct thing = nest.Struct_thing;
-				Console.WriteLine("testNest({" +
-								 nest.Byte_thing + ", {" +
-								 "\"" + thing.String_thing + "\", " +
-								 thing.Byte_thing + ", " +
-								 thing.I32_thing + ", " +
-								 thing.I64_thing + "}, " +
-								 nest.I32_thing + "})");
-				return nest;
-			}
+            public Xtruct2 testNest(Xtruct2 nest)
+            {
+                Xtruct thing = nest.Struct_thing;
+                Console.WriteLine("testNest({" +
+                                 nest.Byte_thing + ", {" +
+                                 "\"" + thing.String_thing + "\", " +
+                                 thing.Byte_thing + ", " +
+                                 thing.I32_thing + ", " +
+                                 thing.I64_thing + "}, " +
+                                 nest.I32_thing + "})");
+                return nest;
+            }
 
-			public Dictionary<int, int> testMap(Dictionary<int, int> thing)
-			{
-				Console.WriteLine("testMap({");
-				bool first = true;
-				foreach (int key in thing.Keys)
-				{
-					if (first)
-					{
-						first = false;
-					}
-					else
-					{
-						Console.WriteLine(", ");
-					}
-					Console.WriteLine(key + " => " + thing[key]);
-				}
-				Console.WriteLine("})");
-				return thing;
-			}
+            public Dictionary<int, int> testMap(Dictionary<int, int> thing)
+            {
+                Console.WriteLine("testMap({");
+                bool first = true;
+                foreach (int key in thing.Keys)
+                {
+                    if (first)
+                    {
+                        first = false;
+                    }
+                    else
+                    {
+                        Console.WriteLine(", ");
+                    }
+                    Console.WriteLine(key + " => " + thing[key]);
+                }
+                Console.WriteLine("})");
+                return thing;
+            }
 
-			public Dictionary<string, string> testStringMap(Dictionary<string, string> thing)
-			{
-				Console.WriteLine("testStringMap({");
-				bool first = true;
-				foreach (string key in thing.Keys)
-				{
-					if (first)
-					{
-						first = false;
-					}
-					else
-					{
-						Console.WriteLine(", ");
-					}
-					Console.WriteLine(key + " => " + thing[key]);
-				}
-				Console.WriteLine("})");
-				return thing;
-			}
+            public Dictionary<string, string> testStringMap(Dictionary<string, string> thing)
+            {
+                Console.WriteLine("testStringMap({");
+                bool first = true;
+                foreach (string key in thing.Keys)
+                {
+                    if (first)
+                    {
+                        first = false;
+                    }
+                    else
+                    {
+                        Console.WriteLine(", ");
+                    }
+                    Console.WriteLine(key + " => " + thing[key]);
+                }
+                Console.WriteLine("})");
+                return thing;
+            }
 
-			public THashSet<int> testSet(THashSet<int> thing)
-			{
-				Console.WriteLine("testSet({");
-				bool first = true;
-				foreach (int elem in thing)
-				{
-					if (first)
-					{
-						first = false;
-					}
-					else
-					{
-						Console.WriteLine(", ");
-					}
-					Console.WriteLine(elem);
-				}
-				Console.WriteLine("})");
-				return thing;
-			}
+            public THashSet<int> testSet(THashSet<int> thing)
+            {
+                Console.WriteLine("testSet({");
+                bool first = true;
+                foreach (int elem in thing)
+                {
+                    if (first)
+                    {
+                        first = false;
+                    }
+                    else
+                    {
+                        Console.WriteLine(", ");
+                    }
+                    Console.WriteLine(elem);
+                }
+                Console.WriteLine("})");
+                return thing;
+            }
 
-			public List<int> testList(List<int> thing)
-			{
-				Console.WriteLine("testList({");
-				bool first = true;
-				foreach (int elem in thing)
-				{
-					if (first)
-					{
-						first = false;
-					}
-					else
-					{
-						Console.WriteLine(", ");
-					}
-					Console.WriteLine(elem);
-				}
-				Console.WriteLine("})");
-				return thing;
-			}
+            public List<int> testList(List<int> thing)
+            {
+                Console.WriteLine("testList({");
+                bool first = true;
+                foreach (int elem in thing)
+                {
+                    if (first)
+                    {
+                        first = false;
+                    }
+                    else
+                    {
+                        Console.WriteLine(", ");
+                    }
+                    Console.WriteLine(elem);
+                }
+                Console.WriteLine("})");
+                return thing;
+            }
 
-			public Numberz testEnum(Numberz thing)
-			{
-				Console.WriteLine("testEnum(" + thing + ")");
-				return thing;
-			}
+            public Numberz testEnum(Numberz thing)
+            {
+                Console.WriteLine("testEnum(" + thing + ")");
+                return thing;
+            }
 
-			public long testTypedef(long thing)
-			{
-				Console.WriteLine("testTypedef(" + thing + ")");
-				return thing;
-			}
+            public long testTypedef(long thing)
+            {
+                Console.WriteLine("testTypedef(" + thing + ")");
+                return thing;
+            }
 
-			public Dictionary<int, Dictionary<int, int>> testMapMap(int hello)
-			{
-				Console.WriteLine("testMapMap(" + hello + ")");
-				Dictionary<int, Dictionary<int, int>> mapmap =
-				  new Dictionary<int, Dictionary<int, int>>();
+            public Dictionary<int, Dictionary<int, int>> testMapMap(int hello)
+            {
+                Console.WriteLine("testMapMap(" + hello + ")");
+                Dictionary<int, Dictionary<int, int>> mapmap =
+                  new Dictionary<int, Dictionary<int, int>>();
 
-				Dictionary<int, int> pos = new Dictionary<int, int>();
-				Dictionary<int, int> neg = new Dictionary<int, int>();
-				for (int i = 1; i < 5; i++)
-				{
-					pos[i] = i;
-					neg[-i] = -i;
-				}
+                Dictionary<int, int> pos = new Dictionary<int, int>();
+                Dictionary<int, int> neg = new Dictionary<int, int>();
+                for (int i = 1; i < 5; i++)
+                {
+                    pos[i] = i;
+                    neg[-i] = -i;
+                }
 
-				mapmap[4] = pos;
-				mapmap[-4] = neg;
+                mapmap[4] = pos;
+                mapmap[-4] = neg;
 
-				return mapmap;
-			}
+                return mapmap;
+            }
 
-			public Dictionary<long, Dictionary<Numberz, Insanity>> testInsanity(Insanity argument)
-			{
-				Console.WriteLine("testInsanity()");
+            public Dictionary<long, Dictionary<Numberz, Insanity>> testInsanity(Insanity argument)
+            {
+                Console.WriteLine("testInsanity()");
 
-				Xtruct hello = new Xtruct();
-				hello.String_thing = "Hello2";
-				hello.Byte_thing = 2;
-				hello.I32_thing = 2;
-				hello.I64_thing = 2;
+                Xtruct hello = new Xtruct();
+                hello.String_thing = "Hello2";
+                hello.Byte_thing = 2;
+                hello.I32_thing = 2;
+                hello.I64_thing = 2;
 
-				Xtruct goodbye = new Xtruct();
-				goodbye.String_thing = "Goodbye4";
-				goodbye.Byte_thing = (sbyte)4;
-				goodbye.I32_thing = 4;
-				goodbye.I64_thing = (long)4;
+                Xtruct goodbye = new Xtruct();
+                goodbye.String_thing = "Goodbye4";
+                goodbye.Byte_thing = (sbyte)4;
+                goodbye.I32_thing = 4;
+                goodbye.I64_thing = (long)4;
 
-				Insanity crazy = new Insanity();
-				crazy.UserMap = new Dictionary<Numberz, long>();
-				crazy.UserMap[Numberz.EIGHT] = (long)8;
-				crazy.Xtructs = new List<Xtruct>();
-				crazy.Xtructs.Add(goodbye);
+                Insanity crazy = new Insanity();
+                crazy.UserMap = new Dictionary<Numberz, long>();
+                crazy.UserMap[Numberz.EIGHT] = (long)8;
+                crazy.Xtructs = new List<Xtruct>();
+                crazy.Xtructs.Add(goodbye);
 
-				Insanity looney = new Insanity();
-				crazy.UserMap[Numberz.FIVE] = (long)5;
-				crazy.Xtructs.Add(hello);
+                Insanity looney = new Insanity();
+                crazy.UserMap[Numberz.FIVE] = (long)5;
+                crazy.Xtructs.Add(hello);
 
-				Dictionary<Numberz, Insanity> first_map = new Dictionary<Numberz, Insanity>();
-				Dictionary<Numberz, Insanity> second_map = new Dictionary<Numberz, Insanity>(); ;
+                Dictionary<Numberz, Insanity> first_map = new Dictionary<Numberz, Insanity>();
+                Dictionary<Numberz, Insanity> second_map = new Dictionary<Numberz, Insanity>(); ;
 
-				first_map[Numberz.TWO] = crazy;
-				first_map[Numberz.THREE] = crazy;
+                first_map[Numberz.TWO] = crazy;
+                first_map[Numberz.THREE] = crazy;
 
-				second_map[Numberz.SIX] = looney;
+                second_map[Numberz.SIX] = looney;
 
-				Dictionary<long, Dictionary<Numberz, Insanity>> insane =
-				  new Dictionary<long, Dictionary<Numberz, Insanity>>();
-				insane[(long)1] = first_map;
-				insane[(long)2] = second_map;
+                Dictionary<long, Dictionary<Numberz, Insanity>> insane =
+                  new Dictionary<long, Dictionary<Numberz, Insanity>>();
+                insane[(long)1] = first_map;
+                insane[(long)2] = second_map;
 
-				return insane;
-			}
+                return insane;
+            }
 
-			public Xtruct testMulti(sbyte arg0, int arg1, long arg2, Dictionary<short, string> arg3, Numberz arg4, long arg5)
-			{
-				Console.WriteLine("testMulti()");
+            public Xtruct testMulti(sbyte arg0, int arg1, long arg2, Dictionary<short, string> arg3, Numberz arg4, long arg5)
+            {
+                Console.WriteLine("testMulti()");
 
-				Xtruct hello = new Xtruct(); ;
-				hello.String_thing = "Hello2";
-				hello.Byte_thing = arg0;
-				hello.I32_thing = arg1;
-				hello.I64_thing = arg2;
-				return hello;
-			}
+                Xtruct hello = new Xtruct(); ;
+                hello.String_thing = "Hello2";
+                hello.Byte_thing = arg0;
+                hello.I32_thing = arg1;
+                hello.I64_thing = arg2;
+                return hello;
+            }
 
-			public void testException(string arg)
-			{
-				Console.WriteLine("testException(" + arg + ")");
-				if (arg == "Xception")
-				{
-					Xception x = new Xception();
-					x.ErrorCode = 1001;
-					x.Message = "This is an Xception";
-					throw x;
-				}
-				return;
-			}
+            public void testException(string arg)
+            {
+                Console.WriteLine("testException(" + arg + ")");
+                if (arg == "Xception")
+                {
+                    Xception x = new Xception();
+                    x.ErrorCode = 1001;
+                    x.Message = "This is an Xception";
+                    throw x;
+                }
+                return;
+            }
 
-			public Xtruct testMultiException(string arg0, string arg1)
-			{
-				Console.WriteLine("testMultiException(" + arg0 + ", " + arg1 + ")");
-				if (arg0 == "Xception")
-				{
-					Xception x = new Xception();
-					x.ErrorCode = 1001;
-					x.Message = "This is an Xception";
-					throw x;
-				}
-				else if (arg0 == "Xception2")
-				{
-					Xception2 x = new Xception2();
-					x.ErrorCode = 2002;
-					x.Struct_thing = new Xtruct();
-					x.Struct_thing.String_thing = "This is an Xception2";
-					throw x;
-				}
+            public Xtruct testMultiException(string arg0, string arg1)
+            {
+                Console.WriteLine("testMultiException(" + arg0 + ", " + arg1 + ")");
+                if (arg0 == "Xception")
+                {
+                    Xception x = new Xception();
+                    x.ErrorCode = 1001;
+                    x.Message = "This is an Xception";
+                    throw x;
+                }
+                else if (arg0 == "Xception2")
+                {
+                    Xception2 x = new Xception2();
+                    x.ErrorCode = 2002;
+                    x.Struct_thing = new Xtruct();
+                    x.Struct_thing.String_thing = "This is an Xception2";
+                    throw x;
+                }
 
-				Xtruct result = new Xtruct();
-				result.String_thing = arg1;
-				return result;
-			}
+                Xtruct result = new Xtruct();
+                result.String_thing = arg1;
+                return result;
+            }
 
-			public void testStop()
-			{
-				if (server != null)
-				{
-					server.Stop();
-				}
-			}
+            public void testStop()
+            {
+                if (server != null)
+                {
+                    server.Stop();
+                }
+            }
 
-			public void testOneway(int arg)
-			{
-				Console.WriteLine("testOneway(" + arg + "), sleeping...");
-				System.Threading.Thread.Sleep(arg * 1000);
-				Console.WriteLine("testOneway finished");
-			}
+            public void testOneway(int arg)
+            {
+                Console.WriteLine("testOneway(" + arg + "), sleeping...");
+                System.Threading.Thread.Sleep(arg * 1000);
+                Console.WriteLine("testOneway finished");
+            }
 
-		} // class TestHandler
+        } // class TestHandler
 
-		public static void Execute(string[] args)
-		{
-			try
-			{
-				bool useBufferedSockets = false, useFramed = false, useEncryption = false, compact = false, json = false;
-				int port = 9090;
-				string pipe = null;
-				for (int i = 0; i < args.Length; i++)
-				{
-					if (args[i] == "-pipe")  // -pipe name
-					{
-						pipe = args[++i];
-					}
-					else if (args[i].Contains("--port="))
-					{
-						port = int.Parse(args[i].Substring(args[i].IndexOf("=")+1));
-					}
-					else if (args[i] == "-b" || args[i] == "--buffered" || args[i] == "--transport=buffered")
-					{
-						useBufferedSockets = true;
-					}
-					else if (args[i] == "-f" || args[i] == "--framed"  || args[i] == "--transport=framed")
-					{
-						useFramed = true;
-					}
-					else if (args[i] == "--compact" || args[i] == "--protocol=compact")
-					{
-						compact = true;
-					}
-					else if (args[i] == "--json" || args[i] == "--protocol=json")
-					{
-						json = true;
-					}
-					else if (args[i] == "--ssl")
-					{
-						useEncryption = true;
-					}
-				}
+        public static void Execute(string[] args)
+        {
+            try
+            {
+                bool useBufferedSockets = false, useFramed = false, useEncryption = false, compact = false, json = false;
+                int port = 9090;
+                string pipe = null;
+                for (int i = 0; i < args.Length; i++)
+                {
+                    if (args[i] == "-pipe")  // -pipe name
+                    {
+                        pipe = args[++i];
+                    }
+                    else if (args[i].Contains("--port="))
+                    {
+                        port = int.Parse(args[i].Substring(args[i].IndexOf("=")+1));
+                    }
+                    else if (args[i] == "-b" || args[i] == "--buffered" || args[i] == "--transport=buffered")
+                    {
+                        useBufferedSockets = true;
+                    }
+                    else if (args[i] == "-f" || args[i] == "--framed"  || args[i] == "--transport=framed")
+                    {
+                        useFramed = true;
+                    }
+                    else if (args[i] == "--compact" || args[i] == "--protocol=compact")
+                    {
+                        compact = true;
+                    }
+                    else if (args[i] == "--json" || args[i] == "--protocol=json")
+                    {
+                        json = true;
+                    }
+                    else if (args[i] == "--ssl")
+                    {
+                        useEncryption = true;
+                    }
+                }
 
-				// Processor
-				TestHandler testHandler = new TestHandler();
-				ThriftTest.Processor testProcessor = new ThriftTest.Processor(testHandler);
+                // Processor
+                TestHandler testHandler = new TestHandler();
+                ThriftTest.Processor testProcessor = new ThriftTest.Processor(testHandler);
 
-				// Transport
-				TServerTransport trans;
-				if( pipe != null)
-				{
-					trans = new TNamedPipeServerTransport(pipe);
-				}
-				else
-				{
-					if (useEncryption)
-					{
-						trans = new TTLSServerSocket(port, 0, useBufferedSockets, new X509Certificate2("../../../../../keys/server.pem"));
-					}
-					else
-					{
-						trans = new TServerSocket(port, 0, useBufferedSockets);
-					}
-				}
+                // Transport
+                TServerTransport trans;
+                if( pipe != null)
+                {
+                    trans = new TNamedPipeServerTransport(pipe);
+                }
+                else
+                {
+                    if (useEncryption)
+                    {
+                        trans = new TTLSServerSocket(port, 0, useBufferedSockets, new X509Certificate2("../../../../../keys/server.pem"));
+                    }
+                    else
+                    {
+                        trans = new TServerSocket(port, 0, useBufferedSockets);
+                    }
+                }
 
-				TProtocolFactory proto;
-				if ( compact )
-					proto = new TCompactProtocol.Factory();
-				else if ( json )
-					proto = new TJSONProtocol.Factory();
-				else
-					proto = new TBinaryProtocol.Factory();
-					
-				// Simple Server
-				TServer serverEngine;
-				if ( useFramed )
-					serverEngine = new TSimpleServer(testProcessor, trans, new TFramedTransport.Factory(), proto);
-				else
-					serverEngine = new TSimpleServer(testProcessor, trans, new TTransportFactory(), proto);
+                TProtocolFactory proto;
+                if ( compact )
+                    proto = new TCompactProtocol.Factory();
+                else if ( json )
+                    proto = new TJSONProtocol.Factory();
+                else
+                    proto = new TBinaryProtocol.Factory();
 
-				// ThreadPool Server
-				// serverEngine = new TThreadPoolServer(testProcessor, tServerSocket);
+                // Simple Server
+                TServer serverEngine;
+                if ( useFramed )
+                    serverEngine = new TSimpleServer(testProcessor, trans, new TFramedTransport.Factory(), proto);
+                else
+                    serverEngine = new TSimpleServer(testProcessor, trans, new TTransportFactory(), proto);
 
-				// Threaded Server
-				// serverEngine = new TThreadedServer(testProcessor, tServerSocket);
+                // ThreadPool Server
+                // serverEngine = new TThreadPoolServer(testProcessor, tServerSocket);
+
+                // Threaded Server
+                // serverEngine = new TThreadedServer(testProcessor, tServerSocket);
 
         //Server event handler
         TradeServerEventHandler serverEvents = new TradeServerEventHandler();
         serverEngine.setEventHandler(serverEvents);
 
-				testHandler.server = serverEngine;
+                testHandler.server = serverEngine;
 
-				// Run it
-				string where = ( pipe != null ? "on pipe "+pipe : "on port " + port);
-				Console.WriteLine("Starting the server " + where +
-					(useBufferedSockets ? " with buffered socket" : "") +
-					(useFramed ? " with framed transport" : "") +
-					(useEncryption ? " with encryption" : "") +
-					(compact ? " with compact protocol" : "") +
-					(json ? " with json protocol" : "") +
-					"...");
-				serverEngine.Serve();
+                // Run it
+                string where = ( pipe != null ? "on pipe "+pipe : "on port " + port);
+                Console.WriteLine("Starting the server " + where +
+                    (useBufferedSockets ? " with buffered socket" : "") +
+                    (useFramed ? " with framed transport" : "") +
+                    (useEncryption ? " with encryption" : "") +
+                    (compact ? " with compact protocol" : "") +
+                    (json ? " with json protocol" : "") +
+                    "...");
+                serverEngine.Serve();
 
-			}
-			catch (Exception x)
-			{
-				Console.Error.Write(x);
-			}
-			Console.WriteLine("done.");
-		}
-	}
+            }
+            catch (Exception x)
+            {
+                Console.Error.Write(x);
+            }
+            Console.WriteLine("done.");
+        }
+    }
 }
diff --git a/lib/delphi/src/Thrift.Collections.pas b/lib/delphi/src/Thrift.Collections.pas
index 3a0274c..b2206cb 100644
--- a/lib/delphi/src/Thrift.Collections.pas
+++ b/lib/delphi/src/Thrift.Collections.pas
@@ -1,619 +1,619 @@
-(*

- * Licensed to the Apache Software Foundation (ASF) under one

- * or more contributor license agreements. See the NOTICE file

- * distributed with this work for additional information

- * regarding copyright ownership. The ASF licenses this file

- * to you under the Apache License, Version 2.0 (the

- * "License"); you may not use this file except in compliance

- * with the License. You may obtain a copy of the License at

- *

- *   http://www.apache.org/licenses/LICENSE-2.0

- *

- * Unless required by applicable law or agreed to in writing,

- * software distributed under the License is distributed on an

- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

- * KIND, either express or implied. See the License for the

- * specific language governing permissions and limitations

- * under the License.

- *)

-

-unit Thrift.Collections;

-

-interface

-

-uses

-  Generics.Collections, Generics.Defaults, Thrift.Utils;

-

-type

-

-{$IF CompilerVersion < 21.0}

-  TArray<T> = array of T;

-{$IFEND}

-

-  IThriftContainer = interface

-    ['{93DEF5A0-D162-461A-AB22-5B4EE0734050}']

-    function ToString: string;

-  end;

-

-  IThriftDictionary<TKey,TValue> = interface(IThriftContainer)

-    ['{25EDD506-F9D1-4008-A40F-5940364B7E46}']

-    function GetEnumerator: TEnumerator<TPair<TKey,TValue>>;

-

-    function GetKeys: TDictionary<TKey,TValue>.TKeyCollection;

-    function GetValues: TDictionary<TKey,TValue>.TValueCollection;

-    function GetItem(const Key: TKey): TValue;

-    procedure SetItem(const Key: TKey; const Value: TValue);

-    function GetCount: Integer;

-

-    procedure Add(const Key: TKey; const Value: TValue);

-    procedure Remove(const Key: TKey);

-{$IF CompilerVersion >= 21.0}

-    function ExtractPair(const Key: TKey): TPair<TKey,TValue>;

-{$IFEND}

-    procedure Clear;

-    procedure TrimExcess;

-    function TryGetValue(const Key: TKey; out Value: TValue): Boolean;

-    procedure AddOrSetValue(const Key: TKey; const Value: TValue);

-    function ContainsKey(const Key: TKey): Boolean;

-    function ContainsValue(const Value: TValue): Boolean;

-    function ToArray: TArray<TPair<TKey,TValue>>;

-

-    property Items[const Key: TKey]: TValue read GetItem write SetItem; default;

-    property Count: Integer read GetCount;

-    property Keys: TDictionary<TKey,TValue>.TKeyCollection read GetKeys;

-    property Values: TDictionary<TKey,TValue>.TValueCollection read GetValues;

-  end;

-

-  TThriftDictionaryImpl<TKey,TValue> = class( TInterfacedObject, IThriftDictionary<TKey,TValue>)

-  private

-    FDictionaly : TDictionary<TKey,TValue>;

-  protected

-    function GetEnumerator: TEnumerator<TPair<TKey,TValue>>;

-

-    function GetKeys: TDictionary<TKey,TValue>.TKeyCollection;

-    function GetValues: TDictionary<TKey,TValue>.TValueCollection;

-    function GetItem(const Key: TKey): TValue;

-    procedure SetItem(const Key: TKey; const Value: TValue);

-    function GetCount: Integer;

-

-    procedure Add(const Key: TKey; const Value: TValue);

-    procedure Remove(const Key: TKey);

-{$IF CompilerVersion >= 21.0}

-    function ExtractPair(const Key: TKey): TPair<TKey,TValue>;

-{$IFEND}

-    procedure Clear;

-    procedure TrimExcess;

-    function TryGetValue(const Key: TKey; out Value: TValue): Boolean;

-    procedure AddOrSetValue(const Key: TKey; const Value: TValue);

-    function ContainsKey(const Key: TKey): Boolean;

-    function ContainsValue(const Value: TValue): Boolean;

-    function ToArray: TArray<TPair<TKey,TValue>>;

-    property Items[const Key: TKey]: TValue read GetItem write SetItem; default;

-    property Count: Integer read GetCount;

-    property Keys: TDictionary<TKey,TValue>.TKeyCollection read GetKeys;

-    property Values: TDictionary<TKey,TValue>.TValueCollection read GetValues;

-  public

-    constructor Create(ACapacity: Integer = 0);

-    destructor Destroy; override;

-  end;

-

-  IThriftList<T> = interface(IThriftContainer)

-    ['{29BEEE31-9CB4-401B-AA04-5148A75F473B}']

-    function GetEnumerator: TEnumerator<T>;

-    function GetCapacity: Integer;

-    procedure SetCapacity(Value: Integer);

-    function GetCount: Integer;

-    procedure SetCount(Value: Integer);

-    function GetItem(Index: Integer): T;

-    procedure SetItem(Index: Integer; const Value: T);

-    function Add(const Value: T): Integer;

-    procedure AddRange(const Values: array of T); overload;

-    procedure AddRange(const Collection: IEnumerable<T>); overload;

-    procedure AddRange(Collection: TEnumerable<T>); overload;

-    procedure Insert(Index: Integer; const Value: T);

-    procedure InsertRange(Index: Integer; const Values: array of T); overload;

-    procedure InsertRange(Index: Integer; const Collection: IEnumerable<T>); overload;

-    procedure InsertRange(Index: Integer; const Collection: TEnumerable<T>); overload;

-    function Remove(const Value: T): Integer;

-    procedure Delete(Index: Integer);

-    procedure DeleteRange(AIndex, ACount: Integer);

-    function Extract(const Value: T): T;

-{$IF CompilerVersion >= 21.0}

-    procedure Exchange(Index1, Index2: Integer);

-    procedure Move(CurIndex, NewIndex: Integer);

-    function First: T;

-    function Last: T;

-{$IFEND}

-    procedure Clear;

-    function Contains(const Value: T): Boolean;

-    function IndexOf(const Value: T): Integer;

-    function LastIndexOf(const Value: T): Integer;

-    procedure Reverse;

-    procedure Sort; overload;

-    procedure Sort(const AComparer: IComparer<T>); overload;

-    function BinarySearch(const Item: T; out Index: Integer): Boolean; overload;

-    function BinarySearch(const Item: T; out Index: Integer; const AComparer: IComparer<T>): Boolean; overload;

-    procedure TrimExcess;

-    function ToArray: TArray<T>;

-    property Capacity: Integer read GetCapacity write SetCapacity;

-    property Count: Integer read GetCount write SetCount;

-    property Items[Index: Integer]: T read GetItem write SetItem; default;

-  end;

-

-  TThriftListImpl<T> = class( TInterfacedObject, IThriftList<T>)

-  private

-    FList : TList<T>;

-  protected

-    function GetEnumerator: TEnumerator<T>;

-    function GetCapacity: Integer;

-    procedure SetCapacity(Value: Integer);

-    function GetCount: Integer;

-    procedure SetCount(Value: Integer);

-    function GetItem(Index: Integer): T;

-    procedure SetItem(Index: Integer; const Value: T);

-    function Add(const Value: T): Integer;

-    procedure AddRange(const Values: array of T); overload;

-    procedure AddRange(const Collection: IEnumerable<T>); overload;

-    procedure AddRange(Collection: TEnumerable<T>); overload;

-    procedure Insert(Index: Integer; const Value: T);

-    procedure InsertRange(Index: Integer; const Values: array of T); overload;

-    procedure InsertRange(Index: Integer; const Collection: IEnumerable<T>); overload;

-    procedure InsertRange(Index: Integer; const Collection: TEnumerable<T>); overload;

-    function Remove(const Value: T): Integer;

-    procedure Delete(Index: Integer);

-    procedure DeleteRange(AIndex, ACount: Integer);

-    function Extract(const Value: T): T;

-{$IF CompilerVersion >= 21.0}

-    procedure Exchange(Index1, Index2: Integer);

-    procedure Move(CurIndex, NewIndex: Integer);

-    function First: T;

-    function Last: T;

-{$IFEND}

-    procedure Clear;

-    function Contains(const Value: T): Boolean;

-    function IndexOf(const Value: T): Integer;

-    function LastIndexOf(const Value: T): Integer;

-    procedure Reverse;

-    procedure Sort; overload;

-    procedure Sort(const AComparer: IComparer<T>); overload;

-    function BinarySearch(const Item: T; out Index: Integer): Boolean; overload;

-    function BinarySearch(const Item: T; out Index: Integer; const AComparer: IComparer<T>): Boolean; overload;

-    procedure TrimExcess;

-    function ToArray: TArray<T>;

-    property Capacity: Integer read GetCapacity write SetCapacity;

-    property Count: Integer read GetCount write SetCount;

-    property Items[Index: Integer]: T read GetItem write SetItem; default;

-  public

-    constructor Create;

-    destructor Destroy; override;

-  end;

-

-  IHashSet<TValue> = interface(IThriftContainer)

-    ['{0923A3B5-D4D4-48A8-91AD-40238E2EAD66}']

-    function GetEnumerator: TEnumerator<TValue>;

-    function GetIsReadOnly: Boolean;

-    function GetCount: Integer;

-    property Count: Integer read GetCount;

-    property IsReadOnly: Boolean read GetIsReadOnly;

-    procedure Add( const item: TValue);

-    procedure Clear;

-    function Contains( const item: TValue): Boolean;

-    procedure CopyTo(var A: TArray<TValue>; arrayIndex: Integer);

-    function Remove( const item: TValue ): Boolean;

-  end;

-

-  THashSetImpl<TValue> = class( TInterfacedObject, IHashSet<TValue>)

-  private

-    FDictionary : IThriftDictionary<TValue,Integer>;

-    FIsReadOnly: Boolean;

-  protected

-    function GetEnumerator: TEnumerator<TValue>;

-    function GetIsReadOnly: Boolean;

-    function GetCount: Integer;

-    property Count: Integer read GetCount;

-    property IsReadOnly: Boolean read FIsReadOnly;

-    procedure Add( const item: TValue);

-    procedure Clear;

-    function Contains( const item: TValue): Boolean;

-    procedure CopyTo(var A: TArray<TValue>; arrayIndex: Integer);

-    function Remove( const item: TValue ): Boolean;

-  public

-    constructor Create;

-  end;

-

-implementation

-

-{ THashSetImpl<TValue> }

-

-procedure THashSetImpl<TValue>.Add( const item: TValue);

-begin

-  if not FDictionary.ContainsKey(item) then

-  begin

-    FDictionary.Add( item, 0);

-  end;

-end;

-

-procedure THashSetImpl<TValue>.Clear;

-begin

-  FDictionary.Clear;

-end;

-

-function THashSetImpl<TValue>.Contains( const item: TValue): Boolean;

-begin

-  Result := FDictionary.ContainsKey(item);

-end;

-

-procedure THashSetImpl<TValue>.CopyTo(var A: TArray<TValue>; arrayIndex: Integer);

-var

-  i : Integer;

-  Enumlator : TEnumerator<TValue>;

-begin

-  Enumlator := GetEnumerator;

-  while Enumlator.MoveNext do

-  begin

-    A[arrayIndex] := Enumlator.Current;

-    Inc(arrayIndex);

-  end;

-end;

-

-constructor THashSetImpl<TValue>.Create;

-begin

-  inherited;

-  FDictionary := TThriftDictionaryImpl<TValue,Integer>.Create;

-end;

-

-function THashSetImpl<TValue>.GetCount: Integer;

-begin

-  Result := FDictionary.Count;

-end;

-

-function THashSetImpl<TValue>.GetEnumerator: TEnumerator<TValue>;

-begin

-  Result := FDictionary.Keys.GetEnumerator;

-end;

-

-function THashSetImpl<TValue>.GetIsReadOnly: Boolean;

-begin

-  Result := FIsReadOnly;

-end;

-

-function THashSetImpl<TValue>.Remove( const item: TValue): Boolean;

-begin

-  Result := False;

-  if FDictionary.ContainsKey( item ) then

-  begin

-    FDictionary.Remove( item );

-    Result := not FDictionary.ContainsKey( item );

-  end;

-end;

-

-{ TThriftDictionaryImpl<TKey, TValue> }

-

-procedure TThriftDictionaryImpl<TKey, TValue>.Add(const Key: TKey;

-  const Value: TValue);

-begin

-  FDictionaly.Add( Key, Value);

-end;

-

-procedure TThriftDictionaryImpl<TKey, TValue>.AddOrSetValue(const Key: TKey;

-  const Value: TValue);

-begin

-  FDictionaly.AddOrSetValue( Key, Value);

-end;

-

-procedure TThriftDictionaryImpl<TKey, TValue>.Clear;

-begin

-  FDictionaly.Clear;

-end;

-

-function TThriftDictionaryImpl<TKey, TValue>.ContainsKey(

-  const Key: TKey): Boolean;

-begin

-  Result := FDictionaly.ContainsKey( Key );

-end;

-

-function TThriftDictionaryImpl<TKey, TValue>.ContainsValue(

-  const Value: TValue): Boolean;

-begin

-  Result := FDictionaly.ContainsValue( Value );

-end;

-

-constructor TThriftDictionaryImpl<TKey, TValue>.Create(ACapacity: Integer);

-begin

-  inherited Create;

-  FDictionaly := TDictionary<TKey,TValue>.Create( ACapacity );

-end;

-

-destructor TThriftDictionaryImpl<TKey, TValue>.Destroy;

-begin

-  FDictionaly.Free;

-  inherited;

-end;

-

-{$IF CompilerVersion >= 21.0}

-function TThriftDictionaryImpl<TKey, TValue>.ExtractPair( const Key: TKey): TPair<TKey, TValue>;

-begin

-  Result := FDictionaly.ExtractPair( Key);

-end;

-{$IFEND}

-

-function TThriftDictionaryImpl<TKey, TValue>.GetCount: Integer;

-begin

-  Result := FDictionaly.Count;

-end;

-

-function TThriftDictionaryImpl<TKey, TValue>.GetEnumerator: TEnumerator<TPair<TKey, TValue>>;

-begin

-  Result := FDictionaly.GetEnumerator;

-end;

-

-function TThriftDictionaryImpl<TKey, TValue>.GetItem(const Key: TKey): TValue;

-begin

-  Result := FDictionaly.Items[Key];

-end;

-

-function TThriftDictionaryImpl<TKey, TValue>.GetKeys: TDictionary<TKey, TValue>.TKeyCollection;

-begin

-  Result := FDictionaly.Keys;

-end;

-

-function TThriftDictionaryImpl<TKey, TValue>.GetValues: TDictionary<TKey, TValue>.TValueCollection;

-begin

-  Result := FDictionaly.Values;

-end;

-

-procedure TThriftDictionaryImpl<TKey, TValue>.Remove(const Key: TKey);

-begin

-  FDictionaly.Remove( Key );

-end;

-

-procedure TThriftDictionaryImpl<TKey, TValue>.SetItem(const Key: TKey;

-  const Value: TValue);

-begin

-  FDictionaly.AddOrSetValue( Key, Value);

-end;

-

-function TThriftDictionaryImpl<TKey, TValue>.ToArray: TArray<TPair<TKey, TValue>>;

-{$IF CompilerVersion < 22.0}

-var

-  x : TPair<TKey, TValue>;

-  i : Integer;

-{$IFEND}

-begin

-{$IF CompilerVersion < 22.0}

-  SetLength(Result, Count);

-  i := 0;

-  for x in FDictionaly do

-  begin

-    Result[i] := x;

-    Inc( i );

-  end;

-{$ELSE}

-  Result := FDictionaly.ToArray;

-{$IFEND}

-end;

-

-procedure TThriftDictionaryImpl<TKey, TValue>.TrimExcess;

-begin

-  FDictionaly.TrimExcess;

-end;

-

-function TThriftDictionaryImpl<TKey, TValue>.TryGetValue(const Key: TKey;

-  out Value: TValue): Boolean;

-begin

-  Result := FDictionaly.TryGetValue( Key, Value);

-end;

-

-{ TThriftListImpl<T> }

-

-function TThriftListImpl<T>.Add(const Value: T): Integer;

-begin

-  Result := FList.Add( Value );

-end;

-

-procedure TThriftListImpl<T>.AddRange(Collection: TEnumerable<T>);

-begin

-  FList.AddRange( Collection );

-end;

-

-procedure TThriftListImpl<T>.AddRange(const Collection: IEnumerable<T>);

-begin

-  FList.AddRange( Collection );

-end;

-

-procedure TThriftListImpl<T>.AddRange(const Values: array of T);

-begin

-  FList.AddRange( Values );

-end;

-

-function TThriftListImpl<T>.BinarySearch(const Item: T;

-  out Index: Integer): Boolean;

-begin

-  Result := FList.BinarySearch( Item, Index);

-end;

-

-function TThriftListImpl<T>.BinarySearch(const Item: T; out Index: Integer;

-  const AComparer: IComparer<T>): Boolean;

-begin

-  Result := FList.BinarySearch( Item, Index, AComparer);

-end;

-

-procedure TThriftListImpl<T>.Clear;

-begin

-  FList.Clear;

-end;

-

-function TThriftListImpl<T>.Contains(const Value: T): Boolean;

-begin

-  Result := FList.Contains( Value );

-end;

-

-constructor TThriftListImpl<T>.Create;

-begin

-  inherited;

-  FList := TList<T>.Create;

-end;

-

-procedure TThriftListImpl<T>.Delete(Index: Integer);

-begin

-  FList.Delete( Index )

-end;

-

-procedure TThriftListImpl<T>.DeleteRange(AIndex, ACount: Integer);

-begin

-  FList.DeleteRange( AIndex, ACount)

-end;

-

-destructor TThriftListImpl<T>.Destroy;

-begin

-  FList.Free;

-  inherited;

-end;

-

-{$IF CompilerVersion >= 21.0}

-procedure TThriftListImpl<T>.Exchange(Index1, Index2: Integer);

-begin

-  FList.Exchange( Index1, Index2 )

-end;

-{$IFEND}

-

-function TThriftListImpl<T>.Extract(const Value: T): T;

-begin

-  Result := FList.Extract( Value )

-end;

-

-{$IF CompilerVersion >= 21.0}

-function TThriftListImpl<T>.First: T;

-begin

-  Result := FList.First;

-end;

-{$IFEND}

-

-function TThriftListImpl<T>.GetCapacity: Integer;

-begin

-  Result := FList.Capacity;

-end;

-

-function TThriftListImpl<T>.GetCount: Integer;

-begin

-  Result := FList.Count;

-end;

-

-function TThriftListImpl<T>.GetEnumerator: TEnumerator<T>;

-begin

-  Result := FList.GetEnumerator;

-end;

-

-function TThriftListImpl<T>.GetItem(Index: Integer): T;

-begin

-  Result := FList[Index];

-end;

-

-function TThriftListImpl<T>.IndexOf(const Value: T): Integer;

-begin

-  Result := FList.IndexOf( Value );

-end;

-

-procedure TThriftListImpl<T>.Insert(Index: Integer; const Value: T);

-begin

-  FList.Insert( Index, Value);

-end;

-

-procedure TThriftListImpl<T>.InsertRange(Index: Integer;

-  const Collection: TEnumerable<T>);

-begin

-  FList.InsertRange( Index, Collection );

-end;

-

-procedure TThriftListImpl<T>.InsertRange(Index: Integer;

-  const Values: array of T);

-begin

-  FList.InsertRange( Index, Values);

-end;

-

-procedure TThriftListImpl<T>.InsertRange(Index: Integer;

-  const Collection: IEnumerable<T>);

-begin

-  FList.InsertRange( Index, Collection );

-end;

-

-{$IF CompilerVersion >= 21.0}

-function TThriftListImpl<T>.Last: T;

-begin

-  Result := FList.Last;

-end;

-{$IFEND}

-

-function TThriftListImpl<T>.LastIndexOf(const Value: T): Integer;

-begin

-  Result := FList.LastIndexOf( Value );

-end;

-

-{$IF CompilerVersion >= 21.0}

-procedure TThriftListImpl<T>.Move(CurIndex, NewIndex: Integer);

-begin

-  FList.Move( CurIndex,  NewIndex);

-end;

-{$IFEND}

-

-function TThriftListImpl<T>.Remove(const Value: T): Integer;

-begin

-  Result := FList.Remove( Value );

-end;

-

-procedure TThriftListImpl<T>.Reverse;

-begin

-  FList.Reverse;

-end;

-

-procedure TThriftListImpl<T>.SetCapacity(Value: Integer);

-begin

-  FList.Capacity := Value;

-end;

-

-procedure TThriftListImpl<T>.SetCount(Value: Integer);

-begin

-  FList.Count := Value;

-end;

-

-procedure TThriftListImpl<T>.SetItem(Index: Integer; const Value: T);

-begin

-  FList[Index] := Value;

-end;

-

-procedure TThriftListImpl<T>.Sort;

-begin

-  FList.Sort;

-end;

-

-procedure TThriftListImpl<T>.Sort(const AComparer: IComparer<T>);

-begin

-  FList.Sort;

-end;

-

-function TThriftListImpl<T>.ToArray: TArray<T>;

-{$IF CompilerVersion < 22.0}

-var

-  x : T;

-  i : Integer;

-{$IFEND}

-begin

-{$IF CompilerVersion < 22.0}

-  SetLength(Result, Count);

-  i := 0;

-  for x in FList do

-  begin

-    Result[i] := x;

-    Inc( i );

-  end;

-{$ELSE}

-  Result := FList.ToArray;

-{$IFEND}

-end;

-

-procedure TThriftListImpl<T>.TrimExcess;

-begin

-  FList.TrimExcess;

-end;

-

-end.

+(*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *)
+
+unit Thrift.Collections;
+
+interface
+
+uses
+  Generics.Collections, Generics.Defaults, Thrift.Utils;
+
+type
+
+{$IF CompilerVersion < 21.0}
+  TArray<T> = array of T;
+{$IFEND}
+
+  IThriftContainer = interface
+    ['{93DEF5A0-D162-461A-AB22-5B4EE0734050}']
+    function ToString: string;
+  end;
+
+  IThriftDictionary<TKey,TValue> = interface(IThriftContainer)
+    ['{25EDD506-F9D1-4008-A40F-5940364B7E46}']
+    function GetEnumerator: TEnumerator<TPair<TKey,TValue>>;
+
+    function GetKeys: TDictionary<TKey,TValue>.TKeyCollection;
+    function GetValues: TDictionary<TKey,TValue>.TValueCollection;
+    function GetItem(const Key: TKey): TValue;
+    procedure SetItem(const Key: TKey; const Value: TValue);
+    function GetCount: Integer;
+
+    procedure Add(const Key: TKey; const Value: TValue);
+    procedure Remove(const Key: TKey);
+{$IF CompilerVersion >= 21.0}
+    function ExtractPair(const Key: TKey): TPair<TKey,TValue>;
+{$IFEND}
+    procedure Clear;
+    procedure TrimExcess;
+    function TryGetValue(const Key: TKey; out Value: TValue): Boolean;
+    procedure AddOrSetValue(const Key: TKey; const Value: TValue);
+    function ContainsKey(const Key: TKey): Boolean;
+    function ContainsValue(const Value: TValue): Boolean;
+    function ToArray: TArray<TPair<TKey,TValue>>;
+
+    property Items[const Key: TKey]: TValue read GetItem write SetItem; default;
+    property Count: Integer read GetCount;
+    property Keys: TDictionary<TKey,TValue>.TKeyCollection read GetKeys;
+    property Values: TDictionary<TKey,TValue>.TValueCollection read GetValues;
+  end;
+
+  TThriftDictionaryImpl<TKey,TValue> = class( TInterfacedObject, IThriftDictionary<TKey,TValue>)
+  private
+    FDictionaly : TDictionary<TKey,TValue>;
+  protected
+    function GetEnumerator: TEnumerator<TPair<TKey,TValue>>;
+
+    function GetKeys: TDictionary<TKey,TValue>.TKeyCollection;
+    function GetValues: TDictionary<TKey,TValue>.TValueCollection;
+    function GetItem(const Key: TKey): TValue;
+    procedure SetItem(const Key: TKey; const Value: TValue);
+    function GetCount: Integer;
+
+    procedure Add(const Key: TKey; const Value: TValue);
+    procedure Remove(const Key: TKey);
+{$IF CompilerVersion >= 21.0}
+    function ExtractPair(const Key: TKey): TPair<TKey,TValue>;
+{$IFEND}
+    procedure Clear;
+    procedure TrimExcess;
+    function TryGetValue(const Key: TKey; out Value: TValue): Boolean;
+    procedure AddOrSetValue(const Key: TKey; const Value: TValue);
+    function ContainsKey(const Key: TKey): Boolean;
+    function ContainsValue(const Value: TValue): Boolean;
+    function ToArray: TArray<TPair<TKey,TValue>>;
+    property Items[const Key: TKey]: TValue read GetItem write SetItem; default;
+    property Count: Integer read GetCount;
+    property Keys: TDictionary<TKey,TValue>.TKeyCollection read GetKeys;
+    property Values: TDictionary<TKey,TValue>.TValueCollection read GetValues;
+  public
+    constructor Create(ACapacity: Integer = 0);
+    destructor Destroy; override;
+  end;
+
+  IThriftList<T> = interface(IThriftContainer)
+    ['{29BEEE31-9CB4-401B-AA04-5148A75F473B}']
+    function GetEnumerator: TEnumerator<T>;
+    function GetCapacity: Integer;
+    procedure SetCapacity(Value: Integer);
+    function GetCount: Integer;
+    procedure SetCount(Value: Integer);
+    function GetItem(Index: Integer): T;
+    procedure SetItem(Index: Integer; const Value: T);
+    function Add(const Value: T): Integer;
+    procedure AddRange(const Values: array of T); overload;
+    procedure AddRange(const Collection: IEnumerable<T>); overload;
+    procedure AddRange(Collection: TEnumerable<T>); overload;
+    procedure Insert(Index: Integer; const Value: T);
+    procedure InsertRange(Index: Integer; const Values: array of T); overload;
+    procedure InsertRange(Index: Integer; const Collection: IEnumerable<T>); overload;
+    procedure InsertRange(Index: Integer; const Collection: TEnumerable<T>); overload;
+    function Remove(const Value: T): Integer;
+    procedure Delete(Index: Integer);
+    procedure DeleteRange(AIndex, ACount: Integer);
+    function Extract(const Value: T): T;
+{$IF CompilerVersion >= 21.0}
+    procedure Exchange(Index1, Index2: Integer);
+    procedure Move(CurIndex, NewIndex: Integer);
+    function First: T;
+    function Last: T;
+{$IFEND}
+    procedure Clear;
+    function Contains(const Value: T): Boolean;
+    function IndexOf(const Value: T): Integer;
+    function LastIndexOf(const Value: T): Integer;
+    procedure Reverse;
+    procedure Sort; overload;
+    procedure Sort(const AComparer: IComparer<T>); overload;
+    function BinarySearch(const Item: T; out Index: Integer): Boolean; overload;
+    function BinarySearch(const Item: T; out Index: Integer; const AComparer: IComparer<T>): Boolean; overload;
+    procedure TrimExcess;
+    function ToArray: TArray<T>;
+    property Capacity: Integer read GetCapacity write SetCapacity;
+    property Count: Integer read GetCount write SetCount;
+    property Items[Index: Integer]: T read GetItem write SetItem; default;
+  end;
+
+  TThriftListImpl<T> = class( TInterfacedObject, IThriftList<T>)
+  private
+    FList : TList<T>;
+  protected
+    function GetEnumerator: TEnumerator<T>;
+    function GetCapacity: Integer;
+    procedure SetCapacity(Value: Integer);
+    function GetCount: Integer;
+    procedure SetCount(Value: Integer);
+    function GetItem(Index: Integer): T;
+    procedure SetItem(Index: Integer; const Value: T);
+    function Add(const Value: T): Integer;
+    procedure AddRange(const Values: array of T); overload;
+    procedure AddRange(const Collection: IEnumerable<T>); overload;
+    procedure AddRange(Collection: TEnumerable<T>); overload;
+    procedure Insert(Index: Integer; const Value: T);
+    procedure InsertRange(Index: Integer; const Values: array of T); overload;
+    procedure InsertRange(Index: Integer; const Collection: IEnumerable<T>); overload;
+    procedure InsertRange(Index: Integer; const Collection: TEnumerable<T>); overload;
+    function Remove(const Value: T): Integer;
+    procedure Delete(Index: Integer);
+    procedure DeleteRange(AIndex, ACount: Integer);
+    function Extract(const Value: T): T;
+{$IF CompilerVersion >= 21.0}
+    procedure Exchange(Index1, Index2: Integer);
+    procedure Move(CurIndex, NewIndex: Integer);
+    function First: T;
+    function Last: T;
+{$IFEND}
+    procedure Clear;
+    function Contains(const Value: T): Boolean;
+    function IndexOf(const Value: T): Integer;
+    function LastIndexOf(const Value: T): Integer;
+    procedure Reverse;
+    procedure Sort; overload;
+    procedure Sort(const AComparer: IComparer<T>); overload;
+    function BinarySearch(const Item: T; out Index: Integer): Boolean; overload;
+    function BinarySearch(const Item: T; out Index: Integer; const AComparer: IComparer<T>): Boolean; overload;
+    procedure TrimExcess;
+    function ToArray: TArray<T>;
+    property Capacity: Integer read GetCapacity write SetCapacity;
+    property Count: Integer read GetCount write SetCount;
+    property Items[Index: Integer]: T read GetItem write SetItem; default;
+  public
+    constructor Create;
+    destructor Destroy; override;
+  end;
+
+  IHashSet<TValue> = interface(IThriftContainer)
+    ['{0923A3B5-D4D4-48A8-91AD-40238E2EAD66}']
+    function GetEnumerator: TEnumerator<TValue>;
+    function GetIsReadOnly: Boolean;
+    function GetCount: Integer;
+    property Count: Integer read GetCount;
+    property IsReadOnly: Boolean read GetIsReadOnly;
+    procedure Add( const item: TValue);
+    procedure Clear;
+    function Contains( const item: TValue): Boolean;
+    procedure CopyTo(var A: TArray<TValue>; arrayIndex: Integer);
+    function Remove( const item: TValue ): Boolean;
+  end;
+
+  THashSetImpl<TValue> = class( TInterfacedObject, IHashSet<TValue>)
+  private
+    FDictionary : IThriftDictionary<TValue,Integer>;
+    FIsReadOnly: Boolean;
+  protected
+    function GetEnumerator: TEnumerator<TValue>;
+    function GetIsReadOnly: Boolean;
+    function GetCount: Integer;
+    property Count: Integer read GetCount;
+    property IsReadOnly: Boolean read FIsReadOnly;
+    procedure Add( const item: TValue);
+    procedure Clear;
+    function Contains( const item: TValue): Boolean;
+    procedure CopyTo(var A: TArray<TValue>; arrayIndex: Integer);
+    function Remove( const item: TValue ): Boolean;
+  public
+    constructor Create;
+  end;
+
+implementation
+
+{ THashSetImpl<TValue> }
+
+procedure THashSetImpl<TValue>.Add( const item: TValue);
+begin
+  if not FDictionary.ContainsKey(item) then
+  begin
+    FDictionary.Add( item, 0);
+  end;
+end;
+
+procedure THashSetImpl<TValue>.Clear;
+begin
+  FDictionary.Clear;
+end;
+
+function THashSetImpl<TValue>.Contains( const item: TValue): Boolean;
+begin
+  Result := FDictionary.ContainsKey(item);
+end;
+
+procedure THashSetImpl<TValue>.CopyTo(var A: TArray<TValue>; arrayIndex: Integer);
+var
+  i : Integer;
+  Enumlator : TEnumerator<TValue>;
+begin
+  Enumlator := GetEnumerator;
+  while Enumlator.MoveNext do
+  begin
+    A[arrayIndex] := Enumlator.Current;
+    Inc(arrayIndex);
+  end;
+end;
+
+constructor THashSetImpl<TValue>.Create;
+begin
+  inherited;
+  FDictionary := TThriftDictionaryImpl<TValue,Integer>.Create;
+end;
+
+function THashSetImpl<TValue>.GetCount: Integer;
+begin
+  Result := FDictionary.Count;
+end;
+
+function THashSetImpl<TValue>.GetEnumerator: TEnumerator<TValue>;
+begin
+  Result := FDictionary.Keys.GetEnumerator;
+end;
+
+function THashSetImpl<TValue>.GetIsReadOnly: Boolean;
+begin
+  Result := FIsReadOnly;
+end;
+
+function THashSetImpl<TValue>.Remove( const item: TValue): Boolean;
+begin
+  Result := False;
+  if FDictionary.ContainsKey( item ) then
+  begin
+    FDictionary.Remove( item );
+    Result := not FDictionary.ContainsKey( item );
+  end;
+end;
+
+{ TThriftDictionaryImpl<TKey, TValue> }
+
+procedure TThriftDictionaryImpl<TKey, TValue>.Add(const Key: TKey;
+  const Value: TValue);
+begin
+  FDictionaly.Add( Key, Value);
+end;
+
+procedure TThriftDictionaryImpl<TKey, TValue>.AddOrSetValue(const Key: TKey;
+  const Value: TValue);
+begin
+  FDictionaly.AddOrSetValue( Key, Value);
+end;
+
+procedure TThriftDictionaryImpl<TKey, TValue>.Clear;
+begin
+  FDictionaly.Clear;
+end;
+
+function TThriftDictionaryImpl<TKey, TValue>.ContainsKey(
+  const Key: TKey): Boolean;
+begin
+  Result := FDictionaly.ContainsKey( Key );
+end;
+
+function TThriftDictionaryImpl<TKey, TValue>.ContainsValue(
+  const Value: TValue): Boolean;
+begin
+  Result := FDictionaly.ContainsValue( Value );
+end;
+
+constructor TThriftDictionaryImpl<TKey, TValue>.Create(ACapacity: Integer);
+begin
+  inherited Create;
+  FDictionaly := TDictionary<TKey,TValue>.Create( ACapacity );
+end;
+
+destructor TThriftDictionaryImpl<TKey, TValue>.Destroy;
+begin
+  FDictionaly.Free;
+  inherited;
+end;
+
+{$IF CompilerVersion >= 21.0}
+function TThriftDictionaryImpl<TKey, TValue>.ExtractPair( const Key: TKey): TPair<TKey, TValue>;
+begin
+  Result := FDictionaly.ExtractPair( Key);
+end;
+{$IFEND}
+
+function TThriftDictionaryImpl<TKey, TValue>.GetCount: Integer;
+begin
+  Result := FDictionaly.Count;
+end;
+
+function TThriftDictionaryImpl<TKey, TValue>.GetEnumerator: TEnumerator<TPair<TKey, TValue>>;
+begin
+  Result := FDictionaly.GetEnumerator;
+end;
+
+function TThriftDictionaryImpl<TKey, TValue>.GetItem(const Key: TKey): TValue;
+begin
+  Result := FDictionaly.Items[Key];
+end;
+
+function TThriftDictionaryImpl<TKey, TValue>.GetKeys: TDictionary<TKey, TValue>.TKeyCollection;
+begin
+  Result := FDictionaly.Keys;
+end;
+
+function TThriftDictionaryImpl<TKey, TValue>.GetValues: TDictionary<TKey, TValue>.TValueCollection;
+begin
+  Result := FDictionaly.Values;
+end;
+
+procedure TThriftDictionaryImpl<TKey, TValue>.Remove(const Key: TKey);
+begin
+  FDictionaly.Remove( Key );
+end;
+
+procedure TThriftDictionaryImpl<TKey, TValue>.SetItem(const Key: TKey;
+  const Value: TValue);
+begin
+  FDictionaly.AddOrSetValue( Key, Value);
+end;
+
+function TThriftDictionaryImpl<TKey, TValue>.ToArray: TArray<TPair<TKey, TValue>>;
+{$IF CompilerVersion < 22.0}
+var
+  x : TPair<TKey, TValue>;
+  i : Integer;
+{$IFEND}
+begin
+{$IF CompilerVersion < 22.0}
+  SetLength(Result, Count);
+  i := 0;
+  for x in FDictionaly do
+  begin
+    Result[i] := x;
+    Inc( i );
+  end;
+{$ELSE}
+  Result := FDictionaly.ToArray;
+{$IFEND}
+end;
+
+procedure TThriftDictionaryImpl<TKey, TValue>.TrimExcess;
+begin
+  FDictionaly.TrimExcess;
+end;
+
+function TThriftDictionaryImpl<TKey, TValue>.TryGetValue(const Key: TKey;
+  out Value: TValue): Boolean;
+begin
+  Result := FDictionaly.TryGetValue( Key, Value);
+end;
+
+{ TThriftListImpl<T> }
+
+function TThriftListImpl<T>.Add(const Value: T): Integer;
+begin
+  Result := FList.Add( Value );
+end;
+
+procedure TThriftListImpl<T>.AddRange(Collection: TEnumerable<T>);
+begin
+  FList.AddRange( Collection );
+end;
+
+procedure TThriftListImpl<T>.AddRange(const Collection: IEnumerable<T>);
+begin
+  FList.AddRange( Collection );
+end;
+
+procedure TThriftListImpl<T>.AddRange(const Values: array of T);
+begin
+  FList.AddRange( Values );
+end;
+
+function TThriftListImpl<T>.BinarySearch(const Item: T;
+  out Index: Integer): Boolean;
+begin
+  Result := FList.BinarySearch( Item, Index);
+end;
+
+function TThriftListImpl<T>.BinarySearch(const Item: T; out Index: Integer;
+  const AComparer: IComparer<T>): Boolean;
+begin
+  Result := FList.BinarySearch( Item, Index, AComparer);
+end;
+
+procedure TThriftListImpl<T>.Clear;
+begin
+  FList.Clear;
+end;
+
+function TThriftListImpl<T>.Contains(const Value: T): Boolean;
+begin
+  Result := FList.Contains( Value );
+end;
+
+constructor TThriftListImpl<T>.Create;
+begin
+  inherited;
+  FList := TList<T>.Create;
+end;
+
+procedure TThriftListImpl<T>.Delete(Index: Integer);
+begin
+  FList.Delete( Index )
+end;
+
+procedure TThriftListImpl<T>.DeleteRange(AIndex, ACount: Integer);
+begin
+  FList.DeleteRange( AIndex, ACount)
+end;
+
+destructor TThriftListImpl<T>.Destroy;
+begin
+  FList.Free;
+  inherited;
+end;
+
+{$IF CompilerVersion >= 21.0}
+procedure TThriftListImpl<T>.Exchange(Index1, Index2: Integer);
+begin
+  FList.Exchange( Index1, Index2 )
+end;
+{$IFEND}
+
+function TThriftListImpl<T>.Extract(const Value: T): T;
+begin
+  Result := FList.Extract( Value )
+end;
+
+{$IF CompilerVersion >= 21.0}
+function TThriftListImpl<T>.First: T;
+begin
+  Result := FList.First;
+end;
+{$IFEND}
+
+function TThriftListImpl<T>.GetCapacity: Integer;
+begin
+  Result := FList.Capacity;
+end;
+
+function TThriftListImpl<T>.GetCount: Integer;
+begin
+  Result := FList.Count;
+end;
+
+function TThriftListImpl<T>.GetEnumerator: TEnumerator<T>;
+begin
+  Result := FList.GetEnumerator;
+end;
+
+function TThriftListImpl<T>.GetItem(Index: Integer): T;
+begin
+  Result := FList[Index];
+end;
+
+function TThriftListImpl<T>.IndexOf(const Value: T): Integer;
+begin
+  Result := FList.IndexOf( Value );
+end;
+
+procedure TThriftListImpl<T>.Insert(Index: Integer; const Value: T);
+begin
+  FList.Insert( Index, Value);
+end;
+
+procedure TThriftListImpl<T>.InsertRange(Index: Integer;
+  const Collection: TEnumerable<T>);
+begin
+  FList.InsertRange( Index, Collection );
+end;
+
+procedure TThriftListImpl<T>.InsertRange(Index: Integer;
+  const Values: array of T);
+begin
+  FList.InsertRange( Index, Values);
+end;
+
+procedure TThriftListImpl<T>.InsertRange(Index: Integer;
+  const Collection: IEnumerable<T>);
+begin
+  FList.InsertRange( Index, Collection );
+end;
+
+{$IF CompilerVersion >= 21.0}
+function TThriftListImpl<T>.Last: T;
+begin
+  Result := FList.Last;
+end;
+{$IFEND}
+
+function TThriftListImpl<T>.LastIndexOf(const Value: T): Integer;
+begin
+  Result := FList.LastIndexOf( Value );
+end;
+
+{$IF CompilerVersion >= 21.0}
+procedure TThriftListImpl<T>.Move(CurIndex, NewIndex: Integer);
+begin
+  FList.Move( CurIndex,  NewIndex);
+end;
+{$IFEND}
+
+function TThriftListImpl<T>.Remove(const Value: T): Integer;
+begin
+  Result := FList.Remove( Value );
+end;
+
+procedure TThriftListImpl<T>.Reverse;
+begin
+  FList.Reverse;
+end;
+
+procedure TThriftListImpl<T>.SetCapacity(Value: Integer);
+begin
+  FList.Capacity := Value;
+end;
+
+procedure TThriftListImpl<T>.SetCount(Value: Integer);
+begin
+  FList.Count := Value;
+end;
+
+procedure TThriftListImpl<T>.SetItem(Index: Integer; const Value: T);
+begin
+  FList[Index] := Value;
+end;
+
+procedure TThriftListImpl<T>.Sort;
+begin
+  FList.Sort;
+end;
+
+procedure TThriftListImpl<T>.Sort(const AComparer: IComparer<T>);
+begin
+  FList.Sort;
+end;
+
+function TThriftListImpl<T>.ToArray: TArray<T>;
+{$IF CompilerVersion < 22.0}
+var
+  x : T;
+  i : Integer;
+{$IFEND}
+begin
+{$IF CompilerVersion < 22.0}
+  SetLength(Result, Count);
+  i := 0;
+  for x in FList do
+  begin
+    Result[i] := x;
+    Inc( i );
+  end;
+{$ELSE}
+  Result := FList.ToArray;
+{$IFEND}
+end;
+
+procedure TThriftListImpl<T>.TrimExcess;
+begin
+  FList.TrimExcess;
+end;
+
+end.
diff --git a/lib/delphi/src/Thrift.Console.pas b/lib/delphi/src/Thrift.Console.pas
index 5d1345b..a52eeb9 100644
--- a/lib/delphi/src/Thrift.Console.pas
+++ b/lib/delphi/src/Thrift.Console.pas
@@ -1,133 +1,133 @@
-(*

- * Licensed to the Apache Software Foundation (ASF) under one

- * or more contributor license agreements. See the NOTICE file

- * distributed with this work for additional information

- * regarding copyright ownership. The ASF licenses this file

- * to you under the Apache License, Version 2.0 (the

- * "License"); you may not use this file except in compliance

- * with the License. You may obtain a copy of the License at

- *

- *   http://www.apache.org/licenses/LICENSE-2.0

- *

- * Unless required by applicable law or agreed to in writing,

- * software distributed under the License is distributed on an

- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

- * KIND, either express or implied. See the License for the

- * specific language governing permissions and limitations

- * under the License.

- *)

-

-unit Thrift.Console;

-

-interface

-

-uses

-  StdCtrls;

-

-type

-  TThriftConsole = class

-  public

-    procedure Write( const S: string); virtual;

-    procedure WriteLine( const S: string); virtual;

-  end;

-

-  TGUIConsole = class( TThriftConsole )

-  private

-    FLineBreak : Boolean;

-    FMemo : TMemo;

-

-    procedure InternalWrite( const S: string; bWriteLine: Boolean);

-  public

-    procedure Write( const S: string); override;

-    procedure WriteLine( const S: string); override;

-    constructor Create( AMemo: TMemo);

-  end;

-

-function Console: TThriftConsole;

-procedure ChangeConsole( AConsole: TThriftConsole );

-procedure RestoreConsoleToDefault;

-

-implementation

-

-var

-  FDefaultConsole : TThriftConsole;

-  FConsole : TThriftConsole;

-

-function Console: TThriftConsole;

-begin

-  Result := FConsole;

-end;

-

-{ TThriftConsole }

-

-procedure TThriftConsole.Write(const S: string);

-begin

-  System.Write( S );

-end;

-

-procedure TThriftConsole.WriteLine(const S: string);

-begin

-  System.Writeln( S );

-end;

-

-procedure ChangeConsole( AConsole: TThriftConsole );

-begin

-  FConsole := AConsole;

-end;

-

-procedure RestoreConsoleToDefault;

-begin

-  FConsole := FDefaultConsole;

-end;

-

-{ TGUIConsole }

-

-constructor TGUIConsole.Create( AMemo: TMemo);

-begin

-  inherited Create;

-  FMemo := AMemo;

-  FLineBreak := True;

-end;

-

-procedure TGUIConsole.InternalWrite(const S: string; bWriteLine: Boolean);

-var

-  idx : Integer;

-begin

-  if FLineBreak then

-  begin

-    FMemo.Lines.Add( S );

-  end else

-  begin

-    idx := FMemo.Lines.Count - 1;

-    if idx < 0 then

-    begin

-      FMemo.Lines.Add( S );

-    end;

-    FMemo.Lines[idx] := FMemo.Lines[idx] + S;

-  end;

-  FLineBreak := bWriteLine;

-end;

-

-procedure TGUIConsole.Write(const S: string);

-begin

-  InternalWrite( S, False);

-end;

-

-procedure TGUIConsole.WriteLine(const S: string);

-begin

-  InternalWrite( S, True);

-end;

-

-initialization

-begin

-  FDefaultConsole := TThriftConsole.Create;

-  FConsole := FDefaultConsole;

-end;

-

-finalization

-begin

-  FDefaultConsole.Free;

-end;

-

-end.

-

+(*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *)
+
+unit Thrift.Console;
+
+interface
+
+uses
+  StdCtrls;
+
+type
+  TThriftConsole = class
+  public
+    procedure Write( const S: string); virtual;
+    procedure WriteLine( const S: string); virtual;
+  end;
+
+  TGUIConsole = class( TThriftConsole )
+  private
+    FLineBreak : Boolean;
+    FMemo : TMemo;
+
+    procedure InternalWrite( const S: string; bWriteLine: Boolean);
+  public
+    procedure Write( const S: string); override;
+    procedure WriteLine( const S: string); override;
+    constructor Create( AMemo: TMemo);
+  end;
+
+function Console: TThriftConsole;
+procedure ChangeConsole( AConsole: TThriftConsole );
+procedure RestoreConsoleToDefault;
+
+implementation
+
+var
+  FDefaultConsole : TThriftConsole;
+  FConsole : TThriftConsole;
+
+function Console: TThriftConsole;
+begin
+  Result := FConsole;
+end;
+
+{ TThriftConsole }
+
+procedure TThriftConsole.Write(const S: string);
+begin
+  System.Write( S );
+end;
+
+procedure TThriftConsole.WriteLine(const S: string);
+begin
+  System.Writeln( S );
+end;
+
+procedure ChangeConsole( AConsole: TThriftConsole );
+begin
+  FConsole := AConsole;
+end;
+
+procedure RestoreConsoleToDefault;
+begin
+  FConsole := FDefaultConsole;
+end;
+
+{ TGUIConsole }
+
+constructor TGUIConsole.Create( AMemo: TMemo);
+begin
+  inherited Create;
+  FMemo := AMemo;
+  FLineBreak := True;
+end;
+
+procedure TGUIConsole.InternalWrite(const S: string; bWriteLine: Boolean);
+var
+  idx : Integer;
+begin
+  if FLineBreak then
+  begin
+    FMemo.Lines.Add( S );
+  end else
+  begin
+    idx := FMemo.Lines.Count - 1;
+    if idx < 0 then
+    begin
+      FMemo.Lines.Add( S );
+    end;
+    FMemo.Lines[idx] := FMemo.Lines[idx] + S;
+  end;
+  FLineBreak := bWriteLine;
+end;
+
+procedure TGUIConsole.Write(const S: string);
+begin
+  InternalWrite( S, False);
+end;
+
+procedure TGUIConsole.WriteLine(const S: string);
+begin
+  InternalWrite( S, True);
+end;
+
+initialization
+begin
+  FDefaultConsole := TThriftConsole.Create;
+  FConsole := FDefaultConsole;
+end;
+
+finalization
+begin
+  FDefaultConsole.Free;
+end;
+
+end.
+
diff --git a/lib/delphi/src/Thrift.Processor.Multiplex.pas b/lib/delphi/src/Thrift.Processor.Multiplex.pas
index 198bed8..f6d9446 100644
--- a/lib/delphi/src/Thrift.Processor.Multiplex.pas
+++ b/lib/delphi/src/Thrift.Processor.Multiplex.pas
@@ -1,22 +1,22 @@
 (*
- * Licensed to the Apache Software Foundation (ASF) under one

- * or more contributor license agreements. See the NOTICE file

- * distributed with this work for additional information

- * regarding copyright ownership. The ASF licenses this file

- * to you under the Apache License, Version 2.0 (the

- * "License"); you may not use this file except in compliance

- * with the License. You may obtain a copy of the License at

- *

- *   http://www.apache.org/licenses/LICENSE-2.0

- *

- * Unless required by applicable law or agreed to in writing,

- * software distributed under the License is distributed on an

- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

- * KIND, either express or implied. See the License for the

- * specific language governing permissions and limitations

- * under the License.

- *)

-

+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *)
+
 unit Thrift.Processor.Multiplex;
 
 
@@ -53,7 +53,7 @@
 
 type
   IMultiplexedProcessor = interface( IProcessor)
-    ['{810FF32D-22A2-4D58-B129-B0590703ECEC}']

+    ['{810FF32D-22A2-4D58-B129-B0590703ECEC}']
     // Register a service with this TMultiplexedProcessor.  This allows us
     // to broker requests to individual services by using the service name
     // to select them at request time.
@@ -150,14 +150,14 @@
   appex := TApplicationException.Create( extype, etxt);
   try
     newMsg := TMessageImpl.Create( msg.Name, TMessageType.Exception, msg.SeqID);
-

+
     oprot.WriteMessageBegin(newMsg);
     appex.Write(oprot);
     oprot.WriteMessageEnd();
     oprot.Transport.Flush();
 
   finally
-    appex.Free;

+    appex.Free;
   end;
 end;
 
@@ -180,9 +180,9 @@
     Error( oprot, msg,
            TApplicationException.TExceptionType.InvalidMessageType,
            ERROR_INVALID_MSGTYPE);
-    Exit( FALSE);

-  end;

-

+    Exit( FALSE);
+  end;
+
   // Extract the service name
   idx := Pos( TMultiplexedProtocol.SEPARATOR, msg.Name);
   if idx < 1 then begin
@@ -190,7 +190,7 @@
            TApplicationException.TExceptionType.InvalidProtocol,
            Format(ERROR_INCOMPATIBLE_PROT,[msg.Name]));
     Exit( FALSE);
-  end;

+  end;
 
   // Create a new TMessage, something that can be consumed by any TProtocol
   sService := Copy( msg.Name, 1, idx-1);
@@ -200,7 +200,7 @@
            TApplicationException.TExceptionType.InternalError,
            Format(ERROR_UNKNOWN_SERVICE,[sService]));
     Exit( FALSE);
-  end;

+  end;
 
   // Create a new TMessage, removing the service name
   Inc( idx, Length(TMultiplexedProtocol.SEPARATOR));
diff --git a/lib/delphi/src/Thrift.Protocol.Multiplex.pas b/lib/delphi/src/Thrift.Protocol.Multiplex.pas
index 2cd2401..18b39b5 100644
--- a/lib/delphi/src/Thrift.Protocol.Multiplex.pas
+++ b/lib/delphi/src/Thrift.Protocol.Multiplex.pas
@@ -1,22 +1,22 @@
 (*
- * Licensed to the Apache Software Foundation (ASF) under one

- * or more contributor license agreements. See the NOTICE file

- * distributed with this work for additional information

- * regarding copyright ownership. The ASF licenses this file

- * to you under the Apache License, Version 2.0 (the

- * "License"); you may not use this file except in compliance

- * with the License. You may obtain a copy of the License at

- *

- *   http://www.apache.org/licenses/LICENSE-2.0

- *

- * Unless required by applicable law or agreed to in writing,

- * software distributed under the License is distributed on an

- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

- * KIND, either express or implied. See the License for the

- * specific language governing permissions and limitations

- * under the License.

- *)

-

+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *)
+
 unit Thrift.Protocol.Multiplex;
 
 interface
diff --git a/lib/delphi/src/Thrift.Protocol.pas b/lib/delphi/src/Thrift.Protocol.pas
index 4d92cb1..6cff09c 100644
--- a/lib/delphi/src/Thrift.Protocol.pas
+++ b/lib/delphi/src/Thrift.Protocol.pas
@@ -1,505 +1,505 @@
-(*

- * Licensed to the Apache Software Foundation (ASF) under one

- * or more contributor license agreements. See the NOTICE file

- * distributed with this work for additional information

- * regarding copyright ownership. The ASF licenses this file

- * to you under the Apache License, Version 2.0 (the

- * "License"); you may not use this file except in compliance

- * with the License. You may obtain a copy of the License at

- *

- *   http://www.apache.org/licenses/LICENSE-2.0

- *

- * Unless required by applicable law or agreed to in writing,

- * software distributed under the License is distributed on an

- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

- * KIND, either express or implied. See the License for the

- * specific language governing permissions and limitations

- * under the License.

- *)

-

-{$SCOPEDENUMS ON}

-

-unit Thrift.Protocol;

-

-interface

-

-uses

-  Classes,

-  SysUtils,

-  Contnrs,

-  Thrift.Stream,

-  Thrift.Collections,

-  Thrift.Transport;

-

-type

-

-  TType = (

-    Stop = 0,

-    Void = 1,

-    Bool_ = 2,

-    Byte_ = 3,

-    Double_ = 4,

-    I16 = 6,

-    I32 = 8,

-    I64 = 10,

-    String_ = 11,

-    Struct = 12,

-    Map = 13,

-    Set_ = 14,

-    List = 15

-  );

-

-  TMessageType = (

-    Call = 1,

-    Reply = 2,

-    Exception = 3,

-    Oneway = 4

-  );

-

-  IProtocol = interface;

-  IStruct = interface;

-

-  IProtocolFactory = interface

-    ['{7CD64A10-4E9F-4E99-93BF-708A31F4A67B}']

-    function GetProtocol( const trans: ITransport): IProtocol;

-  end;

-

-  TThriftStringBuilder = class( TStringBuilder)

-  public

-    function Append(const Value: TBytes): TStringBuilder; overload;

-    function Append(const Value: IThriftContainer): TStringBuilder; overload;

-  end;

-

-  TProtocolException = class( Exception )

-  public

-    const // TODO(jensg): change into enum

-      UNKNOWN : Integer = 0;

-      INVALID_DATA : Integer = 1;

-      NEGATIVE_SIZE : Integer = 2;

-      SIZE_LIMIT : Integer = 3;

-      BAD_VERSION : Integer = 4;

-      NOT_IMPLEMENTED : Integer = 5;

-      DEPTH_LIMIT : Integer = 6;

-  protected

-    FType : Integer;

-  public

-    constructor Create; overload;

-    constructor Create( type_: Integer ); overload;

-    constructor Create( type_: Integer; const msg: string); overload;

-  end;

-

-  IMap = interface

-    ['{30531D97-7E06-4233-B800-C3F53CCD23E7}']

-    function GetKeyType: TType;

-    procedure SetKeyType( Value: TType);

-    function GetValueType: TType;

-    procedure SetValueType( Value: TType);

-    function GetCount: Integer;

-    procedure SetCount( Value: Integer);

-    property KeyType: TType read GetKeyType write SetKeyType;

-    property ValueType: TType read GetValueType write SetValueType;

-    property Count: Integer read GetCount write SetCount;

-  end;

-

-  TMapImpl = class( TInterfacedObject, IMap)

-  private

-    FValueType: TType;

-    FKeyType: TType;

-    FCount: Integer;

-  protected

-    function GetKeyType: TType;

-    procedure SetKeyType( Value: TType);

-    function GetValueType: TType;

-    procedure SetValueType( Value: TType);

-    function GetCount: Integer;

-    procedure SetCount( Value: Integer);

-  public

-    constructor Create( AValueType: TType; AKeyType: TType; ACount: Integer); overload;

-    constructor Create; overload;

-  end;

-

-  IList = interface

-    ['{6763E1EA-A934-4472-904F-0083980B9B87}']

-    function GetElementType: TType;

-    procedure SetElementType( Value: TType);

-    function GetCount: Integer;

-    procedure SetCount( Value: Integer);

-    property ElementType: TType read GetElementType write SetElementType;

-    property Count: Integer read GetCount write SetCount;

-  end;

-

-  TListImpl = class( TInterfacedObject, IList)

-  private

-    FElementType: TType;

-    FCount : Integer;

-  protected

-    function GetElementType: TType;

-    procedure SetElementType( Value: TType);

-    function GetCount: Integer;

-    procedure SetCount( Value: Integer);

-  public

-    constructor Create( AElementType: TType; ACount: Integer); overload;

-    constructor Create; overload;

-  end;

-

-  ISet = interface

-    ['{A8671700-7514-4C1E-8A05-62786872005F}']

-    function GetElementType: TType;

-    procedure SetElementType( Value: TType);

-    function GetCount: Integer;

-    procedure SetCount( Value: Integer);

-    property ElementType: TType read GetElementType write SetElementType;

-    property Count: Integer read GetCount write SetCount;

-  end;

-

-  TSetImpl = class( TInterfacedObject, ISet)

-  private

-    FCount: Integer;

-    FElementType: TType;

-  protected

-    function GetElementType: TType;

-    procedure SetElementType( Value: TType);

-    function GetCount: Integer;

-    procedure SetCount( Value: Integer);

-  public

-    constructor Create( AElementType: TType; ACount: Integer); overload;

-    constructor Create; overload;

-  end;

-

-  IMessage = interface

-    ['{9E368B4A-B1FA-43E7-8CF5-56C66D256CA7}']

-    function GetName: string;

-    procedure SetName( const Value: string);

-    function GetType: TMessageType;

-    procedure SetType( Value: TMessageType);

-    function GetSeqID: Integer;

-    procedure SetSeqID( Value: Integer);

-    property Name: string read GetName write SetName;

-    property Type_: TMessageType read GetType write SetType;

-    property SeqID: Integer read GetSeqID write SetSeqID;

-  end;

-

-  TMessageImpl = class( TInterfacedObject, IMessage )

-  private

-    FName: string;

-    FMessageType: TMessageType;

-    FSeqID: Integer;

-  protected

-    function GetName: string;

-    procedure SetName( const Value: string);

-    function GetType: TMessageType;

-    procedure SetType( Value: TMessageType);

-    function GetSeqID: Integer;

-    procedure SetSeqID( Value: Integer);

-  public

-    property Name: string read FName write FName;

-    property Type_: TMessageType read FMessageType write FMessageType;

-    property SeqID: Integer read FSeqID write FSeqID;

-    constructor Create( AName: string; AMessageType: TMessageType; ASeqID: Integer); overload;

-    constructor Create; overload;

-  end;

-

-  IField = interface

-    ['{F0D43BE5-7883-442E-83FF-0580CC632B72}']

-    function GetName: string;

-    procedure SetName( const Value: string);

-    function GetType: TType;

-    procedure SetType( Value: TType);

-    function GetId: SmallInt;

-    procedure SetId( Value: SmallInt);

-    property Name: string read GetName write SetName;

-    property Type_: TType read GetType write SetType;

-    property Id: SmallInt read GetId write SetId;

-  end;

-

-  TFieldImpl = class( TInterfacedObject, IField)

-  private

-    FName : string;

-    FType : TType;

-    FId   : SmallInt;

-  protected

-    function GetName: string;

-    procedure SetName( const Value: string);

-    function GetType: TType;

-    procedure SetType( Value: TType);

-    function GetId: SmallInt;

-    procedure SetId( Value: SmallInt);

-  public

-    constructor Create( const AName: string; const AType: TType; AId: SmallInt); overload;

-    constructor Create; overload;

-  end;

-

-  TProtocolUtil = class

-  public

-    class procedure Skip( prot: IProtocol; type_: TType);

-  end;

-

-  IProtocol = interface

-    ['{FD95C151-1527-4C96-8134-B902BFC4B4FC}']

-    function GetTransport: ITransport;

-    procedure WriteMessageBegin( const msg: IMessage);

-    procedure WriteMessageEnd;

-    procedure WriteStructBegin( const struc: IStruct);

-    procedure WriteStructEnd;

-    procedure WriteFieldBegin( const field: IField);

-    procedure WriteFieldEnd;

-    procedure WriteFieldStop;

-    procedure WriteMapBegin( const map: IMap);

-    procedure WriteMapEnd;

-    procedure WriteListBegin( const list: IList);

-    procedure WriteListEnd();

-    procedure WriteSetBegin( const set_: ISet );

-    procedure WriteSetEnd();

-    procedure WriteBool( b: Boolean);

-    procedure WriteByte( b: ShortInt);

-    procedure WriteI16( i16: SmallInt);

-    procedure WriteI32( i32: Integer);

-    procedure WriteI64( const i64: Int64);

-    procedure WriteDouble( const d: Double);

-    procedure WriteString( const s: string );

-    procedure WriteAnsiString( const s: AnsiString);

-    procedure WriteBinary( const b: TBytes);

-

-    function ReadMessageBegin: IMessage;

-    procedure ReadMessageEnd();

-    function ReadStructBegin: IStruct;

-    procedure ReadStructEnd;

-    function ReadFieldBegin: IField;

-    procedure ReadFieldEnd();

-    function ReadMapBegin: IMap;

-    procedure ReadMapEnd();

-    function ReadListBegin: IList;

-    procedure ReadListEnd();

-    function ReadSetBegin: ISet;

-    procedure ReadSetEnd();

-    function ReadBool: Boolean;

-    function ReadByte: ShortInt;

-    function ReadI16: SmallInt;

-    function ReadI32: Integer;

-    function ReadI64: Int64;

-    function ReadDouble:Double;

-    function ReadBinary: TBytes;

-    function ReadString: string;

-    function ReadAnsiString: AnsiString;

-    property Transport: ITransport read GetTransport;

-  end;

-

-  TProtocolImpl = class abstract( TInterfacedObject, IProtocol)

-  protected

-    FTrans : ITransport;

-    function GetTransport: ITransport;

-  public

-    procedure WriteMessageBegin( const msg: IMessage); virtual; abstract;

-    procedure WriteMessageEnd; virtual; abstract;

-    procedure WriteStructBegin( const struc: IStruct); virtual; abstract;

-    procedure WriteStructEnd; virtual; abstract;

-    procedure WriteFieldBegin( const field: IField); virtual; abstract;

-    procedure WriteFieldEnd; virtual; abstract;

-    procedure WriteFieldStop; virtual; abstract;

-    procedure WriteMapBegin( const map: IMap); virtual; abstract;

-    procedure WriteMapEnd; virtual; abstract;

-    procedure WriteListBegin( const list: IList); virtual; abstract;

-    procedure WriteListEnd(); virtual; abstract;

-    procedure WriteSetBegin( const set_: ISet ); virtual; abstract;

-    procedure WriteSetEnd(); virtual; abstract;

-    procedure WriteBool( b: Boolean); virtual; abstract;

-    procedure WriteByte( b: ShortInt); virtual; abstract;

-    procedure WriteI16( i16: SmallInt); virtual; abstract;

-    procedure WriteI32( i32: Integer); virtual; abstract;

-    procedure WriteI64( const i64: Int64); virtual; abstract;

-    procedure WriteDouble( const d: Double); virtual; abstract;

-    procedure WriteString( const s: string ); virtual;

-    procedure WriteAnsiString( const s: AnsiString); virtual;

-    procedure WriteBinary( const b: TBytes); virtual; abstract;

-

-    function ReadMessageBegin: IMessage; virtual; abstract;

-    procedure ReadMessageEnd(); virtual; abstract;

-    function ReadStructBegin: IStruct; virtual; abstract;

-    procedure ReadStructEnd; virtual; abstract;

-    function ReadFieldBegin: IField; virtual; abstract;

-    procedure ReadFieldEnd(); virtual; abstract;

-    function ReadMapBegin: IMap; virtual; abstract;

-    procedure ReadMapEnd(); virtual; abstract;

-    function ReadListBegin: IList; virtual; abstract;

-    procedure ReadListEnd(); virtual; abstract;

-    function ReadSetBegin: ISet; virtual; abstract;

-    procedure ReadSetEnd(); virtual; abstract;

-    function ReadBool: Boolean; virtual; abstract;

-    function ReadByte: ShortInt; virtual; abstract;

-    function ReadI16: SmallInt; virtual; abstract;

-    function ReadI32: Integer; virtual; abstract;

-    function ReadI64: Int64; virtual; abstract;

-    function ReadDouble:Double; virtual; abstract;

-    function ReadBinary: TBytes; virtual; abstract;

-    function ReadString: string; virtual;

-    function ReadAnsiString: AnsiString; virtual;

-

-    property Transport: ITransport read GetTransport;

-

-    constructor Create( trans: ITransport );

-  end;

-

-  IBase = interface

-    ['{08D9BAA8-5EAA-410F-B50B-AC2E6E5E4155}']

-    function ToString: string;

-    procedure Read( const iprot: IProtocol);

-    procedure Write( const iprot: IProtocol);

-  end;

-

-  IStruct = interface

-    ['{5DCE39AA-C916-4BC7-A79B-96A0C36B2220}']

-    procedure SetName(const Value: string);

-    function GetName: string;

-    property Name: string read GetName write SetName;

-  end;

-

-  TStructImpl = class( TInterfacedObject, IStruct )

-  private

-    FName: string;

-  protected

-    function GetName: string;

-    procedure SetName(const Value: string);

-  public

-    constructor Create( const AName: string);

-  end;

-

-  TBinaryProtocolImpl = class( TProtocolImpl )

-  protected

-    const

-      VERSION_MASK : Cardinal = $ffff0000;

-      VERSION_1 : Cardinal = $80010000;

-  protected

-    FStrictRead : Boolean;

-    FStrictWrite : Boolean;

-

-  private

-    function ReadAll( var buf: TBytes; off: Integer; len: Integer ): Integer;

-    function ReadStringBody( size: Integer): string;

-

-  public

-

-    type

-      TFactory = class( TInterfacedObject, IProtocolFactory)

-      protected

-        FStrictRead : Boolean;

-        FStrictWrite : Boolean;

-      public

-        function GetProtocol( const trans: ITransport): IProtocol;

-        constructor Create( AStrictRead, AStrictWrite: Boolean ); overload;

-        constructor Create; overload;

-      end;

-

-    constructor Create( const trans: ITransport); overload;

-    constructor Create( const trans: ITransport; strictRead: Boolean; strictWrite: Boolean); overload;

-

-    procedure WriteMessageBegin( const msg: IMessage); override;

-    procedure WriteMessageEnd; override;

-    procedure WriteStructBegin( const struc: IStruct); override;

-    procedure WriteStructEnd; override;

-    procedure WriteFieldBegin( const field: IField); override;

-    procedure WriteFieldEnd; override;

-    procedure WriteFieldStop; override;

-    procedure WriteMapBegin( const map: IMap); override;

-    procedure WriteMapEnd; override;

-    procedure WriteListBegin( const list: IList); override;

-    procedure WriteListEnd(); override;

-    procedure WriteSetBegin( const set_: ISet ); override;

-    procedure WriteSetEnd(); override;

-    procedure WriteBool( b: Boolean); override;

-    procedure WriteByte( b: ShortInt); override;

-    procedure WriteI16( i16: SmallInt); override;

-    procedure WriteI32( i32: Integer); override;

-    procedure WriteI64( const i64: Int64); override;

-    procedure WriteDouble( const d: Double); override;

-    procedure WriteBinary( const b: TBytes); override;

-

-    function ReadMessageBegin: IMessage; override;

-    procedure ReadMessageEnd(); override;

-    function ReadStructBegin: IStruct; override;

-    procedure ReadStructEnd; override;

-    function ReadFieldBegin: IField; override;

-    procedure ReadFieldEnd(); override;

-    function ReadMapBegin: IMap; override;

-    procedure ReadMapEnd(); override;

-    function ReadListBegin: IList; override;

-    procedure ReadListEnd(); override;

-    function ReadSetBegin: ISet; override;

-    procedure ReadSetEnd(); override;

-    function ReadBool: Boolean; override;

-    function ReadByte: ShortInt; override;

-    function ReadI16: SmallInt; override;

-    function ReadI32: Integer; override;

-    function ReadI64: Int64; override;

-    function ReadDouble:Double; override;

-    function ReadBinary: TBytes; override;

-

-  end;

-

-

-  { TProtocolDecorator forwards all requests to an enclosed TProtocol instance,

-    providing a way to author concise concrete decorator subclasses. The decorator

-    does not (and should not) modify the behaviour of the enclosed TProtocol

-

-    See p.175 of Design Patterns (by Gamma et al.)

-  }

-  TProtocolDecorator = class( TProtocolImpl)

-  private

-    FWrappedProtocol : IProtocol;

-

-  public

-    // Encloses the specified protocol.

-    // All operations will be forward to the given protocol.  Must be non-null.

-    constructor Create( const aProtocol : IProtocol);

-

-    procedure WriteMessageBegin( const msg: IMessage); override;

-    procedure WriteMessageEnd; override;

-    procedure WriteStructBegin( const struc: IStruct); override;

-    procedure WriteStructEnd; override;

-    procedure WriteFieldBegin( const field: IField); override;

-    procedure WriteFieldEnd; override;

-    procedure WriteFieldStop; override;

-    procedure WriteMapBegin( const map: IMap); override;

-    procedure WriteMapEnd; override;

-    procedure WriteListBegin( const list: IList); override;

-    procedure WriteListEnd(); override;

-    procedure WriteSetBegin( const set_: ISet ); override;

-    procedure WriteSetEnd(); override;

-    procedure WriteBool( b: Boolean); override;

-    procedure WriteByte( b: ShortInt); override;

-    procedure WriteI16( i16: SmallInt); override;

-    procedure WriteI32( i32: Integer); override;

-    procedure WriteI64( const i64: Int64); override;

-    procedure WriteDouble( const d: Double); override;

-    procedure WriteString( const s: string ); override;

-    procedure WriteAnsiString( const s: AnsiString); override;

-    procedure WriteBinary( const b: TBytes); override;

-

-    function ReadMessageBegin: IMessage; override;

-    procedure ReadMessageEnd(); override;

-    function ReadStructBegin: IStruct; override;

-    procedure ReadStructEnd; override;

-    function ReadFieldBegin: IField; override;

-    procedure ReadFieldEnd(); override;

-    function ReadMapBegin: IMap; override;

-    procedure ReadMapEnd(); override;

-    function ReadListBegin: IList; override;

-    procedure ReadListEnd(); override;

-    function ReadSetBegin: ISet; override;

-    procedure ReadSetEnd(); override;

-    function ReadBool: Boolean; override;

-    function ReadByte: ShortInt; override;

-    function ReadI16: SmallInt; override;

-    function ReadI32: Integer; override;

-    function ReadI64: Int64; override;

-    function ReadDouble:Double; override;

-    function ReadBinary: TBytes; override;

-    function ReadString: string; override;

-    function ReadAnsiString: AnsiString; override;

-  end;

-

-

-type

-  IRequestEvents = interface

+(*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *)
+
+{$SCOPEDENUMS ON}
+
+unit Thrift.Protocol;
+
+interface
+
+uses
+  Classes,
+  SysUtils,
+  Contnrs,
+  Thrift.Stream,
+  Thrift.Collections,
+  Thrift.Transport;
+
+type
+
+  TType = (
+    Stop = 0,
+    Void = 1,
+    Bool_ = 2,
+    Byte_ = 3,
+    Double_ = 4,
+    I16 = 6,
+    I32 = 8,
+    I64 = 10,
+    String_ = 11,
+    Struct = 12,
+    Map = 13,
+    Set_ = 14,
+    List = 15
+  );
+
+  TMessageType = (
+    Call = 1,
+    Reply = 2,
+    Exception = 3,
+    Oneway = 4
+  );
+
+  IProtocol = interface;
+  IStruct = interface;
+
+  IProtocolFactory = interface
+    ['{7CD64A10-4E9F-4E99-93BF-708A31F4A67B}']
+    function GetProtocol( const trans: ITransport): IProtocol;
+  end;
+
+  TThriftStringBuilder = class( TStringBuilder)
+  public
+    function Append(const Value: TBytes): TStringBuilder; overload;
+    function Append(const Value: IThriftContainer): TStringBuilder; overload;
+  end;
+
+  TProtocolException = class( Exception )
+  public
+    const // TODO(jensg): change into enum
+      UNKNOWN : Integer = 0;
+      INVALID_DATA : Integer = 1;
+      NEGATIVE_SIZE : Integer = 2;
+      SIZE_LIMIT : Integer = 3;
+      BAD_VERSION : Integer = 4;
+      NOT_IMPLEMENTED : Integer = 5;
+      DEPTH_LIMIT : Integer = 6;
+  protected
+    FType : Integer;
+  public
+    constructor Create; overload;
+    constructor Create( type_: Integer ); overload;
+    constructor Create( type_: Integer; const msg: string); overload;
+  end;
+
+  IMap = interface
+    ['{30531D97-7E06-4233-B800-C3F53CCD23E7}']
+    function GetKeyType: TType;
+    procedure SetKeyType( Value: TType);
+    function GetValueType: TType;
+    procedure SetValueType( Value: TType);
+    function GetCount: Integer;
+    procedure SetCount( Value: Integer);
+    property KeyType: TType read GetKeyType write SetKeyType;
+    property ValueType: TType read GetValueType write SetValueType;
+    property Count: Integer read GetCount write SetCount;
+  end;
+
+  TMapImpl = class( TInterfacedObject, IMap)
+  private
+    FValueType: TType;
+    FKeyType: TType;
+    FCount: Integer;
+  protected
+    function GetKeyType: TType;
+    procedure SetKeyType( Value: TType);
+    function GetValueType: TType;
+    procedure SetValueType( Value: TType);
+    function GetCount: Integer;
+    procedure SetCount( Value: Integer);
+  public
+    constructor Create( AValueType: TType; AKeyType: TType; ACount: Integer); overload;
+    constructor Create; overload;
+  end;
+
+  IList = interface
+    ['{6763E1EA-A934-4472-904F-0083980B9B87}']
+    function GetElementType: TType;
+    procedure SetElementType( Value: TType);
+    function GetCount: Integer;
+    procedure SetCount( Value: Integer);
+    property ElementType: TType read GetElementType write SetElementType;
+    property Count: Integer read GetCount write SetCount;
+  end;
+
+  TListImpl = class( TInterfacedObject, IList)
+  private
+    FElementType: TType;
+    FCount : Integer;
+  protected
+    function GetElementType: TType;
+    procedure SetElementType( Value: TType);
+    function GetCount: Integer;
+    procedure SetCount( Value: Integer);
+  public
+    constructor Create( AElementType: TType; ACount: Integer); overload;
+    constructor Create; overload;
+  end;
+
+  ISet = interface
+    ['{A8671700-7514-4C1E-8A05-62786872005F}']
+    function GetElementType: TType;
+    procedure SetElementType( Value: TType);
+    function GetCount: Integer;
+    procedure SetCount( Value: Integer);
+    property ElementType: TType read GetElementType write SetElementType;
+    property Count: Integer read GetCount write SetCount;
+  end;
+
+  TSetImpl = class( TInterfacedObject, ISet)
+  private
+    FCount: Integer;
+    FElementType: TType;
+  protected
+    function GetElementType: TType;
+    procedure SetElementType( Value: TType);
+    function GetCount: Integer;
+    procedure SetCount( Value: Integer);
+  public
+    constructor Create( AElementType: TType; ACount: Integer); overload;
+    constructor Create; overload;
+  end;
+
+  IMessage = interface
+    ['{9E368B4A-B1FA-43E7-8CF5-56C66D256CA7}']
+    function GetName: string;
+    procedure SetName( const Value: string);
+    function GetType: TMessageType;
+    procedure SetType( Value: TMessageType);
+    function GetSeqID: Integer;
+    procedure SetSeqID( Value: Integer);
+    property Name: string read GetName write SetName;
+    property Type_: TMessageType read GetType write SetType;
+    property SeqID: Integer read GetSeqID write SetSeqID;
+  end;
+
+  TMessageImpl = class( TInterfacedObject, IMessage )
+  private
+    FName: string;
+    FMessageType: TMessageType;
+    FSeqID: Integer;
+  protected
+    function GetName: string;
+    procedure SetName( const Value: string);
+    function GetType: TMessageType;
+    procedure SetType( Value: TMessageType);
+    function GetSeqID: Integer;
+    procedure SetSeqID( Value: Integer);
+  public
+    property Name: string read FName write FName;
+    property Type_: TMessageType read FMessageType write FMessageType;
+    property SeqID: Integer read FSeqID write FSeqID;
+    constructor Create( AName: string; AMessageType: TMessageType; ASeqID: Integer); overload;
+    constructor Create; overload;
+  end;
+
+  IField = interface
+    ['{F0D43BE5-7883-442E-83FF-0580CC632B72}']
+    function GetName: string;
+    procedure SetName( const Value: string);
+    function GetType: TType;
+    procedure SetType( Value: TType);
+    function GetId: SmallInt;
+    procedure SetId( Value: SmallInt);
+    property Name: string read GetName write SetName;
+    property Type_: TType read GetType write SetType;
+    property Id: SmallInt read GetId write SetId;
+  end;
+
+  TFieldImpl = class( TInterfacedObject, IField)
+  private
+    FName : string;
+    FType : TType;
+    FId   : SmallInt;
+  protected
+    function GetName: string;
+    procedure SetName( const Value: string);
+    function GetType: TType;
+    procedure SetType( Value: TType);
+    function GetId: SmallInt;
+    procedure SetId( Value: SmallInt);
+  public
+    constructor Create( const AName: string; const AType: TType; AId: SmallInt); overload;
+    constructor Create; overload;
+  end;
+
+  TProtocolUtil = class
+  public
+    class procedure Skip( prot: IProtocol; type_: TType);
+  end;
+
+  IProtocol = interface
+    ['{FD95C151-1527-4C96-8134-B902BFC4B4FC}']
+    function GetTransport: ITransport;
+    procedure WriteMessageBegin( const msg: IMessage);
+    procedure WriteMessageEnd;
+    procedure WriteStructBegin( const struc: IStruct);
+    procedure WriteStructEnd;
+    procedure WriteFieldBegin( const field: IField);
+    procedure WriteFieldEnd;
+    procedure WriteFieldStop;
+    procedure WriteMapBegin( const map: IMap);
+    procedure WriteMapEnd;
+    procedure WriteListBegin( const list: IList);
+    procedure WriteListEnd();
+    procedure WriteSetBegin( const set_: ISet );
+    procedure WriteSetEnd();
+    procedure WriteBool( b: Boolean);
+    procedure WriteByte( b: ShortInt);
+    procedure WriteI16( i16: SmallInt);
+    procedure WriteI32( i32: Integer);
+    procedure WriteI64( const i64: Int64);
+    procedure WriteDouble( const d: Double);
+    procedure WriteString( const s: string );
+    procedure WriteAnsiString( const s: AnsiString);
+    procedure WriteBinary( const b: TBytes);
+
+    function ReadMessageBegin: IMessage;
+    procedure ReadMessageEnd();
+    function ReadStructBegin: IStruct;
+    procedure ReadStructEnd;
+    function ReadFieldBegin: IField;
+    procedure ReadFieldEnd();
+    function ReadMapBegin: IMap;
+    procedure ReadMapEnd();
+    function ReadListBegin: IList;
+    procedure ReadListEnd();
+    function ReadSetBegin: ISet;
+    procedure ReadSetEnd();
+    function ReadBool: Boolean;
+    function ReadByte: ShortInt;
+    function ReadI16: SmallInt;
+    function ReadI32: Integer;
+    function ReadI64: Int64;
+    function ReadDouble:Double;
+    function ReadBinary: TBytes;
+    function ReadString: string;
+    function ReadAnsiString: AnsiString;
+    property Transport: ITransport read GetTransport;
+  end;
+
+  TProtocolImpl = class abstract( TInterfacedObject, IProtocol)
+  protected
+    FTrans : ITransport;
+    function GetTransport: ITransport;
+  public
+    procedure WriteMessageBegin( const msg: IMessage); virtual; abstract;
+    procedure WriteMessageEnd; virtual; abstract;
+    procedure WriteStructBegin( const struc: IStruct); virtual; abstract;
+    procedure WriteStructEnd; virtual; abstract;
+    procedure WriteFieldBegin( const field: IField); virtual; abstract;
+    procedure WriteFieldEnd; virtual; abstract;
+    procedure WriteFieldStop; virtual; abstract;
+    procedure WriteMapBegin( const map: IMap); virtual; abstract;
+    procedure WriteMapEnd; virtual; abstract;
+    procedure WriteListBegin( const list: IList); virtual; abstract;
+    procedure WriteListEnd(); virtual; abstract;
+    procedure WriteSetBegin( const set_: ISet ); virtual; abstract;
+    procedure WriteSetEnd(); virtual; abstract;
+    procedure WriteBool( b: Boolean); virtual; abstract;
+    procedure WriteByte( b: ShortInt); virtual; abstract;
+    procedure WriteI16( i16: SmallInt); virtual; abstract;
+    procedure WriteI32( i32: Integer); virtual; abstract;
+    procedure WriteI64( const i64: Int64); virtual; abstract;
+    procedure WriteDouble( const d: Double); virtual; abstract;
+    procedure WriteString( const s: string ); virtual;
+    procedure WriteAnsiString( const s: AnsiString); virtual;
+    procedure WriteBinary( const b: TBytes); virtual; abstract;
+
+    function ReadMessageBegin: IMessage; virtual; abstract;
+    procedure ReadMessageEnd(); virtual; abstract;
+    function ReadStructBegin: IStruct; virtual; abstract;
+    procedure ReadStructEnd; virtual; abstract;
+    function ReadFieldBegin: IField; virtual; abstract;
+    procedure ReadFieldEnd(); virtual; abstract;
+    function ReadMapBegin: IMap; virtual; abstract;
+    procedure ReadMapEnd(); virtual; abstract;
+    function ReadListBegin: IList; virtual; abstract;
+    procedure ReadListEnd(); virtual; abstract;
+    function ReadSetBegin: ISet; virtual; abstract;
+    procedure ReadSetEnd(); virtual; abstract;
+    function ReadBool: Boolean; virtual; abstract;
+    function ReadByte: ShortInt; virtual; abstract;
+    function ReadI16: SmallInt; virtual; abstract;
+    function ReadI32: Integer; virtual; abstract;
+    function ReadI64: Int64; virtual; abstract;
+    function ReadDouble:Double; virtual; abstract;
+    function ReadBinary: TBytes; virtual; abstract;
+    function ReadString: string; virtual;
+    function ReadAnsiString: AnsiString; virtual;
+
+    property Transport: ITransport read GetTransport;
+
+    constructor Create( trans: ITransport );
+  end;
+
+  IBase = interface
+    ['{08D9BAA8-5EAA-410F-B50B-AC2E6E5E4155}']
+    function ToString: string;
+    procedure Read( const iprot: IProtocol);
+    procedure Write( const iprot: IProtocol);
+  end;
+
+  IStruct = interface
+    ['{5DCE39AA-C916-4BC7-A79B-96A0C36B2220}']
+    procedure SetName(const Value: string);
+    function GetName: string;
+    property Name: string read GetName write SetName;
+  end;
+
+  TStructImpl = class( TInterfacedObject, IStruct )
+  private
+    FName: string;
+  protected
+    function GetName: string;
+    procedure SetName(const Value: string);
+  public
+    constructor Create( const AName: string);
+  end;
+
+  TBinaryProtocolImpl = class( TProtocolImpl )
+  protected
+    const
+      VERSION_MASK : Cardinal = $ffff0000;
+      VERSION_1 : Cardinal = $80010000;
+  protected
+    FStrictRead : Boolean;
+    FStrictWrite : Boolean;
+
+  private
+    function ReadAll( var buf: TBytes; off: Integer; len: Integer ): Integer;
+    function ReadStringBody( size: Integer): string;
+
+  public
+
+    type
+      TFactory = class( TInterfacedObject, IProtocolFactory)
+      protected
+        FStrictRead : Boolean;
+        FStrictWrite : Boolean;
+      public
+        function GetProtocol( const trans: ITransport): IProtocol;
+        constructor Create( AStrictRead, AStrictWrite: Boolean ); overload;
+        constructor Create; overload;
+      end;
+
+    constructor Create( const trans: ITransport); overload;
+    constructor Create( const trans: ITransport; strictRead: Boolean; strictWrite: Boolean); overload;
+
+    procedure WriteMessageBegin( const msg: IMessage); override;
+    procedure WriteMessageEnd; override;
+    procedure WriteStructBegin( const struc: IStruct); override;
+    procedure WriteStructEnd; override;
+    procedure WriteFieldBegin( const field: IField); override;
+    procedure WriteFieldEnd; override;
+    procedure WriteFieldStop; override;
+    procedure WriteMapBegin( const map: IMap); override;
+    procedure WriteMapEnd; override;
+    procedure WriteListBegin( const list: IList); override;
+    procedure WriteListEnd(); override;
+    procedure WriteSetBegin( const set_: ISet ); override;
+    procedure WriteSetEnd(); override;
+    procedure WriteBool( b: Boolean); override;
+    procedure WriteByte( b: ShortInt); override;
+    procedure WriteI16( i16: SmallInt); override;
+    procedure WriteI32( i32: Integer); override;
+    procedure WriteI64( const i64: Int64); override;
+    procedure WriteDouble( const d: Double); override;
+    procedure WriteBinary( const b: TBytes); override;
+
+    function ReadMessageBegin: IMessage; override;
+    procedure ReadMessageEnd(); override;
+    function ReadStructBegin: IStruct; override;
+    procedure ReadStructEnd; override;
+    function ReadFieldBegin: IField; override;
+    procedure ReadFieldEnd(); override;
+    function ReadMapBegin: IMap; override;
+    procedure ReadMapEnd(); override;
+    function ReadListBegin: IList; override;
+    procedure ReadListEnd(); override;
+    function ReadSetBegin: ISet; override;
+    procedure ReadSetEnd(); override;
+    function ReadBool: Boolean; override;
+    function ReadByte: ShortInt; override;
+    function ReadI16: SmallInt; override;
+    function ReadI32: Integer; override;
+    function ReadI64: Int64; override;
+    function ReadDouble:Double; override;
+    function ReadBinary: TBytes; override;
+
+  end;
+
+
+  { TProtocolDecorator forwards all requests to an enclosed TProtocol instance,
+    providing a way to author concise concrete decorator subclasses. The decorator
+    does not (and should not) modify the behaviour of the enclosed TProtocol
+
+    See p.175 of Design Patterns (by Gamma et al.)
+  }
+  TProtocolDecorator = class( TProtocolImpl)
+  private
+    FWrappedProtocol : IProtocol;
+
+  public
+    // Encloses the specified protocol.
+    // All operations will be forward to the given protocol.  Must be non-null.
+    constructor Create( const aProtocol : IProtocol);
+
+    procedure WriteMessageBegin( const msg: IMessage); override;
+    procedure WriteMessageEnd; override;
+    procedure WriteStructBegin( const struc: IStruct); override;
+    procedure WriteStructEnd; override;
+    procedure WriteFieldBegin( const field: IField); override;
+    procedure WriteFieldEnd; override;
+    procedure WriteFieldStop; override;
+    procedure WriteMapBegin( const map: IMap); override;
+    procedure WriteMapEnd; override;
+    procedure WriteListBegin( const list: IList); override;
+    procedure WriteListEnd(); override;
+    procedure WriteSetBegin( const set_: ISet ); override;
+    procedure WriteSetEnd(); override;
+    procedure WriteBool( b: Boolean); override;
+    procedure WriteByte( b: ShortInt); override;
+    procedure WriteI16( i16: SmallInt); override;
+    procedure WriteI32( i32: Integer); override;
+    procedure WriteI64( const i64: Int64); override;
+    procedure WriteDouble( const d: Double); override;
+    procedure WriteString( const s: string ); override;
+    procedure WriteAnsiString( const s: AnsiString); override;
+    procedure WriteBinary( const b: TBytes); override;
+
+    function ReadMessageBegin: IMessage; override;
+    procedure ReadMessageEnd(); override;
+    function ReadStructBegin: IStruct; override;
+    procedure ReadStructEnd; override;
+    function ReadFieldBegin: IField; override;
+    procedure ReadFieldEnd(); override;
+    function ReadMapBegin: IMap; override;
+    procedure ReadMapEnd(); override;
+    function ReadListBegin: IList; override;
+    procedure ReadListEnd(); override;
+    function ReadSetBegin: ISet; override;
+    procedure ReadSetEnd(); override;
+    function ReadBool: Boolean; override;
+    function ReadByte: ShortInt; override;
+    function ReadI16: SmallInt; override;
+    function ReadI32: Integer; override;
+    function ReadI64: Int64; override;
+    function ReadDouble:Double; override;
+    function ReadBinary: TBytes; override;
+    function ReadString: string; override;
+    function ReadAnsiString: AnsiString; override;
+  end;
+
+
+type
+  IRequestEvents = interface
     ['{F926A26A-5B00-4560-86FA-2CAE3BA73DAF}']
     // Called before reading arguments.
     procedure PreRead;
@@ -534,1052 +534,1052 @@
     function Process( const iprot :IProtocol; const oprot: IProtocol; const events : IProcessorEvents = nil): Boolean;
   end;
 
-

-

-implementation

-

-function ConvertInt64ToDouble( const n: Int64): Double;

-begin

-  ASSERT( SizeOf(n) = SizeOf(Result));

-  System.Move( n, Result, SizeOf(Result));

-end;

-

-function ConvertDoubleToInt64( const d: Double): Int64;

-begin

-  ASSERT( SizeOf(d) = SizeOf(Result));

-  System.Move( d, Result, SizeOf(Result));

-end;

-

-{ TFieldImpl }

-

-constructor TFieldImpl.Create(const AName: string; const AType: TType;

-  AId: SmallInt);

-begin

-  inherited Create;

-  FName := AName;

-  FType := AType;

-  FId := AId;

-end;

-

-constructor TFieldImpl.Create;

-begin

-  inherited Create;

-  FName := '';

-  FType := Low(TType);

-  FId   := 0;

-end;

-

-function TFieldImpl.GetId: SmallInt;

-begin

-  Result := FId;

-end;

-

-function TFieldImpl.GetName: string;

-begin

-  Result := FName;

-end;

-

-function TFieldImpl.GetType: TType;

-begin

-  Result := FType;

-end;

-

-procedure TFieldImpl.SetId(Value: SmallInt);

-begin

-  FId := Value;

-end;

-

-procedure TFieldImpl.SetName(const Value: string);

-begin

-  FName := Value;

-end;

-

-procedure TFieldImpl.SetType(Value: TType);

-begin

-  FType := Value;

-end;

-

-{ TProtocolImpl }

-

-constructor TProtocolImpl.Create(trans: ITransport);

-begin

-  inherited Create;

-  FTrans := trans;

-end;

-

-function TProtocolImpl.GetTransport: ITransport;

-begin

-  Result := FTrans;

-end;

-

-function TProtocolImpl.ReadAnsiString: AnsiString;

-var

-  b : TBytes;

-  len : Integer;

-begin

-  Result := '';

-  b := ReadBinary;

-  len := Length( b );

-  if len > 0 then

-  begin

-    SetLength( Result, len);

-    System.Move( b[0], Pointer(Result)^, len );

-  end;

-end;

-

-function TProtocolImpl.ReadString: string;

-begin

-  Result := TEncoding.UTF8.GetString( ReadBinary );

-end;

-

-procedure TProtocolImpl.WriteAnsiString(const s: AnsiString);

-var

-  b : TBytes;

-  len : Integer;

-begin

-  len := Length(s);

-  SetLength( b, len);

-  if len > 0 then

-  begin

-    System.Move( Pointer(s)^, b[0], len );

-  end;

-  WriteBinary( b );

-end;

-

-procedure TProtocolImpl.WriteString(const s: string);

-var

-  b : TBytes;

-begin

-  b := TEncoding.UTF8.GetBytes(s);

-  WriteBinary( b );

-end;

-

-{ TProtocolUtil }

-

-class procedure TProtocolUtil.Skip( prot: IProtocol; type_: TType);

-var field : IField;

-    map   : IMap;

-    set_  : ISet;

-    list  : IList;

-    i     : Integer;

-begin

-  case type_ of

-    // simple types

-    TType.Bool_   :  prot.ReadBool();

-    TType.Byte_   :  prot.ReadByte();

-    TType.I16     :  prot.ReadI16();

-    TType.I32     :  prot.ReadI32();

-    TType.I64     :  prot.ReadI64();

-    TType.Double_ :  prot.ReadDouble();

-    TType.String_ :  prot.ReadBinary();// Don't try to decode the string, just skip it.

-

-    // structured types

-    TType.Struct :  begin

-      prot.ReadStructBegin();

-      while TRUE do begin

-        field := prot.ReadFieldBegin();

-        if (field.Type_ = TType.Stop) then Break;

-        Skip(prot, field.Type_);

-        prot.ReadFieldEnd();

-      end;

-      prot.ReadStructEnd();

-    end;

-

-    TType.Map :  begin

-      map := prot.ReadMapBegin();

-      for i := 0 to map.Count-1 do begin

-        Skip(prot, map.KeyType);

-        Skip(prot, map.ValueType);

-      end;

-      prot.ReadMapEnd();

-    end;

-

-    TType.Set_ :  begin

-      set_ := prot.ReadSetBegin();

-      for i := 0 to set_.Count-1

-      do Skip( prot, set_.ElementType);

-      prot.ReadSetEnd();

-    end;

-

-    TType.List :  begin

-      list := prot.ReadListBegin();

-      for i := 0 to list.Count-1

-      do Skip( prot, list.ElementType);

-      prot.ReadListEnd();

-    end;

-

-  else

-    ASSERT( FALSE); // any new types?

-  end;

-end;

-

-{ TStructImpl }

-

-constructor TStructImpl.Create(const AName: string);

-begin

-  inherited Create;

-  FName := AName;

-end;

-

-function TStructImpl.GetName: string;

-begin

-  Result := FName;

-end;

-

-procedure TStructImpl.SetName(const Value: string);

-begin

-  FName := Value;

-end;

-

-{ TMapImpl }

-

-constructor TMapImpl.Create(AValueType, AKeyType: TType; ACount: Integer);

-begin

-  inherited Create;

-  FValueType := AValueType;

-  FKeyType := AKeyType;

-  FCount := ACount;

-end;

-

-constructor TMapImpl.Create;

-begin

-  inherited Create;

-end;

-

-function TMapImpl.GetCount: Integer;

-begin

-  Result := FCount;

-end;

-

-function TMapImpl.GetKeyType: TType;

-begin

-  Result := FKeyType;

-end;

-

-function TMapImpl.GetValueType: TType;

-begin

-  Result := FValueType;

-end;

-

-procedure TMapImpl.SetCount(Value: Integer);

-begin

-  FCount := Value;

-end;

-

-procedure TMapImpl.SetKeyType(Value: TType);

-begin

-  FKeyType := Value;

-end;

-

-procedure TMapImpl.SetValueType(Value: TType);

-begin

-  FValueType := Value;

-end;

-

-{ IMessage }

-

-constructor TMessageImpl.Create(AName: string; AMessageType: TMessageType;

-  ASeqID: Integer);

-begin

-  inherited Create;

-  FName := AName;

-  FMessageType := AMessageType;

-  FSeqID := ASeqID;

-end;

-

-constructor TMessageImpl.Create;

-begin

-  inherited;

-end;

-

-function TMessageImpl.GetName: string;

-begin

-  Result := FName;

-end;

-

-function TMessageImpl.GetSeqID: Integer;

-begin

-  Result := FSeqID;

-end;

-

-function TMessageImpl.GetType: TMessageType;

-begin

-  Result := FMessageType;

-end;

-

-procedure TMessageImpl.SetName(const Value: string);

-begin

-  FName := Value;

-end;

-

-procedure TMessageImpl.SetSeqID(Value: Integer);

-begin

-  FSeqID := Value;

-end;

-

-procedure TMessageImpl.SetType(Value: TMessageType);

-begin

-  FMessageType := Value;

-end;

-

-{ ISet }

-

-constructor TSetImpl.Create( AElementType: TType; ACount: Integer);

-begin

-  inherited Create;

-  FCount := ACount;

-  FElementType := AElementType;

-end;

-

-constructor TSetImpl.Create;

-begin

-  inherited Create;

-end;

-

-function TSetImpl.GetCount: Integer;

-begin

-  Result := FCount;

-end;

-

-function TSetImpl.GetElementType: TType;

-begin

-  Result := FElementType;

-end;

-

-procedure TSetImpl.SetCount(Value: Integer);

-begin

-  FCount := Value;

-end;

-

-procedure TSetImpl.SetElementType(Value: TType);

-begin

-  FElementType := Value;

-end;

-

-{ IList }

-

-constructor TListImpl.Create( AElementType: TType; ACount: Integer);

-begin

-  inherited Create;

-  FCount := ACount;

-  FElementType := AElementType;

-end;

-

-constructor TListImpl.Create;

-begin

-  inherited Create;

-end;

-

-function TListImpl.GetCount: Integer;

-begin

-  Result := FCount;

-end;

-

-function TListImpl.GetElementType: TType;

-begin

-  Result := FElementType;

-end;

-

-procedure TListImpl.SetCount(Value: Integer);

-begin

-  FCount := Value;

-end;

-

-procedure TListImpl.SetElementType(Value: TType);

-begin

-  FElementType := Value;

-end;

-

-{ TBinaryProtocolImpl }

-

-constructor TBinaryProtocolImpl.Create( const trans: ITransport);

-begin

-  //no inherited

-  Create( trans, False, True);

-end;

-

-constructor TBinaryProtocolImpl.Create( const trans: ITransport; strictRead,

-  strictWrite: Boolean);

-begin

-  inherited Create( trans );

-  FStrictRead := strictRead;

-  FStrictWrite := strictWrite;

-end;

-

-function TBinaryProtocolImpl.ReadAll( var buf: TBytes; off,

-  len: Integer): Integer;

-begin

-  Result := FTrans.ReadAll( buf, off, len );

-end;

-

-function TBinaryProtocolImpl.ReadBinary: TBytes;

-var

-  size : Integer;

-  buf : TBytes;

-begin

-  size := ReadI32;

-  SetLength( buf, size );

-  FTrans.ReadAll( buf, 0, size);

-  Result := buf;

-end;

-

-function TBinaryProtocolImpl.ReadBool: Boolean;

-begin

-  Result := ReadByte = 1;

-end;

-

-function TBinaryProtocolImpl.ReadByte: ShortInt;

-var

-  bin : TBytes;

-begin

-  SetLength( bin, 1);

-  ReadAll( bin, 0, 1 );

-  Result := ShortInt( bin[0]);

-end;

-

-function TBinaryProtocolImpl.ReadDouble: Double;

-begin

-  Result := ConvertInt64ToDouble( ReadI64 )

-end;

-

-function TBinaryProtocolImpl.ReadFieldBegin: IField;

-var

-  field : IField;

-begin

-  field := TFieldImpl.Create;

-  field.Type_ := TType( ReadByte);

-  if ( field.Type_ <> TType.Stop ) then

-  begin

-    field.Id := ReadI16;

-  end;

-  Result := field;

-end;

-

-procedure TBinaryProtocolImpl.ReadFieldEnd;

-begin

-

-end;

-

-function TBinaryProtocolImpl.ReadI16: SmallInt;

-var

-  i16in : TBytes;

-begin

-  SetLength( i16in, 2 );

-  ReadAll( i16in, 0, 2);

-  Result := SmallInt(((i16in[0] and $FF) shl 8) or (i16in[1] and $FF));

-end;

-

-function TBinaryProtocolImpl.ReadI32: Integer;

-var

-  i32in : TBytes;

-begin

-  SetLength( i32in, 4 );

-  ReadAll( i32in, 0, 4);

-

-  Result := Integer(

-    ((i32in[0] and $FF) shl 24) or

-    ((i32in[1] and $FF) shl 16) or

-    ((i32in[2] and $FF) shl 8) or

-     (i32in[3] and $FF));

-

-end;

-

-function TBinaryProtocolImpl.ReadI64: Int64;

-var

-  i64in : TBytes;

-begin

-  SetLength( i64in, 8);

-  ReadAll( i64in, 0, 8);

-  Result :=

-    (Int64( i64in[0] and $FF) shl 56) or

-    (Int64( i64in[1] and $FF) shl 48) or

-    (Int64( i64in[2] and $FF) shl 40) or

-    (Int64( i64in[3] and $FF) shl 32) or

-    (Int64( i64in[4] and $FF) shl 24) or

-    (Int64( i64in[5] and $FF) shl 16) or

-    (Int64( i64in[6] and $FF) shl 8) or

-    (Int64( i64in[7] and $FF));

-end;

-

-function TBinaryProtocolImpl.ReadListBegin: IList;

-var

-  list : IList;

-begin

-  list := TListImpl.Create;

-  list.ElementType := TType( ReadByte );

-  list.Count := ReadI32;

-  Result := list;

-end;

-

-procedure TBinaryProtocolImpl.ReadListEnd;

-begin

-

-end;

-

-function TBinaryProtocolImpl.ReadMapBegin: IMap;

-var

-  map : IMap;

-begin

-  map := TMapImpl.Create;

-  map.KeyType := TType( ReadByte );

-  map.ValueType := TType( ReadByte );

-  map.Count := ReadI32;

-  Result := map;

-end;

-

-procedure TBinaryProtocolImpl.ReadMapEnd;

-begin

-

-end;

-

-function TBinaryProtocolImpl.ReadMessageBegin: IMessage;

-var

-  size : Integer;

-  version : Integer;

-  message : IMessage;

-begin

-  message := TMessageImpl.Create;

-  size := ReadI32;

-  if (size < 0) then

-  begin

-    version := size and Integer( VERSION_MASK);

-    if ( version <> Integer( VERSION_1)) then

-    begin

-      raise TProtocolException.Create(TProtocolException.BAD_VERSION, 'Bad version in ReadMessageBegin: ' + IntToStr(version) );

-    end;

-    message.Type_ := TMessageType( size and $000000ff);

-    message.Name := ReadString;

-    message.SeqID := ReadI32;

-  end else

-  begin

-    if FStrictRead then

-    begin

-      raise TProtocolException.Create( TProtocolException.BAD_VERSION, 'Missing version in readMessageBegin, old client?' );

-    end;

-    message.Name := ReadStringBody( size );

-    message.Type_ := TMessageType( ReadByte );

-    message.SeqID := ReadI32;

-  end;

-  Result := message;

-end;

-

-procedure TBinaryProtocolImpl.ReadMessageEnd;

-begin

-  inherited;

-

-end;

-

-function TBinaryProtocolImpl.ReadSetBegin: ISet;

-var

-  set_ : ISet;

-begin

-  set_ := TSetImpl.Create;

-  set_.ElementType := TType( ReadByte );

-  set_.Count := ReadI32;

-  Result := set_;

-end;

-

-procedure TBinaryProtocolImpl.ReadSetEnd;

-begin

-

-end;

-

-function TBinaryProtocolImpl.ReadStringBody( size: Integer): string;

-var

-  buf : TBytes;

-begin

-  SetLength( buf, size );

-  FTrans.ReadAll( buf, 0, size );

-  Result := TEncoding.UTF8.GetString( buf);

-end;

-

-function TBinaryProtocolImpl.ReadStructBegin: IStruct;

-begin

-  Result := TStructImpl.Create('');

-end;

-

-procedure TBinaryProtocolImpl.ReadStructEnd;

-begin

-  inherited;

-

-end;

-

-procedure TBinaryProtocolImpl.WriteBinary( const b: TBytes);

-var iLen : Integer;

-begin

-  iLen := Length(b);

-  WriteI32( iLen);

-  if iLen > 0 then FTrans.Write(b, 0, iLen);

-end;

-

-procedure TBinaryProtocolImpl.WriteBool(b: Boolean);

-begin

-  if b then

-  begin

-    WriteByte( 1 );

-  end else

-  begin

-    WriteByte( 0 );

-  end;

-end;

-

-procedure TBinaryProtocolImpl.WriteByte(b: ShortInt);

-var

-  a : TBytes;

-begin

-  SetLength( a, 1);

-  a[0] := Byte( b );

-  FTrans.Write( a, 0, 1 );

-end;

-

-procedure TBinaryProtocolImpl.WriteDouble( const d: Double);

-begin

-  WriteI64(ConvertDoubleToInt64(d));

-end;

-

-procedure TBinaryProtocolImpl.WriteFieldBegin( const field: IField);

-begin

-  WriteByte(ShortInt(field.Type_));

-  WriteI16(field.ID);

-end;

-

-procedure TBinaryProtocolImpl.WriteFieldEnd;

-begin

-

-end;

-

-procedure TBinaryProtocolImpl.WriteFieldStop;

-begin

-  WriteByte(ShortInt(TType.Stop));

-end;

-

-procedure TBinaryProtocolImpl.WriteI16(i16: SmallInt);

-var

-  i16out : TBytes;

-begin

-  SetLength( i16out, 2);

-  i16out[0] := Byte($FF and (i16 shr 8));

-  i16out[1] := Byte($FF and i16);

-  FTrans.Write( i16out );

-end;

-

-procedure TBinaryProtocolImpl.WriteI32(i32: Integer);

-var

-  i32out : TBytes;

-begin

-  SetLength( i32out, 4);

-  i32out[0] := Byte($FF and (i32 shr 24));

-  i32out[1] := Byte($FF and (i32 shr 16));

-  i32out[2] := Byte($FF and (i32 shr 8));

-  i32out[3] := Byte($FF and i32);

-  FTrans.Write( i32out, 0, 4);

-end;

-

-procedure TBinaryProtocolImpl.WriteI64( const i64: Int64);

-var

-  i64out : TBytes;

-begin

-  SetLength( i64out, 8);

-  i64out[0] := Byte($FF and (i64 shr 56));

-  i64out[1] := Byte($FF and (i64 shr 48));

-  i64out[2] := Byte($FF and (i64 shr 40));

-  i64out[3] := Byte($FF and (i64 shr 32));

-  i64out[4] := Byte($FF and (i64 shr 24));

-  i64out[5] := Byte($FF and (i64 shr 16));

-  i64out[6] := Byte($FF and (i64 shr 8));

-  i64out[7] := Byte($FF and i64);

-  FTrans.Write( i64out, 0, 8);

-end;

-

-procedure TBinaryProtocolImpl.WriteListBegin( const list: IList);

-begin

-  WriteByte(ShortInt(list.ElementType));

-  WriteI32(list.Count);

-end;

-

-procedure TBinaryProtocolImpl.WriteListEnd;

-begin

-

-end;

-

-procedure TBinaryProtocolImpl.WriteMapBegin( const map: IMap);

-begin

-  WriteByte(ShortInt(map.KeyType));

-  WriteByte(ShortInt(map.ValueType));

-  WriteI32(map.Count);

-end;

-

-procedure TBinaryProtocolImpl.WriteMapEnd;

-begin

-

-end;

-

-procedure TBinaryProtocolImpl.WriteMessageBegin( const msg: IMessage);

-var

-  version : Cardinal;

-begin

-  if FStrictWrite then

-  begin

-    version := VERSION_1 or Cardinal( msg.Type_);

-    WriteI32( Integer( version) );

-    WriteString( msg.Name);

-    WriteI32( msg.SeqID);

-  end else

-  begin

-    WriteString( msg.Name);

-    WriteByte(ShortInt( msg.Type_));

-    WriteI32( msg.SeqID);

-  end;

-end;

-

-procedure TBinaryProtocolImpl.WriteMessageEnd;

-begin

-

-end;

-

-procedure TBinaryProtocolImpl.WriteSetBegin( const set_: ISet);

-begin

-  WriteByte(ShortInt(set_.ElementType));

-  WriteI32(set_.Count);

-end;

-

-procedure TBinaryProtocolImpl.WriteSetEnd;

-begin

-

-end;

-

-procedure TBinaryProtocolImpl.WriteStructBegin( const struc: IStruct);

-begin

-

-end;

-

-procedure TBinaryProtocolImpl.WriteStructEnd;

-begin

-

-end;

-

-{ TProtocolException }

-

-constructor TProtocolException.Create;

-begin

-  inherited Create('');

-  FType := UNKNOWN;

-end;

-

-constructor TProtocolException.Create(type_: Integer);

-begin

-  inherited Create('');

-  FType := type_;

-end;

-

-constructor TProtocolException.Create(type_: Integer; const msg: string);

-begin

-  inherited Create( msg );

-  FType := type_;

-end;

-

-{ TThriftStringBuilder }

-

-function TThriftStringBuilder.Append(const Value: TBytes): TStringBuilder;

-begin

-  Result := Append( string( RawByteString(Value)) );

-end;

-

-function TThriftStringBuilder.Append(

-  const Value: IThriftContainer): TStringBuilder;

-begin

-  Result := Append( Value.ToString );

-end;

-

-{ TBinaryProtocolImpl.TFactory }

-

-constructor TBinaryProtocolImpl.TFactory.Create(AStrictRead, AStrictWrite: Boolean);

-begin

-  inherited Create;

-  FStrictRead := AStrictRead;

-  FStrictWrite := AStrictWrite;

-end;

-

-constructor TBinaryProtocolImpl.TFactory.Create;

-begin

-  //no inherited;  

-  Create( False, True )

-end;

-

-function TBinaryProtocolImpl.TFactory.GetProtocol( const trans: ITransport): IProtocol;

-begin

-  Result := TBinaryProtocolImpl.Create( trans, FStrictRead, FStrictWrite);

-end;

-

-

-{ TProtocolDecorator }

-

-constructor TProtocolDecorator.Create( const aProtocol : IProtocol);

-begin

-  ASSERT( aProtocol <> nil);

-  inherited Create( aProtocol.Transport);

-  FWrappedProtocol := aProtocol;

-end;

-

-

-procedure TProtocolDecorator.WriteMessageBegin( const msg: IMessage);

-begin

-  FWrappedProtocol.WriteMessageBegin( msg);

-end;

-

-

-procedure TProtocolDecorator.WriteMessageEnd;

-begin

-  FWrappedProtocol.WriteMessageEnd;

-end;

-

-

-procedure TProtocolDecorator.WriteStructBegin( const struc: IStruct);

-begin

-  FWrappedProtocol.WriteStructBegin( struc);

-end;

-

-

-procedure TProtocolDecorator.WriteStructEnd;

-begin

-  FWrappedProtocol.WriteStructEnd;

-end;

-

-

-procedure TProtocolDecorator.WriteFieldBegin( const field: IField);

-begin

-  FWrappedProtocol.WriteFieldBegin( field);

-end;

-

-

-procedure TProtocolDecorator.WriteFieldEnd;

-begin

-  FWrappedProtocol.WriteFieldEnd;

-end;

-

-

-procedure TProtocolDecorator.WriteFieldStop;

-begin

-  FWrappedProtocol.WriteFieldStop;

-end;

-

-

-procedure TProtocolDecorator.WriteMapBegin( const map: IMap);

-begin

-  FWrappedProtocol.WriteMapBegin( map);

-end;

-

-

-procedure TProtocolDecorator.WriteMapEnd;

-begin

-  FWrappedProtocol.WriteMapEnd;

-end;

-

-

-procedure TProtocolDecorator.WriteListBegin( const list: IList);

-begin

-  FWrappedProtocol.WriteListBegin( list);

-end;

-

-

-procedure TProtocolDecorator.WriteListEnd();

-begin

-  FWrappedProtocol.WriteListEnd();

-end;

-

-

-procedure TProtocolDecorator.WriteSetBegin( const set_: ISet );

-begin

-  FWrappedProtocol.WriteSetBegin( set_);

-end;

-

-

-procedure TProtocolDecorator.WriteSetEnd();

-begin

-  FWrappedProtocol.WriteSetEnd();

-end;

-

-

-procedure TProtocolDecorator.WriteBool( b: Boolean);

-begin

-  FWrappedProtocol.WriteBool( b);

-end;

-

-

-procedure TProtocolDecorator.WriteByte( b: ShortInt);

-begin

-  FWrappedProtocol.WriteByte( b);

-end;

-

-

-procedure TProtocolDecorator.WriteI16( i16: SmallInt);

-begin

-  FWrappedProtocol.WriteI16( i16);

-end;

-

-

-procedure TProtocolDecorator.WriteI32( i32: Integer);

-begin

-  FWrappedProtocol.WriteI32( i32);

-end;

-

-

-procedure TProtocolDecorator.WriteI64( const i64: Int64);

-begin

-  FWrappedProtocol.WriteI64( i64);

-end;

-

-

-procedure TProtocolDecorator.WriteDouble( const d: Double);

-begin

-  FWrappedProtocol.WriteDouble( d);

-end;

-

-

-procedure TProtocolDecorator.WriteString( const s: string );

-begin

-  FWrappedProtocol.WriteString( s);

-end;

-

-

-procedure TProtocolDecorator.WriteAnsiString( const s: AnsiString);

-begin

-  FWrappedProtocol.WriteAnsiString( s);

-end;

-

-

-procedure TProtocolDecorator.WriteBinary( const b: TBytes);

-begin

-  FWrappedProtocol.WriteBinary( b);

-end;

-

-

-function TProtocolDecorator.ReadMessageBegin: IMessage;

-begin

-  result := FWrappedProtocol.ReadMessageBegin;

-end;

-

-

-procedure TProtocolDecorator.ReadMessageEnd();

-begin

-  FWrappedProtocol.ReadMessageEnd();

-end;

-

-

-function TProtocolDecorator.ReadStructBegin: IStruct;

-begin

-  result := FWrappedProtocol.ReadStructBegin;

-end;

-

-

-procedure TProtocolDecorator.ReadStructEnd;

-begin

-  FWrappedProtocol.ReadStructEnd;

-end;

-

-

-function TProtocolDecorator.ReadFieldBegin: IField;

-begin

-  result := FWrappedProtocol.ReadFieldBegin;

-end;

-

-

-procedure TProtocolDecorator.ReadFieldEnd();

-begin

-  FWrappedProtocol.ReadFieldEnd();

-end;

-

-

-function TProtocolDecorator.ReadMapBegin: IMap;

-begin

-  result := FWrappedProtocol.ReadMapBegin;

-end;

-

-

-procedure TProtocolDecorator.ReadMapEnd();

-begin

-  FWrappedProtocol.ReadMapEnd();

-end;

-

-

-function TProtocolDecorator.ReadListBegin: IList;

-begin

-  result := FWrappedProtocol.ReadListBegin;

-end;

-

-

-procedure TProtocolDecorator.ReadListEnd();

-begin

-  FWrappedProtocol.ReadListEnd();

-end;

-

-

-function TProtocolDecorator.ReadSetBegin: ISet;

-begin

-  result := FWrappedProtocol.ReadSetBegin;

-end;

-

-

-procedure TProtocolDecorator.ReadSetEnd();

-begin

-  FWrappedProtocol.ReadSetEnd();

-end;

-

-

-function TProtocolDecorator.ReadBool: Boolean;

-begin

-  result := FWrappedProtocol.ReadBool;

-end;

-

-

-function TProtocolDecorator.ReadByte: ShortInt;

-begin

-  result := FWrappedProtocol.ReadByte;

-end;

-

-

-function TProtocolDecorator.ReadI16: SmallInt;

-begin

-  result := FWrappedProtocol.ReadI16;

-end;

-

-

-function TProtocolDecorator.ReadI32: Integer;

-begin

-  result := FWrappedProtocol.ReadI32;

-end;

-

-

-function TProtocolDecorator.ReadI64: Int64;

-begin

-  result := FWrappedProtocol.ReadI64;

-end;

-

-

-function TProtocolDecorator.ReadDouble:Double;

-begin

-  result := FWrappedProtocol.ReadDouble;

-end;

-

-

-function TProtocolDecorator.ReadBinary: TBytes;

-begin

-  result := FWrappedProtocol.ReadBinary;

-end;

-

-

-function TProtocolDecorator.ReadString: string;

-begin

-  result := FWrappedProtocol.ReadString;

-end;

-

-

-function TProtocolDecorator.ReadAnsiString: AnsiString;

-begin

-  result := FWrappedProtocol.ReadAnsiString;

-end;

-

-

-

-end.

-

+
+
+implementation
+
+function ConvertInt64ToDouble( const n: Int64): Double;
+begin
+  ASSERT( SizeOf(n) = SizeOf(Result));
+  System.Move( n, Result, SizeOf(Result));
+end;
+
+function ConvertDoubleToInt64( const d: Double): Int64;
+begin
+  ASSERT( SizeOf(d) = SizeOf(Result));
+  System.Move( d, Result, SizeOf(Result));
+end;
+
+{ TFieldImpl }
+
+constructor TFieldImpl.Create(const AName: string; const AType: TType;
+  AId: SmallInt);
+begin
+  inherited Create;
+  FName := AName;
+  FType := AType;
+  FId := AId;
+end;
+
+constructor TFieldImpl.Create;
+begin
+  inherited Create;
+  FName := '';
+  FType := Low(TType);
+  FId   := 0;
+end;
+
+function TFieldImpl.GetId: SmallInt;
+begin
+  Result := FId;
+end;
+
+function TFieldImpl.GetName: string;
+begin
+  Result := FName;
+end;
+
+function TFieldImpl.GetType: TType;
+begin
+  Result := FType;
+end;
+
+procedure TFieldImpl.SetId(Value: SmallInt);
+begin
+  FId := Value;
+end;
+
+procedure TFieldImpl.SetName(const Value: string);
+begin
+  FName := Value;
+end;
+
+procedure TFieldImpl.SetType(Value: TType);
+begin
+  FType := Value;
+end;
+
+{ TProtocolImpl }
+
+constructor TProtocolImpl.Create(trans: ITransport);
+begin
+  inherited Create;
+  FTrans := trans;
+end;
+
+function TProtocolImpl.GetTransport: ITransport;
+begin
+  Result := FTrans;
+end;
+
+function TProtocolImpl.ReadAnsiString: AnsiString;
+var
+  b : TBytes;
+  len : Integer;
+begin
+  Result := '';
+  b := ReadBinary;
+  len := Length( b );
+  if len > 0 then
+  begin
+    SetLength( Result, len);
+    System.Move( b[0], Pointer(Result)^, len );
+  end;
+end;
+
+function TProtocolImpl.ReadString: string;
+begin
+  Result := TEncoding.UTF8.GetString( ReadBinary );
+end;
+
+procedure TProtocolImpl.WriteAnsiString(const s: AnsiString);
+var
+  b : TBytes;
+  len : Integer;
+begin
+  len := Length(s);
+  SetLength( b, len);
+  if len > 0 then
+  begin
+    System.Move( Pointer(s)^, b[0], len );
+  end;
+  WriteBinary( b );
+end;
+
+procedure TProtocolImpl.WriteString(const s: string);
+var
+  b : TBytes;
+begin
+  b := TEncoding.UTF8.GetBytes(s);
+  WriteBinary( b );
+end;
+
+{ TProtocolUtil }
+
+class procedure TProtocolUtil.Skip( prot: IProtocol; type_: TType);
+var field : IField;
+    map   : IMap;
+    set_  : ISet;
+    list  : IList;
+    i     : Integer;
+begin
+  case type_ of
+    // simple types
+    TType.Bool_   :  prot.ReadBool();
+    TType.Byte_   :  prot.ReadByte();
+    TType.I16     :  prot.ReadI16();
+    TType.I32     :  prot.ReadI32();
+    TType.I64     :  prot.ReadI64();
+    TType.Double_ :  prot.ReadDouble();
+    TType.String_ :  prot.ReadBinary();// Don't try to decode the string, just skip it.
+
+    // structured types
+    TType.Struct :  begin
+      prot.ReadStructBegin();
+      while TRUE do begin
+        field := prot.ReadFieldBegin();
+        if (field.Type_ = TType.Stop) then Break;
+        Skip(prot, field.Type_);
+        prot.ReadFieldEnd();
+      end;
+      prot.ReadStructEnd();
+    end;
+
+    TType.Map :  begin
+      map := prot.ReadMapBegin();
+      for i := 0 to map.Count-1 do begin
+        Skip(prot, map.KeyType);
+        Skip(prot, map.ValueType);
+      end;
+      prot.ReadMapEnd();
+    end;
+
+    TType.Set_ :  begin
+      set_ := prot.ReadSetBegin();
+      for i := 0 to set_.Count-1
+      do Skip( prot, set_.ElementType);
+      prot.ReadSetEnd();
+    end;
+
+    TType.List :  begin
+      list := prot.ReadListBegin();
+      for i := 0 to list.Count-1
+      do Skip( prot, list.ElementType);
+      prot.ReadListEnd();
+    end;
+
+  else
+    ASSERT( FALSE); // any new types?
+  end;
+end;
+
+{ TStructImpl }
+
+constructor TStructImpl.Create(const AName: string);
+begin
+  inherited Create;
+  FName := AName;
+end;
+
+function TStructImpl.GetName: string;
+begin
+  Result := FName;
+end;
+
+procedure TStructImpl.SetName(const Value: string);
+begin
+  FName := Value;
+end;
+
+{ TMapImpl }
+
+constructor TMapImpl.Create(AValueType, AKeyType: TType; ACount: Integer);
+begin
+  inherited Create;
+  FValueType := AValueType;
+  FKeyType := AKeyType;
+  FCount := ACount;
+end;
+
+constructor TMapImpl.Create;
+begin
+  inherited Create;
+end;
+
+function TMapImpl.GetCount: Integer;
+begin
+  Result := FCount;
+end;
+
+function TMapImpl.GetKeyType: TType;
+begin
+  Result := FKeyType;
+end;
+
+function TMapImpl.GetValueType: TType;
+begin
+  Result := FValueType;
+end;
+
+procedure TMapImpl.SetCount(Value: Integer);
+begin
+  FCount := Value;
+end;
+
+procedure TMapImpl.SetKeyType(Value: TType);
+begin
+  FKeyType := Value;
+end;
+
+procedure TMapImpl.SetValueType(Value: TType);
+begin
+  FValueType := Value;
+end;
+
+{ IMessage }
+
+constructor TMessageImpl.Create(AName: string; AMessageType: TMessageType;
+  ASeqID: Integer);
+begin
+  inherited Create;
+  FName := AName;
+  FMessageType := AMessageType;
+  FSeqID := ASeqID;
+end;
+
+constructor TMessageImpl.Create;
+begin
+  inherited;
+end;
+
+function TMessageImpl.GetName: string;
+begin
+  Result := FName;
+end;
+
+function TMessageImpl.GetSeqID: Integer;
+begin
+  Result := FSeqID;
+end;
+
+function TMessageImpl.GetType: TMessageType;
+begin
+  Result := FMessageType;
+end;
+
+procedure TMessageImpl.SetName(const Value: string);
+begin
+  FName := Value;
+end;
+
+procedure TMessageImpl.SetSeqID(Value: Integer);
+begin
+  FSeqID := Value;
+end;
+
+procedure TMessageImpl.SetType(Value: TMessageType);
+begin
+  FMessageType := Value;
+end;
+
+{ ISet }
+
+constructor TSetImpl.Create( AElementType: TType; ACount: Integer);
+begin
+  inherited Create;
+  FCount := ACount;
+  FElementType := AElementType;
+end;
+
+constructor TSetImpl.Create;
+begin
+  inherited Create;
+end;
+
+function TSetImpl.GetCount: Integer;
+begin
+  Result := FCount;
+end;
+
+function TSetImpl.GetElementType: TType;
+begin
+  Result := FElementType;
+end;
+
+procedure TSetImpl.SetCount(Value: Integer);
+begin
+  FCount := Value;
+end;
+
+procedure TSetImpl.SetElementType(Value: TType);
+begin
+  FElementType := Value;
+end;
+
+{ IList }
+
+constructor TListImpl.Create( AElementType: TType; ACount: Integer);
+begin
+  inherited Create;
+  FCount := ACount;
+  FElementType := AElementType;
+end;
+
+constructor TListImpl.Create;
+begin
+  inherited Create;
+end;
+
+function TListImpl.GetCount: Integer;
+begin
+  Result := FCount;
+end;
+
+function TListImpl.GetElementType: TType;
+begin
+  Result := FElementType;
+end;
+
+procedure TListImpl.SetCount(Value: Integer);
+begin
+  FCount := Value;
+end;
+
+procedure TListImpl.SetElementType(Value: TType);
+begin
+  FElementType := Value;
+end;
+
+{ TBinaryProtocolImpl }
+
+constructor TBinaryProtocolImpl.Create( const trans: ITransport);
+begin
+  //no inherited
+  Create( trans, False, True);
+end;
+
+constructor TBinaryProtocolImpl.Create( const trans: ITransport; strictRead,
+  strictWrite: Boolean);
+begin
+  inherited Create( trans );
+  FStrictRead := strictRead;
+  FStrictWrite := strictWrite;
+end;
+
+function TBinaryProtocolImpl.ReadAll( var buf: TBytes; off,
+  len: Integer): Integer;
+begin
+  Result := FTrans.ReadAll( buf, off, len );
+end;
+
+function TBinaryProtocolImpl.ReadBinary: TBytes;
+var
+  size : Integer;
+  buf : TBytes;
+begin
+  size := ReadI32;
+  SetLength( buf, size );
+  FTrans.ReadAll( buf, 0, size);
+  Result := buf;
+end;
+
+function TBinaryProtocolImpl.ReadBool: Boolean;
+begin
+  Result := ReadByte = 1;
+end;
+
+function TBinaryProtocolImpl.ReadByte: ShortInt;
+var
+  bin : TBytes;
+begin
+  SetLength( bin, 1);
+  ReadAll( bin, 0, 1 );
+  Result := ShortInt( bin[0]);
+end;
+
+function TBinaryProtocolImpl.ReadDouble: Double;
+begin
+  Result := ConvertInt64ToDouble( ReadI64 )
+end;
+
+function TBinaryProtocolImpl.ReadFieldBegin: IField;
+var
+  field : IField;
+begin
+  field := TFieldImpl.Create;
+  field.Type_ := TType( ReadByte);
+  if ( field.Type_ <> TType.Stop ) then
+  begin
+    field.Id := ReadI16;
+  end;
+  Result := field;
+end;
+
+procedure TBinaryProtocolImpl.ReadFieldEnd;
+begin
+
+end;
+
+function TBinaryProtocolImpl.ReadI16: SmallInt;
+var
+  i16in : TBytes;
+begin
+  SetLength( i16in, 2 );
+  ReadAll( i16in, 0, 2);
+  Result := SmallInt(((i16in[0] and $FF) shl 8) or (i16in[1] and $FF));
+end;
+
+function TBinaryProtocolImpl.ReadI32: Integer;
+var
+  i32in : TBytes;
+begin
+  SetLength( i32in, 4 );
+  ReadAll( i32in, 0, 4);
+
+  Result := Integer(
+    ((i32in[0] and $FF) shl 24) or
+    ((i32in[1] and $FF) shl 16) or
+    ((i32in[2] and $FF) shl 8) or
+     (i32in[3] and $FF));
+
+end;
+
+function TBinaryProtocolImpl.ReadI64: Int64;
+var
+  i64in : TBytes;
+begin
+  SetLength( i64in, 8);
+  ReadAll( i64in, 0, 8);
+  Result :=
+    (Int64( i64in[0] and $FF) shl 56) or
+    (Int64( i64in[1] and $FF) shl 48) or
+    (Int64( i64in[2] and $FF) shl 40) or
+    (Int64( i64in[3] and $FF) shl 32) or
+    (Int64( i64in[4] and $FF) shl 24) or
+    (Int64( i64in[5] and $FF) shl 16) or
+    (Int64( i64in[6] and $FF) shl 8) or
+    (Int64( i64in[7] and $FF));
+end;
+
+function TBinaryProtocolImpl.ReadListBegin: IList;
+var
+  list : IList;
+begin
+  list := TListImpl.Create;
+  list.ElementType := TType( ReadByte );
+  list.Count := ReadI32;
+  Result := list;
+end;
+
+procedure TBinaryProtocolImpl.ReadListEnd;
+begin
+
+end;
+
+function TBinaryProtocolImpl.ReadMapBegin: IMap;
+var
+  map : IMap;
+begin
+  map := TMapImpl.Create;
+  map.KeyType := TType( ReadByte );
+  map.ValueType := TType( ReadByte );
+  map.Count := ReadI32;
+  Result := map;
+end;
+
+procedure TBinaryProtocolImpl.ReadMapEnd;
+begin
+
+end;
+
+function TBinaryProtocolImpl.ReadMessageBegin: IMessage;
+var
+  size : Integer;
+  version : Integer;
+  message : IMessage;
+begin
+  message := TMessageImpl.Create;
+  size := ReadI32;
+  if (size < 0) then
+  begin
+    version := size and Integer( VERSION_MASK);
+    if ( version <> Integer( VERSION_1)) then
+    begin
+      raise TProtocolException.Create(TProtocolException.BAD_VERSION, 'Bad version in ReadMessageBegin: ' + IntToStr(version) );
+    end;
+    message.Type_ := TMessageType( size and $000000ff);
+    message.Name := ReadString;
+    message.SeqID := ReadI32;
+  end else
+  begin
+    if FStrictRead then
+    begin
+      raise TProtocolException.Create( TProtocolException.BAD_VERSION, 'Missing version in readMessageBegin, old client?' );
+    end;
+    message.Name := ReadStringBody( size );
+    message.Type_ := TMessageType( ReadByte );
+    message.SeqID := ReadI32;
+  end;
+  Result := message;
+end;
+
+procedure TBinaryProtocolImpl.ReadMessageEnd;
+begin
+  inherited;
+
+end;
+
+function TBinaryProtocolImpl.ReadSetBegin: ISet;
+var
+  set_ : ISet;
+begin
+  set_ := TSetImpl.Create;
+  set_.ElementType := TType( ReadByte );
+  set_.Count := ReadI32;
+  Result := set_;
+end;
+
+procedure TBinaryProtocolImpl.ReadSetEnd;
+begin
+
+end;
+
+function TBinaryProtocolImpl.ReadStringBody( size: Integer): string;
+var
+  buf : TBytes;
+begin
+  SetLength( buf, size );
+  FTrans.ReadAll( buf, 0, size );
+  Result := TEncoding.UTF8.GetString( buf);
+end;
+
+function TBinaryProtocolImpl.ReadStructBegin: IStruct;
+begin
+  Result := TStructImpl.Create('');
+end;
+
+procedure TBinaryProtocolImpl.ReadStructEnd;
+begin
+  inherited;
+
+end;
+
+procedure TBinaryProtocolImpl.WriteBinary( const b: TBytes);
+var iLen : Integer;
+begin
+  iLen := Length(b);
+  WriteI32( iLen);
+  if iLen > 0 then FTrans.Write(b, 0, iLen);
+end;
+
+procedure TBinaryProtocolImpl.WriteBool(b: Boolean);
+begin
+  if b then
+  begin
+    WriteByte( 1 );
+  end else
+  begin
+    WriteByte( 0 );
+  end;
+end;
+
+procedure TBinaryProtocolImpl.WriteByte(b: ShortInt);
+var
+  a : TBytes;
+begin
+  SetLength( a, 1);
+  a[0] := Byte( b );
+  FTrans.Write( a, 0, 1 );
+end;
+
+procedure TBinaryProtocolImpl.WriteDouble( const d: Double);
+begin
+  WriteI64(ConvertDoubleToInt64(d));
+end;
+
+procedure TBinaryProtocolImpl.WriteFieldBegin( const field: IField);
+begin
+  WriteByte(ShortInt(field.Type_));
+  WriteI16(field.ID);
+end;
+
+procedure TBinaryProtocolImpl.WriteFieldEnd;
+begin
+
+end;
+
+procedure TBinaryProtocolImpl.WriteFieldStop;
+begin
+  WriteByte(ShortInt(TType.Stop));
+end;
+
+procedure TBinaryProtocolImpl.WriteI16(i16: SmallInt);
+var
+  i16out : TBytes;
+begin
+  SetLength( i16out, 2);
+  i16out[0] := Byte($FF and (i16 shr 8));
+  i16out[1] := Byte($FF and i16);
+  FTrans.Write( i16out );
+end;
+
+procedure TBinaryProtocolImpl.WriteI32(i32: Integer);
+var
+  i32out : TBytes;
+begin
+  SetLength( i32out, 4);
+  i32out[0] := Byte($FF and (i32 shr 24));
+  i32out[1] := Byte($FF and (i32 shr 16));
+  i32out[2] := Byte($FF and (i32 shr 8));
+  i32out[3] := Byte($FF and i32);
+  FTrans.Write( i32out, 0, 4);
+end;
+
+procedure TBinaryProtocolImpl.WriteI64( const i64: Int64);
+var
+  i64out : TBytes;
+begin
+  SetLength( i64out, 8);
+  i64out[0] := Byte($FF and (i64 shr 56));
+  i64out[1] := Byte($FF and (i64 shr 48));
+  i64out[2] := Byte($FF and (i64 shr 40));
+  i64out[3] := Byte($FF and (i64 shr 32));
+  i64out[4] := Byte($FF and (i64 shr 24));
+  i64out[5] := Byte($FF and (i64 shr 16));
+  i64out[6] := Byte($FF and (i64 shr 8));
+  i64out[7] := Byte($FF and i64);
+  FTrans.Write( i64out, 0, 8);
+end;
+
+procedure TBinaryProtocolImpl.WriteListBegin( const list: IList);
+begin
+  WriteByte(ShortInt(list.ElementType));
+  WriteI32(list.Count);
+end;
+
+procedure TBinaryProtocolImpl.WriteListEnd;
+begin
+
+end;
+
+procedure TBinaryProtocolImpl.WriteMapBegin( const map: IMap);
+begin
+  WriteByte(ShortInt(map.KeyType));
+  WriteByte(ShortInt(map.ValueType));
+  WriteI32(map.Count);
+end;
+
+procedure TBinaryProtocolImpl.WriteMapEnd;
+begin
+
+end;
+
+procedure TBinaryProtocolImpl.WriteMessageBegin( const msg: IMessage);
+var
+  version : Cardinal;
+begin
+  if FStrictWrite then
+  begin
+    version := VERSION_1 or Cardinal( msg.Type_);
+    WriteI32( Integer( version) );
+    WriteString( msg.Name);
+    WriteI32( msg.SeqID);
+  end else
+  begin
+    WriteString( msg.Name);
+    WriteByte(ShortInt( msg.Type_));
+    WriteI32( msg.SeqID);
+  end;
+end;
+
+procedure TBinaryProtocolImpl.WriteMessageEnd;
+begin
+
+end;
+
+procedure TBinaryProtocolImpl.WriteSetBegin( const set_: ISet);
+begin
+  WriteByte(ShortInt(set_.ElementType));
+  WriteI32(set_.Count);
+end;
+
+procedure TBinaryProtocolImpl.WriteSetEnd;
+begin
+
+end;
+
+procedure TBinaryProtocolImpl.WriteStructBegin( const struc: IStruct);
+begin
+
+end;
+
+procedure TBinaryProtocolImpl.WriteStructEnd;
+begin
+
+end;
+
+{ TProtocolException }
+
+constructor TProtocolException.Create;
+begin
+  inherited Create('');
+  FType := UNKNOWN;
+end;
+
+constructor TProtocolException.Create(type_: Integer);
+begin
+  inherited Create('');
+  FType := type_;
+end;
+
+constructor TProtocolException.Create(type_: Integer; const msg: string);
+begin
+  inherited Create( msg );
+  FType := type_;
+end;
+
+{ TThriftStringBuilder }
+
+function TThriftStringBuilder.Append(const Value: TBytes): TStringBuilder;
+begin
+  Result := Append( string( RawByteString(Value)) );
+end;
+
+function TThriftStringBuilder.Append(
+  const Value: IThriftContainer): TStringBuilder;
+begin
+  Result := Append( Value.ToString );
+end;
+
+{ TBinaryProtocolImpl.TFactory }
+
+constructor TBinaryProtocolImpl.TFactory.Create(AStrictRead, AStrictWrite: Boolean);
+begin
+  inherited Create;
+  FStrictRead := AStrictRead;
+  FStrictWrite := AStrictWrite;
+end;
+
+constructor TBinaryProtocolImpl.TFactory.Create;
+begin
+  //no inherited;
+  Create( False, True )
+end;
+
+function TBinaryProtocolImpl.TFactory.GetProtocol( const trans: ITransport): IProtocol;
+begin
+  Result := TBinaryProtocolImpl.Create( trans, FStrictRead, FStrictWrite);
+end;
+
+
+{ TProtocolDecorator }
+
+constructor TProtocolDecorator.Create( const aProtocol : IProtocol);
+begin
+  ASSERT( aProtocol <> nil);
+  inherited Create( aProtocol.Transport);
+  FWrappedProtocol := aProtocol;
+end;
+
+
+procedure TProtocolDecorator.WriteMessageBegin( const msg: IMessage);
+begin
+  FWrappedProtocol.WriteMessageBegin( msg);
+end;
+
+
+procedure TProtocolDecorator.WriteMessageEnd;
+begin
+  FWrappedProtocol.WriteMessageEnd;
+end;
+
+
+procedure TProtocolDecorator.WriteStructBegin( const struc: IStruct);
+begin
+  FWrappedProtocol.WriteStructBegin( struc);
+end;
+
+
+procedure TProtocolDecorator.WriteStructEnd;
+begin
+  FWrappedProtocol.WriteStructEnd;
+end;
+
+
+procedure TProtocolDecorator.WriteFieldBegin( const field: IField);
+begin
+  FWrappedProtocol.WriteFieldBegin( field);
+end;
+
+
+procedure TProtocolDecorator.WriteFieldEnd;
+begin
+  FWrappedProtocol.WriteFieldEnd;
+end;
+
+
+procedure TProtocolDecorator.WriteFieldStop;
+begin
+  FWrappedProtocol.WriteFieldStop;
+end;
+
+
+procedure TProtocolDecorator.WriteMapBegin( const map: IMap);
+begin
+  FWrappedProtocol.WriteMapBegin( map);
+end;
+
+
+procedure TProtocolDecorator.WriteMapEnd;
+begin
+  FWrappedProtocol.WriteMapEnd;
+end;
+
+
+procedure TProtocolDecorator.WriteListBegin( const list: IList);
+begin
+  FWrappedProtocol.WriteListBegin( list);
+end;
+
+
+procedure TProtocolDecorator.WriteListEnd();
+begin
+  FWrappedProtocol.WriteListEnd();
+end;
+
+
+procedure TProtocolDecorator.WriteSetBegin( const set_: ISet );
+begin
+  FWrappedProtocol.WriteSetBegin( set_);
+end;
+
+
+procedure TProtocolDecorator.WriteSetEnd();
+begin
+  FWrappedProtocol.WriteSetEnd();
+end;
+
+
+procedure TProtocolDecorator.WriteBool( b: Boolean);
+begin
+  FWrappedProtocol.WriteBool( b);
+end;
+
+
+procedure TProtocolDecorator.WriteByte( b: ShortInt);
+begin
+  FWrappedProtocol.WriteByte( b);
+end;
+
+
+procedure TProtocolDecorator.WriteI16( i16: SmallInt);
+begin
+  FWrappedProtocol.WriteI16( i16);
+end;
+
+
+procedure TProtocolDecorator.WriteI32( i32: Integer);
+begin
+  FWrappedProtocol.WriteI32( i32);
+end;
+
+
+procedure TProtocolDecorator.WriteI64( const i64: Int64);
+begin
+  FWrappedProtocol.WriteI64( i64);
+end;
+
+
+procedure TProtocolDecorator.WriteDouble( const d: Double);
+begin
+  FWrappedProtocol.WriteDouble( d);
+end;
+
+
+procedure TProtocolDecorator.WriteString( const s: string );
+begin
+  FWrappedProtocol.WriteString( s);
+end;
+
+
+procedure TProtocolDecorator.WriteAnsiString( const s: AnsiString);
+begin
+  FWrappedProtocol.WriteAnsiString( s);
+end;
+
+
+procedure TProtocolDecorator.WriteBinary( const b: TBytes);
+begin
+  FWrappedProtocol.WriteBinary( b);
+end;
+
+
+function TProtocolDecorator.ReadMessageBegin: IMessage;
+begin
+  result := FWrappedProtocol.ReadMessageBegin;
+end;
+
+
+procedure TProtocolDecorator.ReadMessageEnd();
+begin
+  FWrappedProtocol.ReadMessageEnd();
+end;
+
+
+function TProtocolDecorator.ReadStructBegin: IStruct;
+begin
+  result := FWrappedProtocol.ReadStructBegin;
+end;
+
+
+procedure TProtocolDecorator.ReadStructEnd;
+begin
+  FWrappedProtocol.ReadStructEnd;
+end;
+
+
+function TProtocolDecorator.ReadFieldBegin: IField;
+begin
+  result := FWrappedProtocol.ReadFieldBegin;
+end;
+
+
+procedure TProtocolDecorator.ReadFieldEnd();
+begin
+  FWrappedProtocol.ReadFieldEnd();
+end;
+
+
+function TProtocolDecorator.ReadMapBegin: IMap;
+begin
+  result := FWrappedProtocol.ReadMapBegin;
+end;
+
+
+procedure TProtocolDecorator.ReadMapEnd();
+begin
+  FWrappedProtocol.ReadMapEnd();
+end;
+
+
+function TProtocolDecorator.ReadListBegin: IList;
+begin
+  result := FWrappedProtocol.ReadListBegin;
+end;
+
+
+procedure TProtocolDecorator.ReadListEnd();
+begin
+  FWrappedProtocol.ReadListEnd();
+end;
+
+
+function TProtocolDecorator.ReadSetBegin: ISet;
+begin
+  result := FWrappedProtocol.ReadSetBegin;
+end;
+
+
+procedure TProtocolDecorator.ReadSetEnd();
+begin
+  FWrappedProtocol.ReadSetEnd();
+end;
+
+
+function TProtocolDecorator.ReadBool: Boolean;
+begin
+  result := FWrappedProtocol.ReadBool;
+end;
+
+
+function TProtocolDecorator.ReadByte: ShortInt;
+begin
+  result := FWrappedProtocol.ReadByte;
+end;
+
+
+function TProtocolDecorator.ReadI16: SmallInt;
+begin
+  result := FWrappedProtocol.ReadI16;
+end;
+
+
+function TProtocolDecorator.ReadI32: Integer;
+begin
+  result := FWrappedProtocol.ReadI32;
+end;
+
+
+function TProtocolDecorator.ReadI64: Int64;
+begin
+  result := FWrappedProtocol.ReadI64;
+end;
+
+
+function TProtocolDecorator.ReadDouble:Double;
+begin
+  result := FWrappedProtocol.ReadDouble;
+end;
+
+
+function TProtocolDecorator.ReadBinary: TBytes;
+begin
+  result := FWrappedProtocol.ReadBinary;
+end;
+
+
+function TProtocolDecorator.ReadString: string;
+begin
+  result := FWrappedProtocol.ReadString;
+end;
+
+
+function TProtocolDecorator.ReadAnsiString: AnsiString;
+begin
+  result := FWrappedProtocol.ReadAnsiString;
+end;
+
+
+
+end.
+
diff --git a/lib/delphi/src/Thrift.Serializer.pas b/lib/delphi/src/Thrift.Serializer.pas
index 43b5d29..cf646c8 100644
--- a/lib/delphi/src/Thrift.Serializer.pas
+++ b/lib/delphi/src/Thrift.Serializer.pas
@@ -86,7 +86,7 @@
 constructor TSerializer.Create();
 // Create a new TSerializer that uses the TBinaryProtocol by default.
 begin
-  //no inherited;  
+  //no inherited;
   Create( TBinaryProtocolImpl.TFactory.Create);
 end;
 
@@ -138,7 +138,7 @@
 procedure TSerializer.Serialize( const input : IBase; const aStm : TStream);
 // Serialize the Thrift object into a byte array. The process is simple,
 // just clear the byte array output, write the object into it, and grab the
-// raw bytes. 
+// raw bytes.
 const COPY_ENTIRE_STREAM = 0;
 begin
   try
@@ -157,7 +157,7 @@
 constructor TDeserializer.Create();
 // Create a new TDeserializer that uses the TBinaryProtocol by default.
 begin
-  //no inherited;  
+  //no inherited;
   Create( TBinaryProtocolImpl.TFactory.Create);
 end;
 
diff --git a/lib/delphi/src/Thrift.Server.pas b/lib/delphi/src/Thrift.Server.pas
index 2fb5c90..2935747 100644
--- a/lib/delphi/src/Thrift.Server.pas
+++ b/lib/delphi/src/Thrift.Server.pas
@@ -87,7 +87,7 @@
     constructor Create(
       const AProcessor :IProcessor;
       const AServerTransport: IServerTransport
-	  ); overload;
+      ); overload;
 
     constructor Create(
       const AProcessor :IProcessor;
@@ -166,7 +166,7 @@
   InputTransFactory := TTransportFactoryImpl.Create;
   OutputTransFactory := TTransportFactoryImpl.Create;
 
-  //no inherited;  
+  //no inherited;
   Create(
     AProcessor,
     AServerTransport,
@@ -187,7 +187,7 @@
   InputProtocolFactory := TBinaryProtocolImpl.TFactory.Create;
   OutputProtocolFactory := TBinaryProtocolImpl.TFactory.Create;
 
-  //no inherited;  
+  //no inherited;
   Create( AProcessor, AServerTransport, ATransportFactory, ATransportFactory,
     InputProtocolFactory, OutputProtocolFactory, DefaultLogDelegate);
 end;
@@ -338,16 +338,16 @@
 
       client := FServerTransport.Accept( procedure
                                          begin
-                                           if FServerEvents <> nil

+                                           if FServerEvents <> nil
                                            then FServerEvents.PreAccept;
-                                         end);

-

-      if client = nil then begin

-        if FStop

-        then Abort  // silent exception

-        else raise TTransportException.Create( 'ServerTransport.Accept() may not return NULL' );

-      end;

-

+                                         end);
+
+      if client = nil then begin
+        if FStop
+        then Abort  // silent exception
+        else raise TTransportException.Create( 'ServerTransport.Accept() may not return NULL' );
+      end;
+
       FLogDelegate( 'Client Connected!');
 
       InputTransport := FInputTransportFactory.GetTransport( client );
diff --git a/lib/delphi/src/Thrift.Stream.pas b/lib/delphi/src/Thrift.Stream.pas
index c08f5ea..d1f6384 100644
--- a/lib/delphi/src/Thrift.Stream.pas
+++ b/lib/delphi/src/Thrift.Stream.pas
@@ -1,300 +1,300 @@
-(*

- * Licensed to the Apache Software Foundation (ASF) under one

- * or more contributor license agreements. See the NOTICE file

- * distributed with this work for additional information

- * regarding copyright ownership. The ASF licenses this file

- * to you under the Apache License, Version 2.0 (the

- * "License"); you may not use this file except in compliance

- * with the License. You may obtain a copy of the License at

- *

- *   http://www.apache.org/licenses/LICENSE-2.0

- *

- * Unless required by applicable law or agreed to in writing,

- * software distributed under the License is distributed on an

- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

- * KIND, either express or implied. See the License for the

- * specific language governing permissions and limitations

- * under the License.

- *)

-

-unit Thrift.Stream;

-

-interface

-

-uses

-  Classes,

-  SysUtils,

-  SysConst,

-  RTLConsts,

-  Thrift.Utils,

-  ActiveX;

-

-type

-

-  IThriftStream = interface

-    ['{732621B3-F697-4D76-A1B0-B4DD5A8E4018}']

-    procedure Write( const buffer: TBytes; offset: Integer; count: Integer);

-    function Read( var buffer: TBytes; offset: Integer; count: Integer): Integer;

-    procedure Open;

-    procedure Close;

-    procedure Flush;

-    function IsOpen: Boolean;

-    function ToArray: TBytes;

-  end;

-

-  TThriftStreamImpl = class( TInterfacedObject, IThriftStream)

-  private

-    procedure CheckSizeAndOffset( const buffer: TBytes; offset: Integer; count: Integer);

-  protected

-    procedure Write( const buffer: TBytes; offset: Integer; count: Integer); virtual;

-    function Read( var buffer: TBytes; offset: Integer; count: Integer): Integer; virtual;

-    procedure Open; virtual; abstract;

-    procedure Close; virtual; abstract;

-    procedure Flush; virtual; abstract;

-    function IsOpen: Boolean; virtual; abstract;

-    function ToArray: TBytes; virtual; abstract;

-  end;

-

-  TThriftStreamAdapterDelphi = class( TThriftStreamImpl )

-  private

-    FStream : TStream;

-    FOwnsStream : Boolean;

-  protected

-    procedure Write( const buffer: TBytes; offset: Integer; count: Integer); override;

-    function Read( var buffer: TBytes; offset: Integer; count: Integer): Integer; override;

-    procedure Open; override;

-    procedure Close; override;

-    procedure Flush; override;

-    function IsOpen: Boolean; override;

-    function ToArray: TBytes; override;

-  public

-    constructor Create( const AStream: TStream; AOwnsStream : Boolean);

-    destructor Destroy; override;

-  end;

-

-  TThriftStreamAdapterCOM = class( TThriftStreamImpl)

-  private

-    FStream : IStream;

-  protected

-    procedure Write( const buffer: TBytes; offset: Integer; count: Integer); override;

-    function Read( var buffer: TBytes; offset: Integer; count: Integer): Integer; override;

-    procedure Open; override;

-    procedure Close; override;

-    procedure Flush; override;

-    function IsOpen: Boolean; override;

-    function ToArray: TBytes; override;

-  public

-    constructor Create( const AStream: IStream);

-  end;

-

-implementation

-

-{ TThriftStreamAdapterCOM }

-

-procedure TThriftStreamAdapterCOM.Close;

-begin

-  FStream := nil;

-end;

-

-constructor TThriftStreamAdapterCOM.Create( const AStream: IStream);

-begin

-  inherited Create;

-  FStream := AStream;

-end;

-

-procedure TThriftStreamAdapterCOM.Flush;

-begin

-  if IsOpen then

-  begin

-    if FStream <> nil then

-    begin

-      FStream.Commit( STGC_DEFAULT );

-    end;

-  end;

-end;

-

-function TThriftStreamAdapterCOM.IsOpen: Boolean;

-begin

-  Result := FStream <> nil;

-end;

-

-procedure TThriftStreamAdapterCOM.Open;

-begin

-

-end;

-

-function TThriftStreamAdapterCOM.Read( var buffer: TBytes; offset: Integer; count: Integer): Integer;

-begin

-  inherited;

-  Result := 0;

-  if FStream <> nil then

-  begin

-    if count > 0 then

-    begin

-      FStream.Read( @buffer[offset], count, @Result);

-    end;

-  end;

-end;

-

-function TThriftStreamAdapterCOM.ToArray: TBytes;

-var

-  statstg: TStatStg;

-  len : Integer;

-  NewPos : Int64;

-  cbRead : Integer;

-begin

-  FillChar( statstg, SizeOf( statstg), 0);

-  len := 0;

-  if IsOpen then

-  begin

-    if Succeeded( FStream.Stat( statstg, STATFLAG_NONAME )) then

-    begin

-      len := statstg.cbSize;

-    end;

-  end;

-

-  SetLength( Result, len );

-

-  if len > 0 then

-  begin

-    if Succeeded( FStream.Seek( 0, STREAM_SEEK_SET, NewPos) ) then

-    begin

-      FStream.Read( @Result[0], len, @cbRead);

-    end;

-  end;

-end;

-

-procedure TThriftStreamAdapterCOM.Write( const buffer: TBytes; offset: Integer; count: Integer);

-var

-  nWritten : Integer;

-begin

-  inherited;

-  if IsOpen then

-  begin

-    if count > 0 then

-    begin

-      FStream.Write( @buffer[0], count, @nWritten);

-    end;

-  end;

-end;

-

-{ TThriftStreamImpl }

-

-procedure TThriftStreamImpl.CheckSizeAndOffset(const buffer: TBytes; offset,

-  count: Integer);

-var

-  len : Integer;

-begin

-  if count > 0 then

-  begin

-    len := Length( buffer );

-    if (offset < 0) or ( offset >= len) then

-    begin

-      raise ERangeError.Create( SBitsIndexError );

-    end;

-    if count > len then

-    begin

-      raise ERangeError.Create( SBitsIndexError );

-    end;

-  end;

-end;

-

-function TThriftStreamImpl.Read(var buffer: TBytes; offset,

-  count: Integer): Integer;

-begin

-  Result := 0;

-  CheckSizeAndOffset( buffer, offset, count );

-end;

-

-procedure TThriftStreamImpl.Write(const buffer: TBytes; offset, count: Integer);

-begin

-  CheckSizeAndOffset( buffer, offset, count );

-end;

-

-{ TThriftStreamAdapterDelphi }

-

-procedure TThriftStreamAdapterDelphi.Close;

-begin

-  FStream.Free;

-  FStream := nil;

-  FOwnsStream := False;

-end;

-

-constructor TThriftStreamAdapterDelphi.Create( const AStream: TStream; AOwnsStream: Boolean);

-begin

-  inherited Create;

-  FStream := AStream;

-  FOwnsStream := AOwnsStream;

-end;

-

-destructor TThriftStreamAdapterDelphi.Destroy;

-begin

-  if FOwnsStream then

-  begin

-    FStream.Free;

-  end;

-  inherited;

-end;

-

-procedure TThriftStreamAdapterDelphi.Flush;

-begin

-

-end;

-

-function TThriftStreamAdapterDelphi.IsOpen: Boolean;

-begin

-  Result := FStream <> nil;

-end;

-

-procedure TThriftStreamAdapterDelphi.Open;

-begin

-

-end;

-

-function TThriftStreamAdapterDelphi.Read(var buffer: TBytes; offset,

-  count: Integer): Integer;

-begin

-  inherited;

-  Result := 0;

-  if count > 0 then

-  begin

-    Result := FStream.Read( Pointer(@buffer[offset])^, count)

-  end;

-end;

-

-function TThriftStreamAdapterDelphi.ToArray: TBytes;

-var

-  OrgPos : Integer;

-  len : Integer;

-begin

-  len := 0;

-  if FStream <> nil then

-  begin

-    len := FStream.Size;

-  end;

-

-  SetLength( Result, len );

-

-  if len > 0 then

-  begin

-    OrgPos := FStream.Position;

-    try

-      FStream.Position := 0;

-      FStream.ReadBuffer( Pointer(@Result[0])^, len );

-    finally

-      FStream.Position := OrgPos;

-    end;

-  end

-end;

-

-procedure TThriftStreamAdapterDelphi.Write(const buffer: TBytes; offset,

-  count: Integer);

-begin

-  inherited;

-  if count > 0 then

-  begin

-    FStream.Write( Pointer(@buffer[offset])^, count)

-  end;

-end;

-

-end.

+(*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *)
+
+unit Thrift.Stream;
+
+interface
+
+uses
+  Classes,
+  SysUtils,
+  SysConst,
+  RTLConsts,
+  Thrift.Utils,
+  ActiveX;
+
+type
+
+  IThriftStream = interface
+    ['{732621B3-F697-4D76-A1B0-B4DD5A8E4018}']
+    procedure Write( const buffer: TBytes; offset: Integer; count: Integer);
+    function Read( var buffer: TBytes; offset: Integer; count: Integer): Integer;
+    procedure Open;
+    procedure Close;
+    procedure Flush;
+    function IsOpen: Boolean;
+    function ToArray: TBytes;
+  end;
+
+  TThriftStreamImpl = class( TInterfacedObject, IThriftStream)
+  private
+    procedure CheckSizeAndOffset( const buffer: TBytes; offset: Integer; count: Integer);
+  protected
+    procedure Write( const buffer: TBytes; offset: Integer; count: Integer); virtual;
+    function Read( var buffer: TBytes; offset: Integer; count: Integer): Integer; virtual;
+    procedure Open; virtual; abstract;
+    procedure Close; virtual; abstract;
+    procedure Flush; virtual; abstract;
+    function IsOpen: Boolean; virtual; abstract;
+    function ToArray: TBytes; virtual; abstract;
+  end;
+
+  TThriftStreamAdapterDelphi = class( TThriftStreamImpl )
+  private
+    FStream : TStream;
+    FOwnsStream : Boolean;
+  protected
+    procedure Write( const buffer: TBytes; offset: Integer; count: Integer); override;
+    function Read( var buffer: TBytes; offset: Integer; count: Integer): Integer; override;
+    procedure Open; override;
+    procedure Close; override;
+    procedure Flush; override;
+    function IsOpen: Boolean; override;
+    function ToArray: TBytes; override;
+  public
+    constructor Create( const AStream: TStream; AOwnsStream : Boolean);
+    destructor Destroy; override;
+  end;
+
+  TThriftStreamAdapterCOM = class( TThriftStreamImpl)
+  private
+    FStream : IStream;
+  protected
+    procedure Write( const buffer: TBytes; offset: Integer; count: Integer); override;
+    function Read( var buffer: TBytes; offset: Integer; count: Integer): Integer; override;
+    procedure Open; override;
+    procedure Close; override;
+    procedure Flush; override;
+    function IsOpen: Boolean; override;
+    function ToArray: TBytes; override;
+  public
+    constructor Create( const AStream: IStream);
+  end;
+
+implementation
+
+{ TThriftStreamAdapterCOM }
+
+procedure TThriftStreamAdapterCOM.Close;
+begin
+  FStream := nil;
+end;
+
+constructor TThriftStreamAdapterCOM.Create( const AStream: IStream);
+begin
+  inherited Create;
+  FStream := AStream;
+end;
+
+procedure TThriftStreamAdapterCOM.Flush;
+begin
+  if IsOpen then
+  begin
+    if FStream <> nil then
+    begin
+      FStream.Commit( STGC_DEFAULT );
+    end;
+  end;
+end;
+
+function TThriftStreamAdapterCOM.IsOpen: Boolean;
+begin
+  Result := FStream <> nil;
+end;
+
+procedure TThriftStreamAdapterCOM.Open;
+begin
+
+end;
+
+function TThriftStreamAdapterCOM.Read( var buffer: TBytes; offset: Integer; count: Integer): Integer;
+begin
+  inherited;
+  Result := 0;
+  if FStream <> nil then
+  begin
+    if count > 0 then
+    begin
+      FStream.Read( @buffer[offset], count, @Result);
+    end;
+  end;
+end;
+
+function TThriftStreamAdapterCOM.ToArray: TBytes;
+var
+  statstg: TStatStg;
+  len : Integer;
+  NewPos : Int64;
+  cbRead : Integer;
+begin
+  FillChar( statstg, SizeOf( statstg), 0);
+  len := 0;
+  if IsOpen then
+  begin
+    if Succeeded( FStream.Stat( statstg, STATFLAG_NONAME )) then
+    begin
+      len := statstg.cbSize;
+    end;
+  end;
+
+  SetLength( Result, len );
+
+  if len > 0 then
+  begin
+    if Succeeded( FStream.Seek( 0, STREAM_SEEK_SET, NewPos) ) then
+    begin
+      FStream.Read( @Result[0], len, @cbRead);
+    end;
+  end;
+end;
+
+procedure TThriftStreamAdapterCOM.Write( const buffer: TBytes; offset: Integer; count: Integer);
+var
+  nWritten : Integer;
+begin
+  inherited;
+  if IsOpen then
+  begin
+    if count > 0 then
+    begin
+      FStream.Write( @buffer[0], count, @nWritten);
+    end;
+  end;
+end;
+
+{ TThriftStreamImpl }
+
+procedure TThriftStreamImpl.CheckSizeAndOffset(const buffer: TBytes; offset,
+  count: Integer);
+var
+  len : Integer;
+begin
+  if count > 0 then
+  begin
+    len := Length( buffer );
+    if (offset < 0) or ( offset >= len) then
+    begin
+      raise ERangeError.Create( SBitsIndexError );
+    end;
+    if count > len then
+    begin
+      raise ERangeError.Create( SBitsIndexError );
+    end;
+  end;
+end;
+
+function TThriftStreamImpl.Read(var buffer: TBytes; offset,
+  count: Integer): Integer;
+begin
+  Result := 0;
+  CheckSizeAndOffset( buffer, offset, count );
+end;
+
+procedure TThriftStreamImpl.Write(const buffer: TBytes; offset, count: Integer);
+begin
+  CheckSizeAndOffset( buffer, offset, count );
+end;
+
+{ TThriftStreamAdapterDelphi }
+
+procedure TThriftStreamAdapterDelphi.Close;
+begin
+  FStream.Free;
+  FStream := nil;
+  FOwnsStream := False;
+end;
+
+constructor TThriftStreamAdapterDelphi.Create( const AStream: TStream; AOwnsStream: Boolean);
+begin
+  inherited Create;
+  FStream := AStream;
+  FOwnsStream := AOwnsStream;
+end;
+
+destructor TThriftStreamAdapterDelphi.Destroy;
+begin
+  if FOwnsStream then
+  begin
+    FStream.Free;
+  end;
+  inherited;
+end;
+
+procedure TThriftStreamAdapterDelphi.Flush;
+begin
+
+end;
+
+function TThriftStreamAdapterDelphi.IsOpen: Boolean;
+begin
+  Result := FStream <> nil;
+end;
+
+procedure TThriftStreamAdapterDelphi.Open;
+begin
+
+end;
+
+function TThriftStreamAdapterDelphi.Read(var buffer: TBytes; offset,
+  count: Integer): Integer;
+begin
+  inherited;
+  Result := 0;
+  if count > 0 then
+  begin
+    Result := FStream.Read( Pointer(@buffer[offset])^, count)
+  end;
+end;
+
+function TThriftStreamAdapterDelphi.ToArray: TBytes;
+var
+  OrgPos : Integer;
+  len : Integer;
+begin
+  len := 0;
+  if FStream <> nil then
+  begin
+    len := FStream.Size;
+  end;
+
+  SetLength( Result, len );
+
+  if len > 0 then
+  begin
+    OrgPos := FStream.Position;
+    try
+      FStream.Position := 0;
+      FStream.ReadBuffer( Pointer(@Result[0])^, len );
+    finally
+      FStream.Position := OrgPos;
+    end;
+  end
+end;
+
+procedure TThriftStreamAdapterDelphi.Write(const buffer: TBytes; offset,
+  count: Integer);
+begin
+  inherited;
+  if count > 0 then
+  begin
+    FStream.Write( Pointer(@buffer[offset])^, count)
+  end;
+end;
+
+end.
diff --git a/lib/delphi/src/Thrift.Transport.Pipes.pas b/lib/delphi/src/Thrift.Transport.Pipes.pas
index eb4e8e3..48eb5e2 100644
--- a/lib/delphi/src/Thrift.Transport.Pipes.pas
+++ b/lib/delphi/src/Thrift.Transport.Pipes.pas
@@ -781,7 +781,7 @@
     FWriteHandle     := hPipeW;
 
     result := TRUE;
-  
+
   finally
     if sd <> nil then LocalFree( Cardinal(sd));
   end;
diff --git a/lib/delphi/src/Thrift.Transport.pas b/lib/delphi/src/Thrift.Transport.pas
index bc66c64..96735ec 100644
--- a/lib/delphi/src/Thrift.Transport.pas
+++ b/lib/delphi/src/Thrift.Transport.pas
@@ -1,1389 +1,1389 @@
-(*

- * Licensed to the Apache Software Foundation (ASF) under one

- * or more contributor license agreements. See the NOTICE file

- * distributed with this work for additional information

- * regarding copyright ownership. The ASF licenses this file

- * to you under the Apache License, Version 2.0 (the

- * "License"); you may not use this file except in compliance

- * with the License. You may obtain a copy of the License at

- *

- *   http://www.apache.org/licenses/LICENSE-2.0

- *

- * Unless required by applicable law or agreed to in writing,

- * software distributed under the License is distributed on an

- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

- * KIND, either express or implied. See the License for the

- * specific language governing permissions and limitations

- * under the License.

- *)

-

- {$SCOPEDENUMS ON}

-

-unit Thrift.Transport;

-

-interface

-

-uses

-  Classes,

-  SysUtils,

-  Math,

-  Sockets, WinSock,

-  Generics.Collections,

-  Thrift.Collections,

-  Thrift.Utils,

-  Thrift.Stream,

-  ActiveX,

-  msxml;

-

-type

-  ITransport = interface

-    ['{A4A9FC37-D620-44DC-AD21-662D16364CE4}']

-    function GetIsOpen: Boolean;

-    property IsOpen: Boolean read GetIsOpen;

-    function Peek: Boolean;

-    procedure Open;

-    procedure Close;

-    function Read(var buf: TBytes; off: Integer; len: Integer): Integer;

-    function ReadAll(var buf: TBytes; off: Integer; len: Integer): Integer;

-    procedure Write( const buf: TBytes); overload;

-    procedure Write( const buf: TBytes; off: Integer; len: Integer); overload;

-    procedure Flush;

-  end;

-

-  TTransportImpl = class( TInterfacedObject, ITransport)

-  protected

-    function GetIsOpen: Boolean; virtual; abstract;

-    property IsOpen: Boolean read GetIsOpen;

-    function Peek: Boolean; virtual;

-    procedure Open(); virtual; abstract;

-    procedure Close(); virtual; abstract;

-    function Read(var buf: TBytes; off: Integer; len: Integer): Integer; virtual; abstract;

-    function ReadAll(var buf: TBytes; off: Integer; len: Integer): Integer; virtual;

-    procedure Write( const buf: TBytes); overload; virtual;

-    procedure Write( const buf: TBytes; off: Integer; len: Integer); overload; virtual; abstract;

-    procedure Flush; virtual;

-  end;

-

-  TTransportException = class( Exception )

-  public

-    type

-      TExceptionType = (

-        Unknown,

-        NotOpen,

-        AlreadyOpen,

-        TimedOut,

-        EndOfFile

-      );

-  private

-    FType : TExceptionType;

-  public

-    constructor Create( AType: TExceptionType); overload;

-    constructor Create( const msg: string); overload;

-    constructor Create( AType: TExceptionType; const msg: string); overload;

-    property Type_: TExceptionType read FType;

-  end;

-

-  IHTTPClient = interface( ITransport )

-    ['{0F5DB8AB-710D-4338-AAC9-46B5734C5057}']

-    procedure SetConnectionTimeout(const Value: Integer);

-    function GetConnectionTimeout: Integer;

-    procedure SetReadTimeout(const Value: Integer);

-    function GetReadTimeout: Integer;

-    function GetCustomHeaders: IThriftDictionary<string,string>;

-    procedure SendRequest;

-    property ConnectionTimeout: Integer read GetConnectionTimeout write SetConnectionTimeout;

-    property ReadTimeout: Integer read GetReadTimeout write SetReadTimeout;

-    property CustomHeaders: IThriftDictionary<string,string> read GetCustomHeaders;

-  end;

-

-  THTTPClientImpl = class( TTransportImpl, IHTTPClient)

-  private

-    FUri : string;

-    FInputStream : IThriftStream;

-    FOutputStream : IThriftStream;

-    FConnectionTimeout : Integer;

-    FReadTimeout : Integer;

-    FCustomHeaders : IThriftDictionary<string,string>;

-

-    function CreateRequest: IXMLHTTPRequest;

-  protected

-    function GetIsOpen: Boolean; override;

-    procedure Open(); override;

-    procedure Close(); override;

-    function Read( var buf: TBytes; off: Integer; len: Integer): Integer; override;

-    procedure Write( const buf: TBytes; off: Integer; len: Integer); override;

-    procedure Flush; override;

-

-    procedure SetConnectionTimeout(const Value: Integer);

-    function GetConnectionTimeout: Integer;

-    procedure SetReadTimeout(const Value: Integer);

-    function GetReadTimeout: Integer;

-    function GetCustomHeaders: IThriftDictionary<string,string>;

-    procedure SendRequest;

-    property ConnectionTimeout: Integer read GetConnectionTimeout write SetConnectionTimeout;

-    property ReadTimeout: Integer read GetReadTimeout write SetReadTimeout;

-    property CustomHeaders: IThriftDictionary<string,string> read GetCustomHeaders;

-  public

-    constructor Create( const AUri: string);

-    destructor Destroy; override;

-  end;

-

-  IServerTransport = interface

-    ['{C43B87ED-69EA-47C4-B77C-15E288252900}']

-    procedure Listen;

-    procedure Close;

-    function Accept( const fnAccepting: TProc): ITransport;

-  end;

-

-  TServerTransportImpl = class( TInterfacedObject, IServerTransport)

-  protected

-    procedure Listen; virtual; abstract;

-    procedure Close; virtual; abstract;

-    function Accept( const fnAccepting: TProc): ITransport;  virtual; abstract;

-  end;

-

-  ITransportFactory = interface

-    ['{DD809446-000F-49E1-9BFF-E0D0DC76A9D7}']

-    function GetTransport( const ATrans: ITransport): ITransport;

-  end;

-

-  TTransportFactoryImpl = class( TInterfacedObject, ITransportFactory)

-    function GetTransport( const ATrans: ITransport): ITransport; virtual;

-  end;

-

-  TTcpSocketStreamImpl = class( TThriftStreamImpl )

-  private type

-    TWaitForData = ( wfd_HaveData, wfd_Timeout, wfd_Error);

-  private

-    FTcpClient : TCustomIpClient;

-    FTimeout : Integer;

-    function Select( ReadReady, WriteReady, ExceptFlag: PBoolean;

-                     TimeOut: Integer; var wsaError : Integer): Integer;

-    function WaitForData( TimeOut : Integer; pBuf : Pointer; DesiredBytes: Integer;

-                          var wsaError : Integer): TWaitForData;

-  protected

-    procedure Write( const buffer: TBytes; offset: Integer; count: Integer); override;

-    function Read( var buffer: TBytes; offset: Integer; count: Integer): Integer; override;

-    procedure Open; override;

-    procedure Close; override;

-    procedure Flush; override;

-

-    function IsOpen: Boolean; override;

-    function ToArray: TBytes; override;

-  public

-    constructor Create( const ATcpClient: TCustomIpClient; const aTimeout : Integer = 0);

-  end;

-

-  IStreamTransport = interface( ITransport )

-    ['{A8479B47-2A3E-4421-A9A0-D5A9EDCC634A}']

-    function GetInputStream: IThriftStream;

-    function GetOutputStream: IThriftStream;

-    property InputStream : IThriftStream read GetInputStream;

-    property OutputStream : IThriftStream read GetOutputStream;

-  end;

-

-  TStreamTransportImpl = class( TTransportImpl, IStreamTransport)

-  protected

-    FInputStream : IThriftStream;

-    FOutputStream : IThriftStream;

-  protected

-    function GetIsOpen: Boolean; override;

-

-    function GetInputStream: IThriftStream;

-    function GetOutputStream: IThriftStream;

-  public

-    property InputStream : IThriftStream read GetInputStream;

-    property OutputStream : IThriftStream read GetOutputStream;

-

-    procedure Open; override;

-    procedure Close; override;

-    procedure Flush; override;

-    function Read(var buf: TBytes; off: Integer; len: Integer): Integer; override;

-    procedure Write( const buf: TBytes; off: Integer; len: Integer); override;

-    constructor Create( const AInputStream : IThriftStream; const AOutputStream : IThriftStream);

-    destructor Destroy; override;

-  end;

-

-  TBufferedStreamImpl = class( TThriftStreamImpl)

-  private

-    FStream : IThriftStream;

-    FBufSize : Integer;

-    FReadBuffer : TMemoryStream;

-    FWriteBuffer : TMemoryStream;

-  protected

-    procedure Write( const buffer: TBytes; offset: Integer; count: Integer); override;

-    function Read( var buffer: TBytes; offset: Integer; count: Integer): Integer; override;

-    procedure Open;  override;

-    procedure Close; override;

-    procedure Flush; override;

-    function IsOpen: Boolean; override;

-    function ToArray: TBytes; override;

-  public

-    constructor Create( const AStream: IThriftStream; ABufSize: Integer);

-    destructor Destroy; override;

-  end;

-

-  TServerSocketImpl = class( TServerTransportImpl)

-  private

-    FServer : TTcpServer;

-    FPort : Integer;

-    FClientTimeout : Integer;

-    FUseBufferedSocket : Boolean;

-    FOwnsServer : Boolean;

-  protected

-    function Accept( const fnAccepting: TProc) : ITransport; override;

-  public

-    constructor Create( const AServer: TTcpServer; AClientTimeout: Integer = 0); overload;

-    constructor Create( APort: Integer; AClientTimeout: Integer = 0; AUseBufferedSockets: Boolean = FALSE); overload;

-    destructor Destroy; override;

-    procedure Listen; override;

-    procedure Close; override;

-  end;

-

-  TBufferedTransportImpl = class( TTransportImpl )

-  private

-    FInputBuffer : IThriftStream;

-    FOutputBuffer : IThriftStream;

-    FTransport : IStreamTransport;

-    FBufSize : Integer;

-

-    procedure InitBuffers;

-    function GetUnderlyingTransport: ITransport;

-  protected

-    function GetIsOpen: Boolean; override;

-    procedure Flush; override;

-  public

-    procedure Open(); override;

-    procedure Close(); override;

-    function Read(var buf: TBytes; off: Integer; len: Integer): Integer; override;

-    procedure Write( const buf: TBytes; off: Integer; len: Integer); override;

-    constructor Create( const ATransport : IStreamTransport ); overload;

-    constructor Create( const ATransport : IStreamTransport; ABufSize: Integer); overload;

-    property UnderlyingTransport: ITransport read GetUnderlyingTransport;

-    property IsOpen: Boolean read GetIsOpen;

-  end;

-

-  TSocketImpl = class(TStreamTransportImpl)

-  private

-    FClient : TCustomIpClient;

-    FOwnsClient : Boolean;

-    FHost : string;

-    FPort : Integer;

-    FTimeout : Integer;

-

-    procedure InitSocket;

-  protected

-    function GetIsOpen: Boolean; override;

-  public

-    procedure Open; override;

-    constructor Create( const AClient : TCustomIpClient; aOwnsClient : Boolean; ATimeout: Integer = 0); overload;

-    constructor Create( const AHost: string; APort: Integer; ATimeout: Integer = 0); overload;

-    destructor Destroy; override;

-    procedure Close; override;

-    property TcpClient: TCustomIpClient read FClient;

-    property Host : string read FHost;

-    property Port: Integer read FPort;

-  end;

-

-  TFramedTransportImpl = class( TTransportImpl)

-  private const

-    FHeaderSize : Integer = 4;

-  private class var

-    FHeader_Dummy : array of Byte;

-  protected

-    FTransport : ITransport;

-    FWriteBuffer : TMemoryStream;

-    FReadBuffer : TMemoryStream;

-

-    procedure InitWriteBuffer;

-    procedure ReadFrame;

-  public

-    type

-      TFactory = class( TTransportFactoryImpl )

-      public

-        function GetTransport( const ATrans: ITransport): ITransport; override;

-      end;

-

-{$IF CompilerVersion >= 21.0}

-    class constructor Create;

-{$IFEND}

-    constructor Create; overload;

-    constructor Create( const ATrans: ITransport); overload;

-    destructor Destroy; override;

-

-    procedure Open(); override;

-    function GetIsOpen: Boolean; override;

-

-    procedure Close(); override;

-    function Read(var buf: TBytes; off: Integer; len: Integer): Integer; override;

-    procedure Write( const buf: TBytes; off: Integer; len: Integer); override;

-    procedure Flush; override;

-  end;

-

-{$IF CompilerVersion < 21.0}

-procedure TFramedTransportImpl_Initialize;

-{$IFEND}

-

-const

-  DEFAULT_THRIFT_TIMEOUT = 5 * 1000; // ms

-

-

-implementation

-

-{ TTransportImpl }

-

-procedure TTransportImpl.Flush;

-begin

-

-end;

-

-function TTransportImpl.Peek: Boolean;

-begin

-  Result := IsOpen;

-end;

-

-function TTransportImpl.ReadAll( var buf: TBytes; off, len: Integer): Integer;

-var

-  got : Integer;

-  ret : Integer;

-begin

-  got := 0;

-  while ( got < len) do

-  begin

-    ret := Read( buf, off + got, len - got);

-    if ( ret <= 0 ) then

-    begin

-      raise TTransportException.Create( 'Cannot read, Remote side has closed' );

-    end;

-    got := got + ret;

-  end;

-  Result := got;

-end;

-

-procedure TTransportImpl.Write( const buf: TBytes);

-begin

-  Self.Write( buf, 0, Length(buf) );

-end;

-

-{ THTTPClientImpl }

-

-procedure THTTPClientImpl.Close;

-begin

-  FInputStream := nil;

-  FOutputStream := nil;

-end;

-

-constructor THTTPClientImpl.Create(const AUri: string);

-begin

-  inherited Create;

-  FUri := AUri;

-  FCustomHeaders := TThriftDictionaryImpl<string,string>.Create;

-  FOutputStream := TThriftStreamAdapterDelphi.Create( TMemoryStream.Create, True);

-end;

-

-function THTTPClientImpl.CreateRequest: IXMLHTTPRequest;

-var

-  pair : TPair<string,string>;

-begin

-{$IF CompilerVersion >= 21.0}

-  Result := CoXMLHTTP.Create;

-{$ELSE}

-  Result := CoXMLHTTPRequest.Create;

-{$IFEND}

-

-  Result.open('POST', FUri, False, '', '');

-  Result.setRequestHeader( 'Content-Type', 'application/x-thrift');

-  Result.setRequestHeader( 'Accept', 'application/x-thrift');

-  Result.setRequestHeader( 'User-Agent', 'Delphi/IHTTPClient');

-

-  for pair in FCustomHeaders do

-  begin

-    Result.setRequestHeader( pair.Key, pair.Value );

-  end;

-end;

-

-destructor THTTPClientImpl.Destroy;

-begin

-  Close;

-  inherited;

-end;

-

-procedure THTTPClientImpl.Flush;

-begin

-  try

-    SendRequest;

-  finally

-    FOutputStream := nil;

-    FOutputStream := TThriftStreamAdapterDelphi.Create( TMemoryStream.Create, True);

-  end;

-end;

-

-function THTTPClientImpl.GetConnectionTimeout: Integer;

-begin

-  Result := FConnectionTimeout;

-end;

-

-function THTTPClientImpl.GetCustomHeaders: IThriftDictionary<string,string>;

-begin

-  Result := FCustomHeaders;

-end;

-

-function THTTPClientImpl.GetIsOpen: Boolean;

-begin

-  Result := True;

-end;

-

-function THTTPClientImpl.GetReadTimeout: Integer;

-begin

-  Result := FReadTimeout;

-end;

-

-procedure THTTPClientImpl.Open;

-begin

-

-end;

-

-function THTTPClientImpl.Read( var buf: TBytes; off, len: Integer): Integer;

-begin

-  if FInputStream = nil then

-  begin

-    raise TTransportException.Create( TTransportException.TExceptionType.NotOpen,

-      'No request has been sent');

-  end;

-  try

-    Result := FInputStream.Read( buf, off, len )

-  except

-    on E: Exception do

-    begin

-      raise TTransportException.Create( TTransportException.TExceptionType.Unknown,

-        E.Message);

-    end;

-  end;

-end;

-

-procedure THTTPClientImpl.SendRequest;

-var

-  xmlhttp : IXMLHTTPRequest;

-  ms : TMemoryStream;

-  a : TBytes;

-  len : Integer;

-begin

-  xmlhttp := CreateRequest;

-

-  ms := TMemoryStream.Create;

-  try

-    a := FOutputStream.ToArray;

-    len := Length(a);

-    if len > 0 then

-    begin

-      ms.WriteBuffer( Pointer(@a[0])^, len);

-    end;

-    ms.Position := 0;

-    xmlhttp.send( IUnknown( TStreamAdapter.Create( ms, soReference )));

-    FInputStream := nil;

-    FInputStream := TThriftStreamAdapterCOM.Create( IUnknown( xmlhttp.responseStream) as IStream);

-  finally

-    ms.Free;

-  end;

-end;

-

-procedure THTTPClientImpl.SetConnectionTimeout(const Value: Integer);

-begin

-  FConnectionTimeout := Value;

-end;

-

-procedure THTTPClientImpl.SetReadTimeout(const Value: Integer);

-begin

-  FReadTimeout := Value

-end;

-

-procedure THTTPClientImpl.Write( const buf: TBytes; off, len: Integer);

-begin

-  FOutputStream.Write( buf, off, len);

-end;

-

-{ TTransportException }

-

-constructor TTransportException.Create(AType: TExceptionType);

-begin

-  //no inherited;  

-  Create( AType, '' )

-end;

-

-constructor TTransportException.Create(AType: TExceptionType;

-  const msg: string);

-begin

-  inherited Create(msg);

-  FType := AType;

-end;

-

-constructor TTransportException.Create(const msg: string);

-begin

-  inherited Create(msg);

-end;

-

-{ TTransportFactoryImpl }

-

-function TTransportFactoryImpl.GetTransport( const ATrans: ITransport): ITransport;

-begin

-  Result := ATrans;

-end;

-

-{ TServerSocket }

-

-constructor TServerSocketImpl.Create( const AServer: TTcpServer; AClientTimeout: Integer);

-begin

-  inherited Create;

-  FServer := AServer;

-  FClientTimeout := AClientTimeout;

-end;

-

-constructor TServerSocketImpl.Create(APort, AClientTimeout: Integer; AUseBufferedSockets: Boolean);

-begin

-  inherited Create;

-  FPort := APort;

-  FClientTimeout := AClientTimeout;

-  FUseBufferedSocket := AUseBufferedSockets;

-  FOwnsServer := True;

-  FServer := TTcpServer.Create( nil );

-  FServer.BlockMode := bmBlocking;

-{$IF CompilerVersion >= 21.0}

-  FServer.LocalPort := AnsiString( IntToStr( FPort));

-{$ELSE}

-  FServer.LocalPort := IntToStr( FPort);

-{$IFEND}

-end;

-

-destructor TServerSocketImpl.Destroy;

-begin

-  if FOwnsServer then begin

-    FServer.Free;

-    FServer := nil;

-  end;

-  inherited;

-end;

-

-function TServerSocketImpl.Accept( const fnAccepting: TProc): ITransport;

-var

-  client : TCustomIpClient;

-  trans  : IStreamTransport;

-begin

-  if FServer = nil then

-  begin

-    raise TTransportException.Create( TTransportException.TExceptionType.NotOpen,

-      'No underlying server socket.');

-  end;

-

-  client := nil;

-  try

-    client := TCustomIpClient.Create(nil);

-

-    if Assigned(fnAccepting)

-    then fnAccepting();

-

-    if not FServer.Accept( client) then

-    begin

-      client.Free;

-      Result := nil;

-      Exit;

-    end;

-

-    if client = nil then

-    begin

-      Result := nil;

-      Exit;

-    end;

-

-    trans := TSocketImpl.Create( client, TRUE, FClientTimeout);

-    client := nil;  // trans owns it now

-

-    if FUseBufferedSocket

-    then result := TBufferedTransportImpl.Create( trans)

-    else result := trans;

-

-  except

-    on E: Exception do begin

-      client.Free;

-      raise TTransportException.Create( E.ToString );

-    end;

-  end;

-end;

-

-procedure TServerSocketImpl.Listen;

-begin

-  if FServer <> nil then

-  begin

-    try

-      FServer.Active := True;

-    except

-      on E: Exception do

-      begin

-        raise TTransportException.Create('Could not accept on listening socket: ' + E.Message);

-      end;

-    end;

-  end;

-end;

-

-procedure TServerSocketImpl.Close;

-begin

-  if FServer <> nil then

-  begin

-    try

-      FServer.Active := False;

-    except

-      on E: Exception do

-      begin

-        raise TTransportException.Create('Error on closing socket : ' + E.Message);

-      end;

-    end;

-  end;

-end;

-

-{ TSocket }

-

-constructor TSocketImpl.Create( const AClient : TCustomIpClient; aOwnsClient : Boolean; ATimeout: Integer = 0);

-var stream : IThriftStream;

-begin

-  FClient := AClient;

-  FTimeout := ATimeout;

-  FOwnsClient := aOwnsClient;

-  stream := TTcpSocketStreamImpl.Create( FClient, FTimeout);

-  inherited Create( stream, stream);

-end;

-

-constructor TSocketImpl.Create(const AHost: string; APort, ATimeout: Integer);

-begin

-  inherited Create(nil,nil);

-  FHost := AHost;

-  FPort := APort;

-  FTimeout := ATimeout;

-  InitSocket;

-end;

-

-destructor TSocketImpl.Destroy;

-begin

-  if FOwnsClient

-  then FreeAndNil( FClient);

-  inherited;

-end;

-

-procedure TSocketImpl.Close;

-begin

-  inherited Close;

-  if FOwnsClient

-  then FreeAndNil( FClient);

-end;

-

-function TSocketImpl.GetIsOpen: Boolean;

-begin

-  Result := (FClient <> nil) and FClient.Connected;

-end;

-

-procedure TSocketImpl.InitSocket;

-var

-  stream : IThriftStream;

-begin

-  if FOwnsClient

-  then FreeAndNil( FClient)

-  else FClient := nil;

-

-  FClient := TTcpClient.Create( nil);

-  FOwnsClient := True;

-

-  stream := TTcpSocketStreamImpl.Create( FClient, FTimeout);

-  FInputStream := stream;

-  FOutputStream := stream;

-end;

-

-procedure TSocketImpl.Open;

-begin

-  if IsOpen then

-  begin

-    raise TTransportException.Create( TTransportException.TExceptionType.AlreadyOpen,

-      'Socket already connected');

-  end;

-

-  if FHost =  '' then

-  begin

-    raise TTransportException.Create( TTransportException.TExceptionType.NotOpen,

-      'Cannot open null host');

-  end;

-

-  if Port <= 0 then

-  begin

-    raise TTransportException.Create( TTransportException.TExceptionType.NotOpen,

-      'Cannot open without port');

-  end;

-

-  if FClient = nil then

-  begin

-    InitSocket;

-  end;

-

-  FClient.RemoteHost := TSocketHost( Host);

-  FClient.RemotePort := TSocketPort( IntToStr( Port));

-  FClient.Connect;

-

-  FInputStream := TTcpSocketStreamImpl.Create( FClient, FTimeout);

-  FOutputStream := FInputStream;

-end;

-

-{ TBufferedStream }

-

-procedure TBufferedStreamImpl.Close;

-begin

-  Flush;

-  FStream := nil;

-

-  FReadBuffer.Free;

-  FReadBuffer := nil;

-

-  FWriteBuffer.Free;

-  FWriteBuffer := nil;

-end;

-

-constructor TBufferedStreamImpl.Create( const AStream: IThriftStream; ABufSize: Integer);

-begin

-  inherited Create;

-  FStream := AStream;

-  FBufSize := ABufSize;

-  FReadBuffer := TMemoryStream.Create;

-  FWriteBuffer := TMemoryStream.Create;

-end;

-

-destructor TBufferedStreamImpl.Destroy;

-begin

-  Close;

-  inherited;

-end;

-

-procedure TBufferedStreamImpl.Flush;

-var

-  buf : TBytes;

-  len : Integer;

-begin

-  if IsOpen then

-  begin

-    len := FWriteBuffer.Size;

-    if len > 0 then

-    begin

-      SetLength( buf, len );

-      FWriteBuffer.Position := 0;

-      FWriteBuffer.Read( Pointer(@buf[0])^, len );

-      FStream.Write( buf, 0, len );

-    end;

-    FWriteBuffer.Clear;

-  end;

-end;

-

-function TBufferedStreamImpl.IsOpen: Boolean;

-begin

-  Result := (FWriteBuffer <> nil)

-        and (FReadBuffer <> nil)

-        and (FStream <> nil);

-end;

-

-procedure TBufferedStreamImpl.Open;

-begin

-

-end;

-

-function TBufferedStreamImpl.Read( var buffer: TBytes; offset: Integer; count: Integer): Integer;

-var

-  nRead : Integer;

-  tempbuf : TBytes;

-begin

-  inherited;

-  Result := 0;

-  if IsOpen then

-  begin

-    while count > 0 do begin

-

-      if FReadBuffer.Position >= FReadBuffer.Size then

-      begin

-        FReadBuffer.Clear;

-        SetLength( tempbuf, FBufSize);

-        nRead := FStream.Read( tempbuf, 0, FBufSize );

-        if nRead = 0 then Break; // avoid infinite loop

-

-        FReadBuffer.WriteBuffer( Pointer(@tempbuf[0])^, nRead );

-        FReadBuffer.Position := 0;

-      end;

-

-      if FReadBuffer.Position < FReadBuffer.Size then

-      begin

-        nRead  := Min( FReadBuffer.Size - FReadBuffer.Position, count);

-        Inc( Result, FReadBuffer.Read( Pointer(@buffer[offset])^, nRead));

-        Dec( count, nRead);

-        Inc( offset, nRead);

-      end;

-    end;

-  end;

-end;

-

-function TBufferedStreamImpl.ToArray: TBytes;

-var

-  len : Integer;

-begin

-  len := 0;

-

-  if IsOpen then

-  begin

-    len := FReadBuffer.Size;

-  end;

-

-  SetLength( Result, len);

-

-  if len > 0 then

-  begin

-    FReadBuffer.Position := 0;

-    FReadBuffer.Read( Pointer(@Result[0])^, len );

-  end;

-end;

-

-procedure TBufferedStreamImpl.Write( const buffer: TBytes; offset: Integer; count: Integer);

-begin

-  inherited;

-  if count > 0 then

-  begin

-    if IsOpen then

-    begin

-      FWriteBuffer.Write( Pointer(@buffer[offset])^, count );

-      if FWriteBuffer.Size > FBufSize then

-      begin

-        Flush;

-      end;

-    end;

-  end;

-end;

-

-{ TStreamTransportImpl }

-

-procedure TStreamTransportImpl.Close;

-begin

-  if FInputStream <> FOutputStream then

-  begin

-    if FInputStream <> nil then

-    begin

-      FInputStream := nil;

-    end;

-    if FOutputStream <> nil then

-    begin

-      FOutputStream := nil;

-    end;

-  end else

-  begin

-    FInputStream := nil;

-    FOutputStream := nil;

-  end;

-end;

-

-constructor TStreamTransportImpl.Create( const AInputStream : IThriftStream; const AOutputStream : IThriftStream);

-begin

-  inherited Create;

-  FInputStream := AInputStream;

-  FOutputStream := AOutputStream;

-end;

-

-destructor TStreamTransportImpl.Destroy;

-begin

-  FInputStream := nil;

-  FOutputStream := nil;

-  inherited;

-end;

-

-procedure TStreamTransportImpl.Flush;

-begin

-  if FOutputStream = nil then

-  begin

-    raise TTransportException.Create( TTransportException.TExceptionType.NotOpen, 'Cannot flush null outputstream' );

-  end;

-

-  FOutputStream.Flush;

-end;

-

-function TStreamTransportImpl.GetInputStream: IThriftStream;

-begin

-  Result := FInputStream;

-end;

-

-function TStreamTransportImpl.GetIsOpen: Boolean;

-begin

-  Result := True;

-end;

-

-function TStreamTransportImpl.GetOutputStream: IThriftStream;

-begin

-  Result := FInputStream;

-end;

-

-procedure TStreamTransportImpl.Open;

-begin

-

-end;

-

-function TStreamTransportImpl.Read(var buf: TBytes; off, len: Integer): Integer;

-begin

-  if FInputStream = nil then

-  begin

-    raise TTransportException.Create( TTransportException.TExceptionType.NotOpen, 'Cannot read from null inputstream' );

-  end;

-  Result := FInputStream.Read( buf, off, len );

-end;

-

-procedure TStreamTransportImpl.Write(const buf: TBytes; off, len: Integer);

-begin

-  if FOutputStream = nil then

-  begin

-    raise TTransportException.Create( TTransportException.TExceptionType.NotOpen, 'Cannot write to null outputstream' );

-  end;

-

-  FOutputStream.Write( buf, off, len );

-end;

-

-{ TBufferedTransportImpl }

-

-constructor TBufferedTransportImpl.Create( const ATransport: IStreamTransport);

-begin

-  //no inherited;  

-  Create( ATransport, 1024 );

-end;

-

-procedure TBufferedTransportImpl.Close;

-begin

-  FTransport.Close;

-end;

-

-constructor TBufferedTransportImpl.Create( const ATransport: IStreamTransport;

-  ABufSize: Integer);

-begin

-  inherited Create;

-  FTransport := ATransport;

-  FBufSize := ABufSize;

-  InitBuffers;

-end;

-

-procedure TBufferedTransportImpl.Flush;

-begin

-  if FOutputBuffer <> nil then

-  begin

-    FOutputBuffer.Flush;

-  end;

-end;

-

-function TBufferedTransportImpl.GetIsOpen: Boolean;

-begin

-  Result := FTransport.IsOpen;

-end;

-

-function TBufferedTransportImpl.GetUnderlyingTransport: ITransport;

-begin

-  Result := FTransport;

-end;

-

-procedure TBufferedTransportImpl.InitBuffers;

-begin

-  if FTransport.InputStream <> nil then

-  begin

-    FInputBuffer := TBufferedStreamImpl.Create( FTransport.InputStream, FBufSize );

-  end;

-  if FTransport.OutputStream <> nil then

-  begin

-    FOutputBuffer := TBufferedStreamImpl.Create( FTransport.OutputStream, FBufSize );

-  end;

-end;

-

-procedure TBufferedTransportImpl.Open;

-begin

-  FTransport.Open

-end;

-

-function TBufferedTransportImpl.Read(var buf: TBytes; off, len: Integer): Integer;

-begin

-  Result := 0;

-  if FInputBuffer <> nil then

-  begin

-    Result := FInputBuffer.Read( buf, off, len );

-  end;

-end;

-

-procedure TBufferedTransportImpl.Write(const buf: TBytes; off, len: Integer);

-begin

-  if FOutputBuffer <> nil then

-  begin

-    FOutputBuffer.Write( buf, off, len );

-  end;

-end;

-

-{ TFramedTransportImpl }

-

-{$IF CompilerVersion < 21.0}

-procedure TFramedTransportImpl_Initialize;

-begin

-  SetLength( TFramedTransportImpl.FHeader_Dummy, TFramedTransportImpl.FHeaderSize);

-  FillChar( TFramedTransportImpl.FHeader_Dummy[0],

-    Length( TFramedTransportImpl.FHeader_Dummy) * SizeOf( Byte ), 0);

-end;

-{$ELSE}

-class constructor TFramedTransportImpl.Create;

-begin

-  SetLength( FHeader_Dummy, FHeaderSize);

-  FillChar( FHeader_Dummy[0], Length( FHeader_Dummy) * SizeOf( Byte ), 0);

-end;

-{$IFEND}

-

-constructor TFramedTransportImpl.Create;

-begin

-  inherited Create;

-  InitWriteBuffer;

-end;

-

-procedure TFramedTransportImpl.Close;

-begin

-  FTransport.Close;

-end;

-

-constructor TFramedTransportImpl.Create( const ATrans: ITransport);

-begin

-  inherited Create;

-  InitWriteBuffer;

-  FTransport := ATrans;

-end;

-

-destructor TFramedTransportImpl.Destroy;

-begin

-  FWriteBuffer.Free;

-  FReadBuffer.Free;

-  inherited;

-end;

-

-procedure TFramedTransportImpl.Flush;

-var

-  buf : TBytes;

-  len : Integer;

-  data_len : Integer;

-

-begin

-  len := FWriteBuffer.Size;

-  SetLength( buf, len);

-  if len > 0 then

-  begin

-    System.Move( FWriteBuffer.Memory^, buf[0], len );

-  end;

-

-  data_len := len - FHeaderSize;

-  if (data_len < 0) then

-  begin

-    raise Exception.Create( 'TFramedTransport.Flush: data_len < 0' );

-  end;

-

-  InitWriteBuffer;

-

-  buf[0] := Byte($FF and (data_len shr 24));

-  buf[1] := Byte($FF and (data_len shr 16));

-  buf[2] := Byte($FF and (data_len shr 8));

-  buf[3] := Byte($FF and data_len);

-

-  FTransport.Write( buf, 0, len );

-  FTransport.Flush;

-end;

-

-function TFramedTransportImpl.GetIsOpen: Boolean;

-begin

-  Result := FTransport.IsOpen;

-end;

-

-type

-  TAccessMemoryStream = class(TMemoryStream)

-  end;

-

-procedure TFramedTransportImpl.InitWriteBuffer;

-begin

-  FWriteBuffer.Free;

-  FWriteBuffer := TMemoryStream.Create;

-  TAccessMemoryStream(FWriteBuffer).Capacity := 1024;

-  FWriteBuffer.Write( Pointer(@FHeader_Dummy[0])^, FHeaderSize);

-end;

-

-procedure TFramedTransportImpl.Open;

-begin

-  FTransport.Open;

-end;

-

-function TFramedTransportImpl.Read(var buf: TBytes; off, len: Integer): Integer;

-var

-  got : Integer;

-begin

-  if FReadBuffer <> nil then

-  begin

-    if len > 0

-    then got := FReadBuffer.Read( Pointer(@buf[off])^, len )

-    else got := 0;

-    if got > 0 then

-    begin

-      Result := got;

-      Exit;

-    end;

-  end;

-

-  ReadFrame;

-  if len > 0

-  then Result := FReadBuffer.Read( Pointer(@buf[off])^, len)

-  else Result := 0;

-end;

-

-procedure TFramedTransportImpl.ReadFrame;

-var

-  i32rd : TBytes;

-  size : Integer;

-  buff : TBytes;

-begin

-  SetLength( i32rd, FHeaderSize );

-  FTransport.ReadAll( i32rd, 0, FHeaderSize);

-  size :=

-    ((i32rd[0] and $FF) shl 24) or

-    ((i32rd[1] and $FF) shl 16) or

-    ((i32rd[2] and $FF) shl 8) or

-     (i32rd[3] and $FF);

-  SetLength( buff, size );

-  FTransport.ReadAll( buff, 0, size );

-  FReadBuffer.Free;

-  FReadBuffer := TMemoryStream.Create;

-  FReadBuffer.Write( Pointer(@buff[0])^, size );

-  FReadBuffer.Position := 0;

-end;

-

-procedure TFramedTransportImpl.Write(const buf: TBytes; off, len: Integer);

-begin

-  if len > 0

-  then FWriteBuffer.Write( Pointer(@buf[off])^, len );

-end;

-

-{ TFramedTransport.TFactory }

-

-function TFramedTransportImpl.TFactory.GetTransport( const ATrans: ITransport): ITransport;

-begin

-  Result := TFramedTransportImpl.Create( ATrans );

-end;

-

-{ TTcpSocketStreamImpl }

-

-procedure TTcpSocketStreamImpl.Close;

-begin

-  FTcpClient.Close;

-end;

-

-constructor TTcpSocketStreamImpl.Create( const ATcpClient: TCustomIpClient; const aTimeout : Integer);

-begin

-  inherited Create;

-  FTcpClient := ATcpClient;

-  FTimeout := aTimeout;

-end;

-

-procedure TTcpSocketStreamImpl.Flush;

-begin

-

-end;

-

-function TTcpSocketStreamImpl.IsOpen: Boolean;

-begin

-  Result := FTcpClient.Active;

-end;

-

-procedure TTcpSocketStreamImpl.Open;

-begin

-  FTcpClient.Open;

-end;

-

-

-function TTcpSocketStreamImpl.Select( ReadReady, WriteReady, ExceptFlag: PBoolean;

-                                      TimeOut: Integer; var wsaError : Integer): Integer;

-var

-  ReadFds: TFDset;

-  ReadFdsptr: PFDset;

-  WriteFds: TFDset;

-  WriteFdsptr: PFDset;

-  ExceptFds: TFDset;

-  ExceptFdsptr: PFDset;

-  tv: timeval;

-  Timeptr: PTimeval;

-  socket : TSocket;

-begin

-  if not FTcpClient.Active then begin

-    wsaError := WSAEINVAL;

-    Exit( SOCKET_ERROR);

-  end;

-

-  socket := FTcpClient.Handle;

-

-  if Assigned(ReadReady) then

-  begin

-    ReadFdsptr := @ReadFds;

-    FD_ZERO(ReadFds);

-    FD_SET(socket, ReadFds);

-  end

-  else

-    ReadFdsptr := nil;

-

-  if Assigned(WriteReady) then

-  begin

-    WriteFdsptr := @WriteFds;

-    FD_ZERO(WriteFds);

-    FD_SET(socket, WriteFds);

-  end

-  else

-    WriteFdsptr := nil;

-

-  if Assigned(ExceptFlag) then

-  begin

-    ExceptFdsptr := @ExceptFds;

-    FD_ZERO(ExceptFds);

-    FD_SET(socket, ExceptFds);

-  end

-  else

-    ExceptFdsptr := nil;

-

-  if TimeOut >= 0 then

-  begin

-    tv.tv_sec := TimeOut div 1000;

-    tv.tv_usec :=  1000 * (TimeOut mod 1000);

-    Timeptr := @tv;

-  end

-  else

-    Timeptr := nil;  // wait forever

-

-  wsaError := 0;

-  try

-{$IFDEF MSWINDOWS}

-    result := WinSock.select(socket + 1, ReadFdsptr, WriteFdsptr, ExceptFdsptr, Timeptr);

-{$ENDIF}

-{$IFDEF LINUX}

-    result := Libc.select(socket + 1, ReadFdsptr, WriteFdsptr, ExceptFdsptr, Timeptr);

-{$ENDIF}

-    if result = SOCKET_ERROR

-    then wsaError := WSAGetLastError;

-

-  except

-    result := SOCKET_ERROR;

-  end;

-

-  if Assigned(ReadReady) then

-    ReadReady^ := FD_ISSET(socket, ReadFds);

-  if Assigned(WriteReady) then

-    WriteReady^ := FD_ISSET(socket, WriteFds);

-  if Assigned(ExceptFlag) then

-    ExceptFlag^ := FD_ISSET(socket, ExceptFds);

-end;

-

-function TTcpSocketStreamImpl.WaitForData( TimeOut : Integer; pBuf : Pointer;

-                                           DesiredBytes : Integer;

-                                           var wsaError : Integer): TWaitForData;

-var bCanRead, bError : Boolean;

-    retval : Integer;

-begin

-  // The select function returns the total number of socket handles that are ready

-  // and contained in the fd_set structures, zero if the time limit expired,

-  // or SOCKET_ERROR if an error occurred. If the return value is SOCKET_ERROR,

-  // WSAGetLastError can be used to retrieve a specific error code.

-  retval := Self.Select( @bCanRead, nil, @bError, TimeOut, wsaError);

-  if retval = SOCKET_ERROR

-  then Exit( TWaitForData.wfd_Error);

-  if (retval = 0) or not bCanRead

-  then Exit( TWaitForData.wfd_Timeout);

-

-  // recv() returns the number of bytes received, or -1 if an error occurred.

-  // The return value will be 0 when the peer has performed an orderly shutdown.

-  retval := recv( FTcpClient.Handle, pBuf^, DesiredBytes, WinSock.MSG_PEEK);

-  if retval <= 0

-  then Exit( TWaitForData.wfd_Error);

-

-  // Enough data ready to be read?

-  if retval = DesiredBytes

-  then result := TWaitForData.wfd_HaveData

-  else result := TWaitForData.wfd_Timeout;

-end;

-

-function TTcpSocketStreamImpl.Read(var buffer: TBytes; offset, count: Integer): Integer;

-var wfd : TWaitForData;

-    wsaError : Integer;

-    pDest : Pointer;

-const

-  SLEEP_TIME = 200;

-begin

-  inherited;

-

-  pDest := Pointer(@buffer[offset]);

-

-  while TRUE do begin

-    if FTimeout > 0

-    then wfd := WaitForData( FTimeout,   pDest, count, wsaError)

-    else wfd := WaitForData( SLEEP_TIME, pDest, count, wsaError);

-

-    case wfd of

-      TWaitForData.wfd_Error    :  Exit(0);

-      TWaitForData.wfd_HaveData :  Break;

-      TWaitForData.wfd_Timeout  :  begin

-        if (FTimeout > 0)

-        then raise TTransportException.Create( TTransportException.TExceptionType.TimedOut,

-                                               SysErrorMessage(Cardinal(wsaError)));

-      end;

-    else

-      ASSERT( FALSE);

-    end;

-  end;

-

-  Result := FTcpClient.ReceiveBuf( pDest^, count);

-end;

-

-function TTcpSocketStreamImpl.ToArray: TBytes;

-var

-  len : Integer;

-begin

-  len := 0;

-  if IsOpen then

-  begin

-    len := FTcpClient.BytesReceived;

-  end;

-

-  SetLength( Result, len );

-

-  if len > 0 then

-  begin

-    FTcpClient.ReceiveBuf( Pointer(@Result[0])^, len);

-  end;

-end;

-

-procedure TTcpSocketStreamImpl.Write(const buffer: TBytes; offset, count: Integer);

-var bCanWrite, bError : Boolean;

-    retval, wsaError : Integer;

-begin

-  inherited;

-

-  if not FTcpClient.Active

-  then raise TTransportException.Create( TTransportException.TExceptionType.NotOpen);

-

-  // The select function returns the total number of socket handles that are ready

-  // and contained in the fd_set structures, zero if the time limit expired,

-  // or SOCKET_ERROR if an error occurred. If the return value is SOCKET_ERROR,

-  // WSAGetLastError can be used to retrieve a specific error code.

-  retval := Self.Select( nil, @bCanWrite, @bError, FTimeOut, wsaError);

-  if retval = SOCKET_ERROR

-  then raise TTransportException.Create( TTransportException.TExceptionType.Unknown,

-                                         SysErrorMessage(Cardinal(wsaError)));

-  if (retval = 0)

-  then raise TTransportException.Create( TTransportException.TExceptionType.TimedOut);

-  if bError or not bCanWrite

-  then raise TTransportException.Create( TTransportException.TExceptionType.Unknown);

-

-  FTcpClient.SendBuf( Pointer(@buffer[offset])^, count);

-end;

-

-{$IF CompilerVersion < 21.0}

-initialization

-begin

-  TFramedTransportImpl_Initialize;

-end;

-{$IFEND}

-

-

-end.

+(*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *)
+
+ {$SCOPEDENUMS ON}
+
+unit Thrift.Transport;
+
+interface
+
+uses
+  Classes,
+  SysUtils,
+  Math,
+  Sockets, WinSock,
+  Generics.Collections,
+  Thrift.Collections,
+  Thrift.Utils,
+  Thrift.Stream,
+  ActiveX,
+  msxml;
+
+type
+  ITransport = interface
+    ['{A4A9FC37-D620-44DC-AD21-662D16364CE4}']
+    function GetIsOpen: Boolean;
+    property IsOpen: Boolean read GetIsOpen;
+    function Peek: Boolean;
+    procedure Open;
+    procedure Close;
+    function Read(var buf: TBytes; off: Integer; len: Integer): Integer;
+    function ReadAll(var buf: TBytes; off: Integer; len: Integer): Integer;
+    procedure Write( const buf: TBytes); overload;
+    procedure Write( const buf: TBytes; off: Integer; len: Integer); overload;
+    procedure Flush;
+  end;
+
+  TTransportImpl = class( TInterfacedObject, ITransport)
+  protected
+    function GetIsOpen: Boolean; virtual; abstract;
+    property IsOpen: Boolean read GetIsOpen;
+    function Peek: Boolean; virtual;
+    procedure Open(); virtual; abstract;
+    procedure Close(); virtual; abstract;
+    function Read(var buf: TBytes; off: Integer; len: Integer): Integer; virtual; abstract;
+    function ReadAll(var buf: TBytes; off: Integer; len: Integer): Integer; virtual;
+    procedure Write( const buf: TBytes); overload; virtual;
+    procedure Write( const buf: TBytes; off: Integer; len: Integer); overload; virtual; abstract;
+    procedure Flush; virtual;
+  end;
+
+  TTransportException = class( Exception )
+  public
+    type
+      TExceptionType = (
+        Unknown,
+        NotOpen,
+        AlreadyOpen,
+        TimedOut,
+        EndOfFile
+      );
+  private
+    FType : TExceptionType;
+  public
+    constructor Create( AType: TExceptionType); overload;
+    constructor Create( const msg: string); overload;
+    constructor Create( AType: TExceptionType; const msg: string); overload;
+    property Type_: TExceptionType read FType;
+  end;
+
+  IHTTPClient = interface( ITransport )
+    ['{0F5DB8AB-710D-4338-AAC9-46B5734C5057}']
+    procedure SetConnectionTimeout(const Value: Integer);
+    function GetConnectionTimeout: Integer;
+    procedure SetReadTimeout(const Value: Integer);
+    function GetReadTimeout: Integer;
+    function GetCustomHeaders: IThriftDictionary<string,string>;
+    procedure SendRequest;
+    property ConnectionTimeout: Integer read GetConnectionTimeout write SetConnectionTimeout;
+    property ReadTimeout: Integer read GetReadTimeout write SetReadTimeout;
+    property CustomHeaders: IThriftDictionary<string,string> read GetCustomHeaders;
+  end;
+
+  THTTPClientImpl = class( TTransportImpl, IHTTPClient)
+  private
+    FUri : string;
+    FInputStream : IThriftStream;
+    FOutputStream : IThriftStream;
+    FConnectionTimeout : Integer;
+    FReadTimeout : Integer;
+    FCustomHeaders : IThriftDictionary<string,string>;
+
+    function CreateRequest: IXMLHTTPRequest;
+  protected
+    function GetIsOpen: Boolean; override;
+    procedure Open(); override;
+    procedure Close(); override;
+    function Read( var buf: TBytes; off: Integer; len: Integer): Integer; override;
+    procedure Write( const buf: TBytes; off: Integer; len: Integer); override;
+    procedure Flush; override;
+
+    procedure SetConnectionTimeout(const Value: Integer);
+    function GetConnectionTimeout: Integer;
+    procedure SetReadTimeout(const Value: Integer);
+    function GetReadTimeout: Integer;
+    function GetCustomHeaders: IThriftDictionary<string,string>;
+    procedure SendRequest;
+    property ConnectionTimeout: Integer read GetConnectionTimeout write SetConnectionTimeout;
+    property ReadTimeout: Integer read GetReadTimeout write SetReadTimeout;
+    property CustomHeaders: IThriftDictionary<string,string> read GetCustomHeaders;
+  public
+    constructor Create( const AUri: string);
+    destructor Destroy; override;
+  end;
+
+  IServerTransport = interface
+    ['{C43B87ED-69EA-47C4-B77C-15E288252900}']
+    procedure Listen;
+    procedure Close;
+    function Accept( const fnAccepting: TProc): ITransport;
+  end;
+
+  TServerTransportImpl = class( TInterfacedObject, IServerTransport)
+  protected
+    procedure Listen; virtual; abstract;
+    procedure Close; virtual; abstract;
+    function Accept( const fnAccepting: TProc): ITransport;  virtual; abstract;
+  end;
+
+  ITransportFactory = interface
+    ['{DD809446-000F-49E1-9BFF-E0D0DC76A9D7}']
+    function GetTransport( const ATrans: ITransport): ITransport;
+  end;
+
+  TTransportFactoryImpl = class( TInterfacedObject, ITransportFactory)
+    function GetTransport( const ATrans: ITransport): ITransport; virtual;
+  end;
+
+  TTcpSocketStreamImpl = class( TThriftStreamImpl )
+  private type
+    TWaitForData = ( wfd_HaveData, wfd_Timeout, wfd_Error);
+  private
+    FTcpClient : TCustomIpClient;
+    FTimeout : Integer;
+    function Select( ReadReady, WriteReady, ExceptFlag: PBoolean;
+                     TimeOut: Integer; var wsaError : Integer): Integer;
+    function WaitForData( TimeOut : Integer; pBuf : Pointer; DesiredBytes: Integer;
+                          var wsaError : Integer): TWaitForData;
+  protected
+    procedure Write( const buffer: TBytes; offset: Integer; count: Integer); override;
+    function Read( var buffer: TBytes; offset: Integer; count: Integer): Integer; override;
+    procedure Open; override;
+    procedure Close; override;
+    procedure Flush; override;
+
+    function IsOpen: Boolean; override;
+    function ToArray: TBytes; override;
+  public
+    constructor Create( const ATcpClient: TCustomIpClient; const aTimeout : Integer = 0);
+  end;
+
+  IStreamTransport = interface( ITransport )
+    ['{A8479B47-2A3E-4421-A9A0-D5A9EDCC634A}']
+    function GetInputStream: IThriftStream;
+    function GetOutputStream: IThriftStream;
+    property InputStream : IThriftStream read GetInputStream;
+    property OutputStream : IThriftStream read GetOutputStream;
+  end;
+
+  TStreamTransportImpl = class( TTransportImpl, IStreamTransport)
+  protected
+    FInputStream : IThriftStream;
+    FOutputStream : IThriftStream;
+  protected
+    function GetIsOpen: Boolean; override;
+
+    function GetInputStream: IThriftStream;
+    function GetOutputStream: IThriftStream;
+  public
+    property InputStream : IThriftStream read GetInputStream;
+    property OutputStream : IThriftStream read GetOutputStream;
+
+    procedure Open; override;
+    procedure Close; override;
+    procedure Flush; override;
+    function Read(var buf: TBytes; off: Integer; len: Integer): Integer; override;
+    procedure Write( const buf: TBytes; off: Integer; len: Integer); override;
+    constructor Create( const AInputStream : IThriftStream; const AOutputStream : IThriftStream);
+    destructor Destroy; override;
+  end;
+
+  TBufferedStreamImpl = class( TThriftStreamImpl)
+  private
+    FStream : IThriftStream;
+    FBufSize : Integer;
+    FReadBuffer : TMemoryStream;
+    FWriteBuffer : TMemoryStream;
+  protected
+    procedure Write( const buffer: TBytes; offset: Integer; count: Integer); override;
+    function Read( var buffer: TBytes; offset: Integer; count: Integer): Integer; override;
+    procedure Open;  override;
+    procedure Close; override;
+    procedure Flush; override;
+    function IsOpen: Boolean; override;
+    function ToArray: TBytes; override;
+  public
+    constructor Create( const AStream: IThriftStream; ABufSize: Integer);
+    destructor Destroy; override;
+  end;
+
+  TServerSocketImpl = class( TServerTransportImpl)
+  private
+    FServer : TTcpServer;
+    FPort : Integer;
+    FClientTimeout : Integer;
+    FUseBufferedSocket : Boolean;
+    FOwnsServer : Boolean;
+  protected
+    function Accept( const fnAccepting: TProc) : ITransport; override;
+  public
+    constructor Create( const AServer: TTcpServer; AClientTimeout: Integer = 0); overload;
+    constructor Create( APort: Integer; AClientTimeout: Integer = 0; AUseBufferedSockets: Boolean = FALSE); overload;
+    destructor Destroy; override;
+    procedure Listen; override;
+    procedure Close; override;
+  end;
+
+  TBufferedTransportImpl = class( TTransportImpl )
+  private
+    FInputBuffer : IThriftStream;
+    FOutputBuffer : IThriftStream;
+    FTransport : IStreamTransport;
+    FBufSize : Integer;
+
+    procedure InitBuffers;
+    function GetUnderlyingTransport: ITransport;
+  protected
+    function GetIsOpen: Boolean; override;
+    procedure Flush; override;
+  public
+    procedure Open(); override;
+    procedure Close(); override;
+    function Read(var buf: TBytes; off: Integer; len: Integer): Integer; override;
+    procedure Write( const buf: TBytes; off: Integer; len: Integer); override;
+    constructor Create( const ATransport : IStreamTransport ); overload;
+    constructor Create( const ATransport : IStreamTransport; ABufSize: Integer); overload;
+    property UnderlyingTransport: ITransport read GetUnderlyingTransport;
+    property IsOpen: Boolean read GetIsOpen;
+  end;
+
+  TSocketImpl = class(TStreamTransportImpl)
+  private
+    FClient : TCustomIpClient;
+    FOwnsClient : Boolean;
+    FHost : string;
+    FPort : Integer;
+    FTimeout : Integer;
+
+    procedure InitSocket;
+  protected
+    function GetIsOpen: Boolean; override;
+  public
+    procedure Open; override;
+    constructor Create( const AClient : TCustomIpClient; aOwnsClient : Boolean; ATimeout: Integer = 0); overload;
+    constructor Create( const AHost: string; APort: Integer; ATimeout: Integer = 0); overload;
+    destructor Destroy; override;
+    procedure Close; override;
+    property TcpClient: TCustomIpClient read FClient;
+    property Host : string read FHost;
+    property Port: Integer read FPort;
+  end;
+
+  TFramedTransportImpl = class( TTransportImpl)
+  private const
+    FHeaderSize : Integer = 4;
+  private class var
+    FHeader_Dummy : array of Byte;
+  protected
+    FTransport : ITransport;
+    FWriteBuffer : TMemoryStream;
+    FReadBuffer : TMemoryStream;
+
+    procedure InitWriteBuffer;
+    procedure ReadFrame;
+  public
+    type
+      TFactory = class( TTransportFactoryImpl )
+      public
+        function GetTransport( const ATrans: ITransport): ITransport; override;
+      end;
+
+{$IF CompilerVersion >= 21.0}
+    class constructor Create;
+{$IFEND}
+    constructor Create; overload;
+    constructor Create( const ATrans: ITransport); overload;
+    destructor Destroy; override;
+
+    procedure Open(); override;
+    function GetIsOpen: Boolean; override;
+
+    procedure Close(); override;
+    function Read(var buf: TBytes; off: Integer; len: Integer): Integer; override;
+    procedure Write( const buf: TBytes; off: Integer; len: Integer); override;
+    procedure Flush; override;
+  end;
+
+{$IF CompilerVersion < 21.0}
+procedure TFramedTransportImpl_Initialize;
+{$IFEND}
+
+const
+  DEFAULT_THRIFT_TIMEOUT = 5 * 1000; // ms
+
+
+implementation
+
+{ TTransportImpl }
+
+procedure TTransportImpl.Flush;
+begin
+
+end;
+
+function TTransportImpl.Peek: Boolean;
+begin
+  Result := IsOpen;
+end;
+
+function TTransportImpl.ReadAll( var buf: TBytes; off, len: Integer): Integer;
+var
+  got : Integer;
+  ret : Integer;
+begin
+  got := 0;
+  while ( got < len) do
+  begin
+    ret := Read( buf, off + got, len - got);
+    if ( ret <= 0 ) then
+    begin
+      raise TTransportException.Create( 'Cannot read, Remote side has closed' );
+    end;
+    got := got + ret;
+  end;
+  Result := got;
+end;
+
+procedure TTransportImpl.Write( const buf: TBytes);
+begin
+  Self.Write( buf, 0, Length(buf) );
+end;
+
+{ THTTPClientImpl }
+
+procedure THTTPClientImpl.Close;
+begin
+  FInputStream := nil;
+  FOutputStream := nil;
+end;
+
+constructor THTTPClientImpl.Create(const AUri: string);
+begin
+  inherited Create;
+  FUri := AUri;
+  FCustomHeaders := TThriftDictionaryImpl<string,string>.Create;
+  FOutputStream := TThriftStreamAdapterDelphi.Create( TMemoryStream.Create, True);
+end;
+
+function THTTPClientImpl.CreateRequest: IXMLHTTPRequest;
+var
+  pair : TPair<string,string>;
+begin
+{$IF CompilerVersion >= 21.0}
+  Result := CoXMLHTTP.Create;
+{$ELSE}
+  Result := CoXMLHTTPRequest.Create;
+{$IFEND}
+
+  Result.open('POST', FUri, False, '', '');
+  Result.setRequestHeader( 'Content-Type', 'application/x-thrift');
+  Result.setRequestHeader( 'Accept', 'application/x-thrift');
+  Result.setRequestHeader( 'User-Agent', 'Delphi/IHTTPClient');
+
+  for pair in FCustomHeaders do
+  begin
+    Result.setRequestHeader( pair.Key, pair.Value );
+  end;
+end;
+
+destructor THTTPClientImpl.Destroy;
+begin
+  Close;
+  inherited;
+end;
+
+procedure THTTPClientImpl.Flush;
+begin
+  try
+    SendRequest;
+  finally
+    FOutputStream := nil;
+    FOutputStream := TThriftStreamAdapterDelphi.Create( TMemoryStream.Create, True);
+  end;
+end;
+
+function THTTPClientImpl.GetConnectionTimeout: Integer;
+begin
+  Result := FConnectionTimeout;
+end;
+
+function THTTPClientImpl.GetCustomHeaders: IThriftDictionary<string,string>;
+begin
+  Result := FCustomHeaders;
+end;
+
+function THTTPClientImpl.GetIsOpen: Boolean;
+begin
+  Result := True;
+end;
+
+function THTTPClientImpl.GetReadTimeout: Integer;
+begin
+  Result := FReadTimeout;
+end;
+
+procedure THTTPClientImpl.Open;
+begin
+
+end;
+
+function THTTPClientImpl.Read( var buf: TBytes; off, len: Integer): Integer;
+begin
+  if FInputStream = nil then
+  begin
+    raise TTransportException.Create( TTransportException.TExceptionType.NotOpen,
+      'No request has been sent');
+  end;
+  try
+    Result := FInputStream.Read( buf, off, len )
+  except
+    on E: Exception do
+    begin
+      raise TTransportException.Create( TTransportException.TExceptionType.Unknown,
+        E.Message);
+    end;
+  end;
+end;
+
+procedure THTTPClientImpl.SendRequest;
+var
+  xmlhttp : IXMLHTTPRequest;
+  ms : TMemoryStream;
+  a : TBytes;
+  len : Integer;
+begin
+  xmlhttp := CreateRequest;
+
+  ms := TMemoryStream.Create;
+  try
+    a := FOutputStream.ToArray;
+    len := Length(a);
+    if len > 0 then
+    begin
+      ms.WriteBuffer( Pointer(@a[0])^, len);
+    end;
+    ms.Position := 0;
+    xmlhttp.send( IUnknown( TStreamAdapter.Create( ms, soReference )));
+    FInputStream := nil;
+    FInputStream := TThriftStreamAdapterCOM.Create( IUnknown( xmlhttp.responseStream) as IStream);
+  finally
+    ms.Free;
+  end;
+end;
+
+procedure THTTPClientImpl.SetConnectionTimeout(const Value: Integer);
+begin
+  FConnectionTimeout := Value;
+end;
+
+procedure THTTPClientImpl.SetReadTimeout(const Value: Integer);
+begin
+  FReadTimeout := Value
+end;
+
+procedure THTTPClientImpl.Write( const buf: TBytes; off, len: Integer);
+begin
+  FOutputStream.Write( buf, off, len);
+end;
+
+{ TTransportException }
+
+constructor TTransportException.Create(AType: TExceptionType);
+begin
+  //no inherited;
+  Create( AType, '' )
+end;
+
+constructor TTransportException.Create(AType: TExceptionType;
+  const msg: string);
+begin
+  inherited Create(msg);
+  FType := AType;
+end;
+
+constructor TTransportException.Create(const msg: string);
+begin
+  inherited Create(msg);
+end;
+
+{ TTransportFactoryImpl }
+
+function TTransportFactoryImpl.GetTransport( const ATrans: ITransport): ITransport;
+begin
+  Result := ATrans;
+end;
+
+{ TServerSocket }
+
+constructor TServerSocketImpl.Create( const AServer: TTcpServer; AClientTimeout: Integer);
+begin
+  inherited Create;
+  FServer := AServer;
+  FClientTimeout := AClientTimeout;
+end;
+
+constructor TServerSocketImpl.Create(APort, AClientTimeout: Integer; AUseBufferedSockets: Boolean);
+begin
+  inherited Create;
+  FPort := APort;
+  FClientTimeout := AClientTimeout;
+  FUseBufferedSocket := AUseBufferedSockets;
+  FOwnsServer := True;
+  FServer := TTcpServer.Create( nil );
+  FServer.BlockMode := bmBlocking;
+{$IF CompilerVersion >= 21.0}
+  FServer.LocalPort := AnsiString( IntToStr( FPort));
+{$ELSE}
+  FServer.LocalPort := IntToStr( FPort);
+{$IFEND}
+end;
+
+destructor TServerSocketImpl.Destroy;
+begin
+  if FOwnsServer then begin
+    FServer.Free;
+    FServer := nil;
+  end;
+  inherited;
+end;
+
+function TServerSocketImpl.Accept( const fnAccepting: TProc): ITransport;
+var
+  client : TCustomIpClient;
+  trans  : IStreamTransport;
+begin
+  if FServer = nil then
+  begin
+    raise TTransportException.Create( TTransportException.TExceptionType.NotOpen,
+      'No underlying server socket.');
+  end;
+
+  client := nil;
+  try
+    client := TCustomIpClient.Create(nil);
+
+    if Assigned(fnAccepting)
+    then fnAccepting();
+
+    if not FServer.Accept( client) then
+    begin
+      client.Free;
+      Result := nil;
+      Exit;
+    end;
+
+    if client = nil then
+    begin
+      Result := nil;
+      Exit;
+    end;
+
+    trans := TSocketImpl.Create( client, TRUE, FClientTimeout);
+    client := nil;  // trans owns it now
+
+    if FUseBufferedSocket
+    then result := TBufferedTransportImpl.Create( trans)
+    else result := trans;
+
+  except
+    on E: Exception do begin
+      client.Free;
+      raise TTransportException.Create( E.ToString );
+    end;
+  end;
+end;
+
+procedure TServerSocketImpl.Listen;
+begin
+  if FServer <> nil then
+  begin
+    try
+      FServer.Active := True;
+    except
+      on E: Exception do
+      begin
+        raise TTransportException.Create('Could not accept on listening socket: ' + E.Message);
+      end;
+    end;
+  end;
+end;
+
+procedure TServerSocketImpl.Close;
+begin
+  if FServer <> nil then
+  begin
+    try
+      FServer.Active := False;
+    except
+      on E: Exception do
+      begin
+        raise TTransportException.Create('Error on closing socket : ' + E.Message);
+      end;
+    end;
+  end;
+end;
+
+{ TSocket }
+
+constructor TSocketImpl.Create( const AClient : TCustomIpClient; aOwnsClient : Boolean; ATimeout: Integer = 0);
+var stream : IThriftStream;
+begin
+  FClient := AClient;
+  FTimeout := ATimeout;
+  FOwnsClient := aOwnsClient;
+  stream := TTcpSocketStreamImpl.Create( FClient, FTimeout);
+  inherited Create( stream, stream);
+end;
+
+constructor TSocketImpl.Create(const AHost: string; APort, ATimeout: Integer);
+begin
+  inherited Create(nil,nil);
+  FHost := AHost;
+  FPort := APort;
+  FTimeout := ATimeout;
+  InitSocket;
+end;
+
+destructor TSocketImpl.Destroy;
+begin
+  if FOwnsClient
+  then FreeAndNil( FClient);
+  inherited;
+end;
+
+procedure TSocketImpl.Close;
+begin
+  inherited Close;
+  if FOwnsClient
+  then FreeAndNil( FClient);
+end;
+
+function TSocketImpl.GetIsOpen: Boolean;
+begin
+  Result := (FClient <> nil) and FClient.Connected;
+end;
+
+procedure TSocketImpl.InitSocket;
+var
+  stream : IThriftStream;
+begin
+  if FOwnsClient
+  then FreeAndNil( FClient)
+  else FClient := nil;
+
+  FClient := TTcpClient.Create( nil);
+  FOwnsClient := True;
+
+  stream := TTcpSocketStreamImpl.Create( FClient, FTimeout);
+  FInputStream := stream;
+  FOutputStream := stream;
+end;
+
+procedure TSocketImpl.Open;
+begin
+  if IsOpen then
+  begin
+    raise TTransportException.Create( TTransportException.TExceptionType.AlreadyOpen,
+      'Socket already connected');
+  end;
+
+  if FHost =  '' then
+  begin
+    raise TTransportException.Create( TTransportException.TExceptionType.NotOpen,
+      'Cannot open null host');
+  end;
+
+  if Port <= 0 then
+  begin
+    raise TTransportException.Create( TTransportException.TExceptionType.NotOpen,
+      'Cannot open without port');
+  end;
+
+  if FClient = nil then
+  begin
+    InitSocket;
+  end;
+
+  FClient.RemoteHost := TSocketHost( Host);
+  FClient.RemotePort := TSocketPort( IntToStr( Port));
+  FClient.Connect;
+
+  FInputStream := TTcpSocketStreamImpl.Create( FClient, FTimeout);
+  FOutputStream := FInputStream;
+end;
+
+{ TBufferedStream }
+
+procedure TBufferedStreamImpl.Close;
+begin
+  Flush;
+  FStream := nil;
+
+  FReadBuffer.Free;
+  FReadBuffer := nil;
+
+  FWriteBuffer.Free;
+  FWriteBuffer := nil;
+end;
+
+constructor TBufferedStreamImpl.Create( const AStream: IThriftStream; ABufSize: Integer);
+begin
+  inherited Create;
+  FStream := AStream;
+  FBufSize := ABufSize;
+  FReadBuffer := TMemoryStream.Create;
+  FWriteBuffer := TMemoryStream.Create;
+end;
+
+destructor TBufferedStreamImpl.Destroy;
+begin
+  Close;
+  inherited;
+end;
+
+procedure TBufferedStreamImpl.Flush;
+var
+  buf : TBytes;
+  len : Integer;
+begin
+  if IsOpen then
+  begin
+    len := FWriteBuffer.Size;
+    if len > 0 then
+    begin
+      SetLength( buf, len );
+      FWriteBuffer.Position := 0;
+      FWriteBuffer.Read( Pointer(@buf[0])^, len );
+      FStream.Write( buf, 0, len );
+    end;
+    FWriteBuffer.Clear;
+  end;
+end;
+
+function TBufferedStreamImpl.IsOpen: Boolean;
+begin
+  Result := (FWriteBuffer <> nil)
+        and (FReadBuffer <> nil)
+        and (FStream <> nil);
+end;
+
+procedure TBufferedStreamImpl.Open;
+begin
+
+end;
+
+function TBufferedStreamImpl.Read( var buffer: TBytes; offset: Integer; count: Integer): Integer;
+var
+  nRead : Integer;
+  tempbuf : TBytes;
+begin
+  inherited;
+  Result := 0;
+  if IsOpen then
+  begin
+    while count > 0 do begin
+
+      if FReadBuffer.Position >= FReadBuffer.Size then
+      begin
+        FReadBuffer.Clear;
+        SetLength( tempbuf, FBufSize);
+        nRead := FStream.Read( tempbuf, 0, FBufSize );
+        if nRead = 0 then Break; // avoid infinite loop
+
+        FReadBuffer.WriteBuffer( Pointer(@tempbuf[0])^, nRead );
+        FReadBuffer.Position := 0;
+      end;
+
+      if FReadBuffer.Position < FReadBuffer.Size then
+      begin
+        nRead  := Min( FReadBuffer.Size - FReadBuffer.Position, count);
+        Inc( Result, FReadBuffer.Read( Pointer(@buffer[offset])^, nRead));
+        Dec( count, nRead);
+        Inc( offset, nRead);
+      end;
+    end;
+  end;
+end;
+
+function TBufferedStreamImpl.ToArray: TBytes;
+var
+  len : Integer;
+begin
+  len := 0;
+
+  if IsOpen then
+  begin
+    len := FReadBuffer.Size;
+  end;
+
+  SetLength( Result, len);
+
+  if len > 0 then
+  begin
+    FReadBuffer.Position := 0;
+    FReadBuffer.Read( Pointer(@Result[0])^, len );
+  end;
+end;
+
+procedure TBufferedStreamImpl.Write( const buffer: TBytes; offset: Integer; count: Integer);
+begin
+  inherited;
+  if count > 0 then
+  begin
+    if IsOpen then
+    begin
+      FWriteBuffer.Write( Pointer(@buffer[offset])^, count );
+      if FWriteBuffer.Size > FBufSize then
+      begin
+        Flush;
+      end;
+    end;
+  end;
+end;
+
+{ TStreamTransportImpl }
+
+procedure TStreamTransportImpl.Close;
+begin
+  if FInputStream <> FOutputStream then
+  begin
+    if FInputStream <> nil then
+    begin
+      FInputStream := nil;
+    end;
+    if FOutputStream <> nil then
+    begin
+      FOutputStream := nil;
+    end;
+  end else
+  begin
+    FInputStream := nil;
+    FOutputStream := nil;
+  end;
+end;
+
+constructor TStreamTransportImpl.Create( const AInputStream : IThriftStream; const AOutputStream : IThriftStream);
+begin
+  inherited Create;
+  FInputStream := AInputStream;
+  FOutputStream := AOutputStream;
+end;
+
+destructor TStreamTransportImpl.Destroy;
+begin
+  FInputStream := nil;
+  FOutputStream := nil;
+  inherited;
+end;
+
+procedure TStreamTransportImpl.Flush;
+begin
+  if FOutputStream = nil then
+  begin
+    raise TTransportException.Create( TTransportException.TExceptionType.NotOpen, 'Cannot flush null outputstream' );
+  end;
+
+  FOutputStream.Flush;
+end;
+
+function TStreamTransportImpl.GetInputStream: IThriftStream;
+begin
+  Result := FInputStream;
+end;
+
+function TStreamTransportImpl.GetIsOpen: Boolean;
+begin
+  Result := True;
+end;
+
+function TStreamTransportImpl.GetOutputStream: IThriftStream;
+begin
+  Result := FInputStream;
+end;
+
+procedure TStreamTransportImpl.Open;
+begin
+
+end;
+
+function TStreamTransportImpl.Read(var buf: TBytes; off, len: Integer): Integer;
+begin
+  if FInputStream = nil then
+  begin
+    raise TTransportException.Create( TTransportException.TExceptionType.NotOpen, 'Cannot read from null inputstream' );
+  end;
+  Result := FInputStream.Read( buf, off, len );
+end;
+
+procedure TStreamTransportImpl.Write(const buf: TBytes; off, len: Integer);
+begin
+  if FOutputStream = nil then
+  begin
+    raise TTransportException.Create( TTransportException.TExceptionType.NotOpen, 'Cannot write to null outputstream' );
+  end;
+
+  FOutputStream.Write( buf, off, len );
+end;
+
+{ TBufferedTransportImpl }
+
+constructor TBufferedTransportImpl.Create( const ATransport: IStreamTransport);
+begin
+  //no inherited;
+  Create( ATransport, 1024 );
+end;
+
+procedure TBufferedTransportImpl.Close;
+begin
+  FTransport.Close;
+end;
+
+constructor TBufferedTransportImpl.Create( const ATransport: IStreamTransport;
+  ABufSize: Integer);
+begin
+  inherited Create;
+  FTransport := ATransport;
+  FBufSize := ABufSize;
+  InitBuffers;
+end;
+
+procedure TBufferedTransportImpl.Flush;
+begin
+  if FOutputBuffer <> nil then
+  begin
+    FOutputBuffer.Flush;
+  end;
+end;
+
+function TBufferedTransportImpl.GetIsOpen: Boolean;
+begin
+  Result := FTransport.IsOpen;
+end;
+
+function TBufferedTransportImpl.GetUnderlyingTransport: ITransport;
+begin
+  Result := FTransport;
+end;
+
+procedure TBufferedTransportImpl.InitBuffers;
+begin
+  if FTransport.InputStream <> nil then
+  begin
+    FInputBuffer := TBufferedStreamImpl.Create( FTransport.InputStream, FBufSize );
+  end;
+  if FTransport.OutputStream <> nil then
+  begin
+    FOutputBuffer := TBufferedStreamImpl.Create( FTransport.OutputStream, FBufSize );
+  end;
+end;
+
+procedure TBufferedTransportImpl.Open;
+begin
+  FTransport.Open
+end;
+
+function TBufferedTransportImpl.Read(var buf: TBytes; off, len: Integer): Integer;
+begin
+  Result := 0;
+  if FInputBuffer <> nil then
+  begin
+    Result := FInputBuffer.Read( buf, off, len );
+  end;
+end;
+
+procedure TBufferedTransportImpl.Write(const buf: TBytes; off, len: Integer);
+begin
+  if FOutputBuffer <> nil then
+  begin
+    FOutputBuffer.Write( buf, off, len );
+  end;
+end;
+
+{ TFramedTransportImpl }
+
+{$IF CompilerVersion < 21.0}
+procedure TFramedTransportImpl_Initialize;
+begin
+  SetLength( TFramedTransportImpl.FHeader_Dummy, TFramedTransportImpl.FHeaderSize);
+  FillChar( TFramedTransportImpl.FHeader_Dummy[0],
+    Length( TFramedTransportImpl.FHeader_Dummy) * SizeOf( Byte ), 0);
+end;
+{$ELSE}
+class constructor TFramedTransportImpl.Create;
+begin
+  SetLength( FHeader_Dummy, FHeaderSize);
+  FillChar( FHeader_Dummy[0], Length( FHeader_Dummy) * SizeOf( Byte ), 0);
+end;
+{$IFEND}
+
+constructor TFramedTransportImpl.Create;
+begin
+  inherited Create;
+  InitWriteBuffer;
+end;
+
+procedure TFramedTransportImpl.Close;
+begin
+  FTransport.Close;
+end;
+
+constructor TFramedTransportImpl.Create( const ATrans: ITransport);
+begin
+  inherited Create;
+  InitWriteBuffer;
+  FTransport := ATrans;
+end;
+
+destructor TFramedTransportImpl.Destroy;
+begin
+  FWriteBuffer.Free;
+  FReadBuffer.Free;
+  inherited;
+end;
+
+procedure TFramedTransportImpl.Flush;
+var
+  buf : TBytes;
+  len : Integer;
+  data_len : Integer;
+
+begin
+  len := FWriteBuffer.Size;
+  SetLength( buf, len);
+  if len > 0 then
+  begin
+    System.Move( FWriteBuffer.Memory^, buf[0], len );
+  end;
+
+  data_len := len - FHeaderSize;
+  if (data_len < 0) then
+  begin
+    raise Exception.Create( 'TFramedTransport.Flush: data_len < 0' );
+  end;
+
+  InitWriteBuffer;
+
+  buf[0] := Byte($FF and (data_len shr 24));
+  buf[1] := Byte($FF and (data_len shr 16));
+  buf[2] := Byte($FF and (data_len shr 8));
+  buf[3] := Byte($FF and data_len);
+
+  FTransport.Write( buf, 0, len );
+  FTransport.Flush;
+end;
+
+function TFramedTransportImpl.GetIsOpen: Boolean;
+begin
+  Result := FTransport.IsOpen;
+end;
+
+type
+  TAccessMemoryStream = class(TMemoryStream)
+  end;
+
+procedure TFramedTransportImpl.InitWriteBuffer;
+begin
+  FWriteBuffer.Free;
+  FWriteBuffer := TMemoryStream.Create;
+  TAccessMemoryStream(FWriteBuffer).Capacity := 1024;
+  FWriteBuffer.Write( Pointer(@FHeader_Dummy[0])^, FHeaderSize);
+end;
+
+procedure TFramedTransportImpl.Open;
+begin
+  FTransport.Open;
+end;
+
+function TFramedTransportImpl.Read(var buf: TBytes; off, len: Integer): Integer;
+var
+  got : Integer;
+begin
+  if FReadBuffer <> nil then
+  begin
+    if len > 0
+    then got := FReadBuffer.Read( Pointer(@buf[off])^, len )
+    else got := 0;
+    if got > 0 then
+    begin
+      Result := got;
+      Exit;
+    end;
+  end;
+
+  ReadFrame;
+  if len > 0
+  then Result := FReadBuffer.Read( Pointer(@buf[off])^, len)
+  else Result := 0;
+end;
+
+procedure TFramedTransportImpl.ReadFrame;
+var
+  i32rd : TBytes;
+  size : Integer;
+  buff : TBytes;
+begin
+  SetLength( i32rd, FHeaderSize );
+  FTransport.ReadAll( i32rd, 0, FHeaderSize);
+  size :=
+    ((i32rd[0] and $FF) shl 24) or
+    ((i32rd[1] and $FF) shl 16) or
+    ((i32rd[2] and $FF) shl 8) or
+     (i32rd[3] and $FF);
+  SetLength( buff, size );
+  FTransport.ReadAll( buff, 0, size );
+  FReadBuffer.Free;
+  FReadBuffer := TMemoryStream.Create;
+  FReadBuffer.Write( Pointer(@buff[0])^, size );
+  FReadBuffer.Position := 0;
+end;
+
+procedure TFramedTransportImpl.Write(const buf: TBytes; off, len: Integer);
+begin
+  if len > 0
+  then FWriteBuffer.Write( Pointer(@buf[off])^, len );
+end;
+
+{ TFramedTransport.TFactory }
+
+function TFramedTransportImpl.TFactory.GetTransport( const ATrans: ITransport): ITransport;
+begin
+  Result := TFramedTransportImpl.Create( ATrans );
+end;
+
+{ TTcpSocketStreamImpl }
+
+procedure TTcpSocketStreamImpl.Close;
+begin
+  FTcpClient.Close;
+end;
+
+constructor TTcpSocketStreamImpl.Create( const ATcpClient: TCustomIpClient; const aTimeout : Integer);
+begin
+  inherited Create;
+  FTcpClient := ATcpClient;
+  FTimeout := aTimeout;
+end;
+
+procedure TTcpSocketStreamImpl.Flush;
+begin
+
+end;
+
+function TTcpSocketStreamImpl.IsOpen: Boolean;
+begin
+  Result := FTcpClient.Active;
+end;
+
+procedure TTcpSocketStreamImpl.Open;
+begin
+  FTcpClient.Open;
+end;
+
+
+function TTcpSocketStreamImpl.Select( ReadReady, WriteReady, ExceptFlag: PBoolean;
+                                      TimeOut: Integer; var wsaError : Integer): Integer;
+var
+  ReadFds: TFDset;
+  ReadFdsptr: PFDset;
+  WriteFds: TFDset;
+  WriteFdsptr: PFDset;
+  ExceptFds: TFDset;
+  ExceptFdsptr: PFDset;
+  tv: timeval;
+  Timeptr: PTimeval;
+  socket : TSocket;
+begin
+  if not FTcpClient.Active then begin
+    wsaError := WSAEINVAL;
+    Exit( SOCKET_ERROR);
+  end;
+
+  socket := FTcpClient.Handle;
+
+  if Assigned(ReadReady) then
+  begin
+    ReadFdsptr := @ReadFds;
+    FD_ZERO(ReadFds);
+    FD_SET(socket, ReadFds);
+  end
+  else
+    ReadFdsptr := nil;
+
+  if Assigned(WriteReady) then
+  begin
+    WriteFdsptr := @WriteFds;
+    FD_ZERO(WriteFds);
+    FD_SET(socket, WriteFds);
+  end
+  else
+    WriteFdsptr := nil;
+
+  if Assigned(ExceptFlag) then
+  begin
+    ExceptFdsptr := @ExceptFds;
+    FD_ZERO(ExceptFds);
+    FD_SET(socket, ExceptFds);
+  end
+  else
+    ExceptFdsptr := nil;
+
+  if TimeOut >= 0 then
+  begin
+    tv.tv_sec := TimeOut div 1000;
+    tv.tv_usec :=  1000 * (TimeOut mod 1000);
+    Timeptr := @tv;
+  end
+  else
+    Timeptr := nil;  // wait forever
+
+  wsaError := 0;
+  try
+{$IFDEF MSWINDOWS}
+    result := WinSock.select(socket + 1, ReadFdsptr, WriteFdsptr, ExceptFdsptr, Timeptr);
+{$ENDIF}
+{$IFDEF LINUX}
+    result := Libc.select(socket + 1, ReadFdsptr, WriteFdsptr, ExceptFdsptr, Timeptr);
+{$ENDIF}
+    if result = SOCKET_ERROR
+    then wsaError := WSAGetLastError;
+
+  except
+    result := SOCKET_ERROR;
+  end;
+
+  if Assigned(ReadReady) then
+    ReadReady^ := FD_ISSET(socket, ReadFds);
+  if Assigned(WriteReady) then
+    WriteReady^ := FD_ISSET(socket, WriteFds);
+  if Assigned(ExceptFlag) then
+    ExceptFlag^ := FD_ISSET(socket, ExceptFds);
+end;
+
+function TTcpSocketStreamImpl.WaitForData( TimeOut : Integer; pBuf : Pointer;
+                                           DesiredBytes : Integer;
+                                           var wsaError : Integer): TWaitForData;
+var bCanRead, bError : Boolean;
+    retval : Integer;
+begin
+  // The select function returns the total number of socket handles that are ready
+  // and contained in the fd_set structures, zero if the time limit expired,
+  // or SOCKET_ERROR if an error occurred. If the return value is SOCKET_ERROR,
+  // WSAGetLastError can be used to retrieve a specific error code.
+  retval := Self.Select( @bCanRead, nil, @bError, TimeOut, wsaError);
+  if retval = SOCKET_ERROR
+  then Exit( TWaitForData.wfd_Error);
+  if (retval = 0) or not bCanRead
+  then Exit( TWaitForData.wfd_Timeout);
+
+  // recv() returns the number of bytes received, or -1 if an error occurred.
+  // The return value will be 0 when the peer has performed an orderly shutdown.
+  retval := recv( FTcpClient.Handle, pBuf^, DesiredBytes, WinSock.MSG_PEEK);
+  if retval <= 0
+  then Exit( TWaitForData.wfd_Error);
+
+  // Enough data ready to be read?
+  if retval = DesiredBytes
+  then result := TWaitForData.wfd_HaveData
+  else result := TWaitForData.wfd_Timeout;
+end;
+
+function TTcpSocketStreamImpl.Read(var buffer: TBytes; offset, count: Integer): Integer;
+var wfd : TWaitForData;
+    wsaError : Integer;
+    pDest : Pointer;
+const
+  SLEEP_TIME = 200;
+begin
+  inherited;
+
+  pDest := Pointer(@buffer[offset]);
+
+  while TRUE do begin
+    if FTimeout > 0
+    then wfd := WaitForData( FTimeout,   pDest, count, wsaError)
+    else wfd := WaitForData( SLEEP_TIME, pDest, count, wsaError);
+
+    case wfd of
+      TWaitForData.wfd_Error    :  Exit(0);
+      TWaitForData.wfd_HaveData :  Break;
+      TWaitForData.wfd_Timeout  :  begin
+        if (FTimeout > 0)
+        then raise TTransportException.Create( TTransportException.TExceptionType.TimedOut,
+                                               SysErrorMessage(Cardinal(wsaError)));
+      end;
+    else
+      ASSERT( FALSE);
+    end;
+  end;
+
+  Result := FTcpClient.ReceiveBuf( pDest^, count);
+end;
+
+function TTcpSocketStreamImpl.ToArray: TBytes;
+var
+  len : Integer;
+begin
+  len := 0;
+  if IsOpen then
+  begin
+    len := FTcpClient.BytesReceived;
+  end;
+
+  SetLength( Result, len );
+
+  if len > 0 then
+  begin
+    FTcpClient.ReceiveBuf( Pointer(@Result[0])^, len);
+  end;
+end;
+
+procedure TTcpSocketStreamImpl.Write(const buffer: TBytes; offset, count: Integer);
+var bCanWrite, bError : Boolean;
+    retval, wsaError : Integer;
+begin
+  inherited;
+
+  if not FTcpClient.Active
+  then raise TTransportException.Create( TTransportException.TExceptionType.NotOpen);
+
+  // The select function returns the total number of socket handles that are ready
+  // and contained in the fd_set structures, zero if the time limit expired,
+  // or SOCKET_ERROR if an error occurred. If the return value is SOCKET_ERROR,
+  // WSAGetLastError can be used to retrieve a specific error code.
+  retval := Self.Select( nil, @bCanWrite, @bError, FTimeOut, wsaError);
+  if retval = SOCKET_ERROR
+  then raise TTransportException.Create( TTransportException.TExceptionType.Unknown,
+                                         SysErrorMessage(Cardinal(wsaError)));
+  if (retval = 0)
+  then raise TTransportException.Create( TTransportException.TExceptionType.TimedOut);
+  if bError or not bCanWrite
+  then raise TTransportException.Create( TTransportException.TExceptionType.Unknown);
+
+  FTcpClient.SendBuf( Pointer(@buffer[offset])^, count);
+end;
+
+{$IF CompilerVersion < 21.0}
+initialization
+begin
+  TFramedTransportImpl_Initialize;
+end;
+{$IFEND}
+
+
+end.
diff --git a/lib/delphi/src/Thrift.TypeRegistry.pas b/lib/delphi/src/Thrift.TypeRegistry.pas
index cc22952..c18e97f 100644
--- a/lib/delphi/src/Thrift.TypeRegistry.pas
+++ b/lib/delphi/src/Thrift.TypeRegistry.pas
@@ -1,95 +1,95 @@
-(*

- * Licensed to the Apache Software Foundation (ASF) under one

- * or more contributor license agreements. See the NOTICE file

- * distributed with this work for additional information

- * regarding copyright ownership. The ASF licenses this file

- * to you under the Apache License, Version 2.0 (the

- * "License"); you may not use this file except in compliance

- * with the License. You may obtain a copy of the License at

- *

- *   http://www.apache.org/licenses/LICENSE-2.0

- *

- * Unless required by applicable law or agreed to in writing,

- * software distributed under the License is distributed on an

- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

- * KIND, either express or implied. See the License for the

- * specific language governing permissions and limitations

- * under the License.

- *)

-

-unit Thrift.TypeRegistry;

-

-interface

-

-uses

-  Generics.Collections, TypInfo,

-  Thrift.Protocol;

-

-type

-  TFactoryMethod<T> = function:T;

-

-  TypeRegistry = class

-  private

-    class var FTypeInfoToFactoryLookup : TDictionary<Pointer, Pointer>;

-  public

-    class constructor Create;

-    class destructor Destroy;

-    class procedure RegisterTypeFactory<F>(const aFactoryMethod: TFactoryMethod<F>);

-    class function  Construct<F>: F;

-    class function  ConstructFromTypeInfo(const aTypeInfo: PTypeInfo): IBase;

-  end;

-

-implementation

-

-

-{ TypeRegistration }

-

-class constructor TypeRegistry.Create;

-begin

-  FTypeInfoToFactoryLookup := TDictionary<Pointer, Pointer>.Create;

-end;

-

-class destructor TypeRegistry.Destroy;

-begin

-  FTypeInfoToFactoryLookup.Free;

-end;

-

-class procedure TypeRegistry.RegisterTypeFactory<F>(const aFactoryMethod: TFactoryMethod<F>);

-var

-  TypeInfo     : Pointer;

-begin

-  TypeInfo := System.TypeInfo(F);

-

-  if (TypeInfo <> nil) and (PTypeInfo(TypeInfo).Kind = tkInterface)

-  then FTypeInfoToFactoryLookup.AddOrSetValue(TypeInfo, @aFactoryMethod);

-end;

-

-class function TypeRegistry.Construct<F>: F;

-var

-  TypeInfo     : PTypeInfo;

-  Factory      : Pointer;

-begin

-  Result := default(F);

-

-  TypeInfo := System.TypeInfo(F);

-

-  if Assigned(TypeInfo) and (TypeInfo.Kind = tkInterface)

-  then begin

-    if FTypeInfoToFactoryLookup.TryGetValue(TypeInfo, Factory)

-    then Result := TFactoryMethod<F>(Factory)();

-  end;

-end;

-

-class function TypeRegistry.ConstructFromTypeInfo(const aTypeInfo: PTypeInfo): IBase;

-var

-  Factory      : Pointer;

-begin

-  Result := nil;

-  if FTypeInfoToFactoryLookup.TryGetValue(aTypeInfo, Factory)

-  then Result := IBase(TFactoryMethod<IBase>(Factory)());

-end;

-

-

-

-

-end.

+(*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *)
+
+unit Thrift.TypeRegistry;
+
+interface
+
+uses
+  Generics.Collections, TypInfo,
+  Thrift.Protocol;
+
+type
+  TFactoryMethod<T> = function:T;
+
+  TypeRegistry = class
+  private
+    class var FTypeInfoToFactoryLookup : TDictionary<Pointer, Pointer>;
+  public
+    class constructor Create;
+    class destructor Destroy;
+    class procedure RegisterTypeFactory<F>(const aFactoryMethod: TFactoryMethod<F>);
+    class function  Construct<F>: F;
+    class function  ConstructFromTypeInfo(const aTypeInfo: PTypeInfo): IBase;
+  end;
+
+implementation
+
+
+{ TypeRegistration }
+
+class constructor TypeRegistry.Create;
+begin
+  FTypeInfoToFactoryLookup := TDictionary<Pointer, Pointer>.Create;
+end;
+
+class destructor TypeRegistry.Destroy;
+begin
+  FTypeInfoToFactoryLookup.Free;
+end;
+
+class procedure TypeRegistry.RegisterTypeFactory<F>(const aFactoryMethod: TFactoryMethod<F>);
+var
+  TypeInfo     : Pointer;
+begin
+  TypeInfo := System.TypeInfo(F);
+
+  if (TypeInfo <> nil) and (PTypeInfo(TypeInfo).Kind = tkInterface)
+  then FTypeInfoToFactoryLookup.AddOrSetValue(TypeInfo, @aFactoryMethod);
+end;
+
+class function TypeRegistry.Construct<F>: F;
+var
+  TypeInfo     : PTypeInfo;
+  Factory      : Pointer;
+begin
+  Result := default(F);
+
+  TypeInfo := System.TypeInfo(F);
+
+  if Assigned(TypeInfo) and (TypeInfo.Kind = tkInterface)
+  then begin
+    if FTypeInfoToFactoryLookup.TryGetValue(TypeInfo, Factory)
+    then Result := TFactoryMethod<F>(Factory)();
+  end;
+end;
+
+class function TypeRegistry.ConstructFromTypeInfo(const aTypeInfo: PTypeInfo): IBase;
+var
+  Factory      : Pointer;
+begin
+  Result := nil;
+  if FTypeInfoToFactoryLookup.TryGetValue(aTypeInfo, Factory)
+  then Result := IBase(TFactoryMethod<IBase>(Factory)());
+end;
+
+
+
+
+end.
diff --git a/lib/delphi/src/Thrift.Utils.pas b/lib/delphi/src/Thrift.Utils.pas
index ec8190c..58ffe79 100644
--- a/lib/delphi/src/Thrift.Utils.pas
+++ b/lib/delphi/src/Thrift.Utils.pas
@@ -1,118 +1,118 @@
-(*

- * Licensed to the Apache Software Foundation (ASF) under one

- * or more contributor license agreements. See the NOTICE file

- * distributed with this work for additional information

- * regarding copyright ownership. The ASF licenses this file

- * to you under the Apache License, Version 2.0 (the

- * "License"); you may not use this file except in compliance

- * with the License. You may obtain a copy of the License at

- *

- *   http://www.apache.org/licenses/LICENSE-2.0

- *

- * Unless required by applicable law or agreed to in writing,

- * software distributed under the License is distributed on an

- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

- * KIND, either express or implied. See the License for the

- * specific language governing permissions and limitations

- * under the License.

- *)

-

-unit Thrift.Utils;

-

-interface

-

-uses

-  Classes, Windows, SysUtils, SyncObjs;

-

-type

-  IOverlappedHelper = interface

-    ['{A1832EFA-2E02-4884-8F09-F0A0277157FA}']

-    function Overlapped : TOverlapped;

-    function OverlappedPtr : POverlapped;

-    function WaitHandle : THandle;

-    function WaitFor(dwTimeout: DWORD) : DWORD;

-  end;

-

-  TOverlappedHelperImpl = class( TInterfacedObject, IOverlappedHelper)

-  strict protected

-    FOverlapped : TOverlapped;

-    FEvent      : TEvent;

-

-    // IOverlappedHelper

-    function Overlapped : TOverlapped;

-    function OverlappedPtr : POverlapped;

-    function WaitHandle : THandle;

-    function WaitFor(dwTimeout: DWORD) : DWORD;

-  public

-    constructor Create;

-    destructor Destroy;  override;

-  end;

-

-

-

-function IfValue(B: Boolean; const TrueValue, FalseValue: WideString): string;

-

-implementation

-

-

-function IfValue(B: Boolean; const TrueValue, FalseValue: WideString): string;

-begin

-  if B then

-    Result := TrueValue

-  else

-    Result := FalseValue;

-end;

-

-

-{ TOverlappedHelperImpl }

-

-constructor TOverlappedHelperImpl.Create;

-begin

-  inherited Create;

-  FillChar( FOverlapped, SizeOf(FOverlapped), 0);

-  FEvent := TEvent.Create( nil, TRUE, FALSE, '');  // always ManualReset, see MSDN

-  FOverlapped.hEvent := FEvent.Handle;

-end;

-

-

-

-destructor TOverlappedHelperImpl.Destroy;

-begin

-  try

-    FOverlapped.hEvent := 0;

-    FreeAndNil( FEvent);

-

-  finally

-    inherited Destroy;

-  end;

-

-end;

-

-

-function TOverlappedHelperImpl.Overlapped : TOverlapped;

-begin

-  result := FOverlapped;

-end;

-

-

-function TOverlappedHelperImpl.OverlappedPtr : POverlapped;

-begin

-  result := @FOverlapped;

-end;

-

-

-function TOverlappedHelperImpl.WaitHandle : THandle;

-begin

-  result := FOverlapped.hEvent;

-end;

-

-

-function TOverlappedHelperImpl.WaitFor( dwTimeout : DWORD) : DWORD;

-begin

-  result := WaitForSingleObject( FOverlapped.hEvent, dwTimeout);

-end;

-

-

-

-

-end.

+(*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *)
+
+unit Thrift.Utils;
+
+interface
+
+uses
+  Classes, Windows, SysUtils, SyncObjs;
+
+type
+  IOverlappedHelper = interface
+    ['{A1832EFA-2E02-4884-8F09-F0A0277157FA}']
+    function Overlapped : TOverlapped;
+    function OverlappedPtr : POverlapped;
+    function WaitHandle : THandle;
+    function WaitFor(dwTimeout: DWORD) : DWORD;
+  end;
+
+  TOverlappedHelperImpl = class( TInterfacedObject, IOverlappedHelper)
+  strict protected
+    FOverlapped : TOverlapped;
+    FEvent      : TEvent;
+
+    // IOverlappedHelper
+    function Overlapped : TOverlapped;
+    function OverlappedPtr : POverlapped;
+    function WaitHandle : THandle;
+    function WaitFor(dwTimeout: DWORD) : DWORD;
+  public
+    constructor Create;
+    destructor Destroy;  override;
+  end;
+
+
+
+function IfValue(B: Boolean; const TrueValue, FalseValue: WideString): string;
+
+implementation
+
+
+function IfValue(B: Boolean; const TrueValue, FalseValue: WideString): string;
+begin
+  if B then
+    Result := TrueValue
+  else
+    Result := FalseValue;
+end;
+
+
+{ TOverlappedHelperImpl }
+
+constructor TOverlappedHelperImpl.Create;
+begin
+  inherited Create;
+  FillChar( FOverlapped, SizeOf(FOverlapped), 0);
+  FEvent := TEvent.Create( nil, TRUE, FALSE, '');  // always ManualReset, see MSDN
+  FOverlapped.hEvent := FEvent.Handle;
+end;
+
+
+
+destructor TOverlappedHelperImpl.Destroy;
+begin
+  try
+    FOverlapped.hEvent := 0;
+    FreeAndNil( FEvent);
+
+  finally
+    inherited Destroy;
+  end;
+
+end;
+
+
+function TOverlappedHelperImpl.Overlapped : TOverlapped;
+begin
+  result := FOverlapped;
+end;
+
+
+function TOverlappedHelperImpl.OverlappedPtr : POverlapped;
+begin
+  result := @FOverlapped;
+end;
+
+
+function TOverlappedHelperImpl.WaitHandle : THandle;
+begin
+  result := FOverlapped.hEvent;
+end;
+
+
+function TOverlappedHelperImpl.WaitFor( dwTimeout : DWORD) : DWORD;
+begin
+  result := WaitForSingleObject( FOverlapped.hEvent, dwTimeout);
+end;
+
+
+
+
+end.
diff --git a/lib/delphi/test/TestClient.pas b/lib/delphi/test/TestClient.pas
index cbd825e..dc39828 100644
--- a/lib/delphi/test/TestClient.pas
+++ b/lib/delphi/test/TestClient.pas
@@ -825,7 +825,7 @@
 
     Expect( crazy.Xtructs.Count = 2, 'crazy.Xtructs.Count = '+IntToStr(crazy.Xtructs.Count));
     goodbye := crazy.Xtructs[0];  // lists are ordered, so we are allowed to assume this order
-	  hello   := crazy.Xtructs[1];
+      hello   := crazy.Xtructs[1];
 
     Expect( goodbye.String_thing = 'Goodbye4', 'goodbye.String_thing = "'+goodbye.String_thing+'"');
     Expect( goodbye.Byte_thing = 4, 'goodbye.Byte_thing = '+IntToStr(goodbye.Byte_thing));
@@ -878,10 +878,10 @@
     Expect( i.String_thing = 'run out of beer', 'i.String_thing = "' +i.String_thing+ '"');
     Expect( i.__isset_String_thing, 'i.__isset_String_thing = '+BoolToString(i.__isset_String_thing));
     { this is not necessarily true, these fields are default-serialized
-	Expect( not i.__isset_Byte_thing, 'i.__isset_Byte_thing = '+BoolToString(i.__isset_Byte_thing));
+    Expect( not i.__isset_Byte_thing, 'i.__isset_Byte_thing = '+BoolToString(i.__isset_Byte_thing));
     Expect( not i.__isset_I32_thing, 'i.__isset_I32_thing = '+BoolToString(i.__isset_I32_thing));
     Expect( not i.__isset_I64_thing, 'i.__isset_I64_thing = '+BoolToString(i.__isset_I64_thing));
-	}
+    }
   except
     on e:Exception do Expect( FALSE, 'Unexpected exception "'+e.ClassName+'"');
   end;
@@ -915,7 +915,7 @@
       Expect( not x.Struct_thing.__isset_Byte_thing, 'x.Struct_thing.__isset_Byte_thing = '+BoolToString(x.Struct_thing.__isset_Byte_thing));
       Expect( not x.Struct_thing.__isset_I32_thing, 'x.Struct_thing.__isset_I32_thing = '+BoolToString(x.Struct_thing.__isset_I32_thing));
       Expect( not x.Struct_thing.__isset_I64_thing, 'x.Struct_thing.__isset_I64_thing = '+BoolToString(x.Struct_thing.__isset_I64_thing));
-	  }
+      }
     end;
     on e:Exception do Expect( FALSE, 'Unexpected exception "'+e.ClassName+'"');
   end;
diff --git a/lib/delphi/test/TestServer.pas b/lib/delphi/test/TestServer.pas
index 286047d..35f1ac8 100644
--- a/lib/delphi/test/TestServer.pas
+++ b/lib/delphi/test/TestServer.pas
@@ -316,7 +316,7 @@
   Console.WriteLine('testMultiException(' + arg0 + ', ' + arg1 + ')');
   if ( arg0 = 'Xception') then
   begin
-    raise TXception.Create( 1001, 'This is an Xception');  // test the new rich CTOR 
+    raise TXception.Create( 1001, 'This is an Xception');  // test the new rich CTOR
   end else
   if ( arg0 = 'Xception2') then
   begin
@@ -473,8 +473,8 @@
 //This is a simple example and does not include elevation or other
 //advanced features.
 var pi : PROCESS_INFORMATION;
-		si : STARTUPINFO;
-		sArg, sHandles, sCmdLine : string;
+        si : STARTUPINFO;
+        sArg, sHandles, sCmdLine : string;
     i : Integer;
 begin
   GetStartupInfo( si);  //set startupinfo for the spawned process
@@ -505,7 +505,7 @@
   Win32Check( CreateProcess( nil, PChar(sCmdLine), nil,nil,TRUE,0,nil,nil,si,pi));
 
   CloseHandle( pi.hThread);
-	CloseHandle( pi.hProcess);
+    CloseHandle( pi.hProcess);
 end;
 
 
diff --git a/lib/delphi/test/TestServerEvents.pas b/lib/delphi/test/TestServerEvents.pas
index 8e931c4..2e776d2 100644
--- a/lib/delphi/test/TestServerEvents.pas
+++ b/lib/delphi/test/TestServerEvents.pas
@@ -47,128 +47,128 @@
 
 
   TProcessorEventsImpl = class( TInterfacedObject, IProcessorEvents)
-  protected

-    FReqs : Integer;

-    // IProcessorEvents

-    procedure Processing( const transport : ITransport);

+  protected
+    FReqs : Integer;
+    // IProcessorEvents
+    procedure Processing( const transport : ITransport);
     function  CreateRequestContext( const aFunctionName : string) : IRequestEvents;
     procedure CleanupContext;
   public
     constructor Create;
-  end;

+  end;
 
 
   TServerEventsImpl = class( TInterfacedObject, IServerEvents)
-  protected

-    // IServerEvents

-    procedure PreServe;

-    procedure PreAccept;

-    function  CreateProcessingContext( const input, output : IProtocol) : IProcessorEvents;

-  end;

+  protected
+    // IServerEvents
+    procedure PreServe;
+    procedure PreAccept;
+    function  CreateProcessingContext( const input, output : IProtocol) : IProcessorEvents;
+  end;
 
 
 implementation
 
 { TServerEventsImpl }
-

+
 procedure TServerEventsImpl.PreServe;
-begin

-  Console.WriteLine('ServerEvents: Server starting to serve requests');

-end;

-

-

+begin
+  Console.WriteLine('ServerEvents: Server starting to serve requests');
+end;
+
+
 procedure TServerEventsImpl.PreAccept;
-begin

-  Console.WriteLine('ServerEvents: Server transport is ready to accept incoming calls');

-end;

-

-

+begin
+  Console.WriteLine('ServerEvents: Server transport is ready to accept incoming calls');
+end;
+
+
 function TServerEventsImpl.CreateProcessingContext(const input, output: IProtocol): IProcessorEvents;
-begin

-  result := TProcessorEventsImpl.Create;

-end;

-

-

+begin
+  result := TProcessorEventsImpl.Create;
+end;
+
+
 { TProcessorEventsImpl }
-

+
 constructor TProcessorEventsImpl.Create;
-begin

-  inherited Create;

-  FReqs := 0;

-  Console.WriteLine('ProcessorEvents: Client connected, processing begins');

-end;

-

-procedure TProcessorEventsImpl.Processing(const transport: ITransport);

-begin

-  Console.WriteLine('ProcessorEvents: Processing of incoming request begins');

-end;

-

-

-function TProcessorEventsImpl.CreateRequestContext( const aFunctionName: string): IRequestEvents;

-begin

-  result := TRequestEventsImpl.Create;

-  Inc( FReqs);

-end;

-

-

-procedure TProcessorEventsImpl.CleanupContext;

-begin

-  Console.WriteLine( 'ProcessorEvents: completed after handling '+IntToStr(FReqs)+' requests.');

-end;

-

-

-{ TRequestEventsImpl }

-

+begin
+  inherited Create;
+  FReqs := 0;
+  Console.WriteLine('ProcessorEvents: Client connected, processing begins');
+end;
+
+procedure TProcessorEventsImpl.Processing(const transport: ITransport);
+begin
+  Console.WriteLine('ProcessorEvents: Processing of incoming request begins');
+end;
+
+
+function TProcessorEventsImpl.CreateRequestContext( const aFunctionName: string): IRequestEvents;
+begin
+  result := TRequestEventsImpl.Create;
+  Inc( FReqs);
+end;
+
+
+procedure TProcessorEventsImpl.CleanupContext;
+begin
+  Console.WriteLine( 'ProcessorEvents: completed after handling '+IntToStr(FReqs)+' requests.');
+end;
+
+
+{ TRequestEventsImpl }
+
 
 constructor TRequestEventsImpl.Create;
-begin

-  inherited Create;

-  FStart := Now;

-  Console.WriteLine('RequestEvents: New request');

-end;

-

-

+begin
+  inherited Create;
+  FStart := Now;
+  Console.WriteLine('RequestEvents: New request');
+end;
+
+
 procedure TRequestEventsImpl.PreRead;
-begin

-  Console.WriteLine('RequestEvents: Reading request message ...');

-end;

-

+begin
+  Console.WriteLine('RequestEvents: Reading request message ...');
+end;
+
 
 procedure TRequestEventsImpl.PostRead;
-begin

-  Console.WriteLine('RequestEvents: Reading request message completed');

-end;

+begin
+  Console.WriteLine('RequestEvents: Reading request message completed');
+end;
 
 procedure TRequestEventsImpl.PreWrite;
-begin

-  Console.WriteLine('RequestEvents: Writing response message ...');

-end;

-

+begin
+  Console.WriteLine('RequestEvents: Writing response message ...');
+end;
+
 
 procedure TRequestEventsImpl.PostWrite;
-begin

-  Console.WriteLine('RequestEvents: Writing response message completed');

-end;

-

+begin
+  Console.WriteLine('RequestEvents: Writing response message completed');
+end;
+
 
 procedure TRequestEventsImpl.OnewayComplete;
-begin

-  Console.WriteLine('RequestEvents: Oneway message processed');

-end;

-

+begin
+  Console.WriteLine('RequestEvents: Oneway message processed');
+end;
+
 
 procedure TRequestEventsImpl.UnhandledError(const e: Exception);
-begin

-  Console.WriteLine('RequestEvents: Unhandled exception of type '+e.classname);

-end;

-

-

-procedure TRequestEventsImpl.CleanupContext;

-var millis : Double;

-begin

-  millis := (Now - FStart) * (24*60*60*1000);

-  Console.WriteLine( 'Request processing completed in '+IntToStr(Round(millis))+' ms');

-end;

-

-

+begin
+  Console.WriteLine('RequestEvents: Unhandled exception of type '+e.classname);
+end;
+
+
+procedure TRequestEventsImpl.CleanupContext;
+var millis : Double;
+begin
+  millis := (Now - FStart) * (24*60*60*1000);
+  Console.WriteLine( 'Request processing completed in '+IntToStr(Round(millis))+' ms');
+end;
+
+
 end.
diff --git a/lib/delphi/test/codegen/README.md b/lib/delphi/test/codegen/README.md
index d1447a1..a014589 100644
--- a/lib/delphi/test/codegen/README.md
+++ b/lib/delphi/test/codegen/README.md
@@ -1,17 +1,17 @@
 How to use the test case:
 ----------------------------------------------
-- copy and the template batch file 
+- copy and the template batch file
 - open the batch file and adjust configuration as necessary
 - run the batch
 
 
 Configuration:
 ----------------------------------------------
-SVNWORKDIR 
+SVNWORKDIR
 should point to the Thrift working copy root
 
-MY_THRIFT_FILES 
-can be set to point to a folder with more thrift IDL files. 
+MY_THRIFT_FILES
+can be set to point to a folder with more thrift IDL files.
 If you don't have any such files, just leave the setting blank.
 
 BIN
diff --git a/lib/delphi/test/codegen/ReservedKeywords.thrift b/lib/delphi/test/codegen/ReservedKeywords.thrift
index 83c1836..300adf9 100644
--- a/lib/delphi/test/codegen/ReservedKeywords.thrift
+++ b/lib/delphi/test/codegen/ReservedKeywords.thrift
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-// make sure generated code does not produce name collisions with predefined keywords 
+// make sure generated code does not produce name collisions with predefined keywords
 
 
 
diff --git a/lib/delphi/test/codegen/run-Pascal-Codegen-Tests.bat.tmpl b/lib/delphi/test/codegen/run-Pascal-Codegen-Tests.bat.tmpl
index f1b56a3..4398545 100644
--- a/lib/delphi/test/codegen/run-Pascal-Codegen-Tests.bat.tmpl
+++ b/lib/delphi/test/codegen/run-Pascal-Codegen-Tests.bat.tmpl
@@ -62,7 +62,7 @@
 rem * create and/or empty target dirs
 if not exist "%TARGET%"           md "%TARGET%"
 if not exist "%TARGET%\%SUBDIR%"  md "%TARGET%\%SUBDIR%"
-if not exist "%OUTDCU%" 	      md "%OUTDCU%"
+if not exist "%OUTDCU%"           md "%OUTDCU%"
 if exist "%TARGET%\*.thrift"      del "%TARGET%\*.thrift"       /Q
 if exist "%TARGET%\%SUBDIR%\*.*"  del "%TARGET%\%SUBDIR%\*.*"   /Q
 if exist "%OUTDCU%\*.*"           del "%OUTDCU%\*.*"            /Q
@@ -88,31 +88,31 @@
 rem * generate a minimal DPR file that uses all generated pascal units
 cd "%TARGET%\%SUBDIR%\"
 if exist inherited.*  ren inherited.*  _inherited.*
-echo program %TESTAPP%;    					> %TESTAPP%.dpr
-echo {$APPTYPE CONSOLE}   					>> %TESTAPP%.dpr
-echo.    									>> %TESTAPP%.dpr
-echo uses 									>> %TESTAPP%.dpr
-for %%a in (*.pas) do echo   %%~na,			>> %TESTAPP%.dpr
-echo   Windows, Classes, SysUtils;			>> %TESTAPP%.dpr
-echo.    									>> %TESTAPP%.dpr
-echo begin 									>> %TESTAPP%.dpr
-echo   Writeln('Successfully compiled!');	>> %TESTAPP%.dpr
-echo   Writeln('List of units:');	>> %TESTAPP%.dpr
-for %%a in (*.pas) do echo   Write('%%~na':30,'':10);  >> %TESTAPP%.dpr
-echo   Writeln;	>> %TESTAPP%.dpr
-echo end. 									>> %TESTAPP%.dpr
-echo.    									>> %TESTAPP%.dpr
+echo program %TESTAPP%;                                           > %TESTAPP%.dpr
+echo {$APPTYPE CONSOLE}                                          >> %TESTAPP%.dpr
+echo.                                                            >> %TESTAPP%.dpr
+echo uses                                                        >> %TESTAPP%.dpr
+for %%a in (*.pas) do echo   %%~na,                              >> %TESTAPP%.dpr
+echo   Windows, Classes, SysUtils;                               >> %TESTAPP%.dpr
+echo.                                                            >> %TESTAPP%.dpr
+echo begin                                                       >> %TESTAPP%.dpr
+echo   Writeln('Successfully compiled!');                        >> %TESTAPP%.dpr
+echo   Writeln('List of units:');                                >> %TESTAPP%.dpr
+for %%a in (*.pas) do echo   Write('%%~na':30,'':10);            >> %TESTAPP%.dpr
+echo   Writeln;                                                  >> %TESTAPP%.dpr
+echo end.                                                        >> %TESTAPP%.dpr
+echo.                                                            >> %TESTAPP%.dpr
 cd ..\..
 
 rem * try to compile the DPR
 rem * this should not throw any errors, warnings or hints
-"%DCC%"  -B "%TARGET%\%SUBDIR%\%TESTAPP%" -U"%UNITSEARCH%" -I"%UNITSEARCH%" -N"%OUTDCU%" -E"%TARGET%\%SUBDIR%" 
+"%DCC%"  -B "%TARGET%\%SUBDIR%\%TESTAPP%" -U"%UNITSEARCH%" -I"%UNITSEARCH%" -N"%OUTDCU%" -E"%TARGET%\%SUBDIR%"
 dir "%TARGET%\%SUBDIR%\%TESTAPP%.exe"
 if not exist "%TARGET%\%SUBDIR%\%TESTAPP%.exe"  goto CODEGEN_FAILED
 echo.
 echo -----------------------------------------------------------------
 echo The compiled program is now executed. If it hangs or crashes, we
-echo have a serious problem with the generated code. Expected output 
+echo have a serious problem with the generated code. Expected output
 echo is "Successfully compiled:" followed by a list of generated units.
 echo -----------------------------------------------------------------
 "%TARGET%\%SUBDIR%\%TESTAPP%.exe"
@@ -124,7 +124,7 @@
 REM -----------------------------------------------------
 :DXE_NOT_FOUND
 REM -----------------------------------------------------
-echo Delphi Compiler (dcc32.exe) not found. 
+echo Delphi Compiler (dcc32.exe) not found.
 echo Please check the "DCC" setting in this batch.
 echo.
 cmd /c start notepad README.MD
diff --git a/lib/delphi/test/multiplexed/Multiplex.Client.Main.pas b/lib/delphi/test/multiplexed/Multiplex.Client.Main.pas
index a1af40b..34ee081 100644
--- a/lib/delphi/test/multiplexed/Multiplex.Client.Main.pas
+++ b/lib/delphi/test/multiplexed/Multiplex.Client.Main.pas
@@ -57,8 +57,8 @@
 
 type
   IServiceClient = interface
-    ['{7745C1C2-AB20-43BA-B6F0-08BF92DE0BAC}']

-    procedure Test;

+    ['{7745C1C2-AB20-43BA-B6F0-08BF92DE0BAC}']
+    procedure Test;
   end;
 
 //--- TTestClient -------------------------------------
@@ -70,15 +70,15 @@
   client := TTestClient.Create(args);
   try
     client.Run;
-  finally

-    client.Free;

+  finally
+    client.Free;
   end;
 end;
 
 
 constructor TTestClient.Create( const args: array of string);
 begin
-  inherited;  
+  inherited;
   ParseArgs(args);
   Setup;
 end;
@@ -121,8 +121,8 @@
     do Write(IntToStr(i)+' ');
     WriteLn;
   except
-    on e:Exception do Writeln(#10+e.Message);

-  end;

+    on e:Exception do Writeln(#10+e.Message);
+  end;
 end;
 
 
diff --git a/lib/delphi/test/multiplexed/Multiplex.Server.Main.pas b/lib/delphi/test/multiplexed/Multiplex.Server.Main.pas
index 4f5cd13..37f84bb 100644
--- a/lib/delphi/test/multiplexed/Multiplex.Server.Main.pas
+++ b/lib/delphi/test/multiplexed/Multiplex.Server.Main.pas
@@ -72,20 +72,20 @@
     TAggrImpl = class( TTestHandlerImpl, TAggr.Iface)
     protected
       FList : IThriftList<Integer>;
-    
+
       // TAggr.Iface
       procedure addValue(value: Integer);
-      function getValues(): IThriftList<Integer>;

-    public

-      constructor Create;

-      destructor Destroy;  override;

-    end;

+      function getValues(): IThriftList<Integer>;
+    public
+      constructor Create;
+      destructor Destroy;  override;
+    end;
 
   public
     class procedure Execute( const args: array of string);
   end;
 
-  
+
 implementation
 
 
@@ -105,45 +105,45 @@
   prev   := 0;
   result := 1;
   while n > 0 do begin
-    next   := result + prev;

-    prev   := result;

-    result := next;

-    Dec(n);

+    next   := result + prev;
+    prev   := result;
+    result := next;
+    Dec(n);
   end;
 end;
 
 { TTestServer.TAggrImpl }
 
 constructor TTestServer.TAggrImpl.Create;
-begin

+begin
   inherited Create;
   FList := TThriftListImpl<Integer>.Create;
 end;
 
-

-destructor TTestServer.TAggrImpl.Destroy;  

+
+destructor TTestServer.TAggrImpl.Destroy;
 begin
   try
-    FreeAndNil( FList);

-  finally

-    inherited Destroy;

-  end;                  
+    FreeAndNil( FList);
+  finally
+    inherited Destroy;
+  end;
 end;
 
-

+
 procedure TTestServer.TAggrImpl.addValue(value: Integer);
 begin
   FList.Add( value);
 end;
 
-

+
 function TTestServer.TAggrImpl.getValues(): IThriftList<Integer>;
 begin
   result := FList;
 end;
 
-

-{ TTestServer }    
+
+{ TTestServer }
 
 class procedure TTestServer.Execute( const args: array of string);
 var
diff --git a/lib/delphi/test/multiplexed/Multiplex.Test.Client.dpr b/lib/delphi/test/multiplexed/Multiplex.Test.Client.dpr
index 23e296a..f7ccba1 100644
--- a/lib/delphi/test/multiplexed/Multiplex.Test.Client.dpr
+++ b/lib/delphi/test/multiplexed/Multiplex.Test.Client.dpr
@@ -23,19 +23,19 @@
 {$APPTYPE CONSOLE}
 
 uses
-  SysUtils,

-  Multiplex.Client.Main in 'Multiplex.Client.Main.pas',

-  Thrift in '..\..\src\Thrift.pas',

-  Thrift.Transport in '..\..\src\Thrift.Transport.pas',

-  Thrift.Transport.Pipes in '..\..\src\Thrift.Transport.Pipes.pas',

-  Thrift.Protocol in '..\..\src\Thrift.Protocol.pas',

-  Thrift.Protocol.Multiplex in '..\..\src\Thrift.Protocol.Multiplex.pas',

-  Thrift.Collections in '..\..\src\Thrift.Collections.pas',

-  Thrift.Server in '..\..\src\Thrift.Server.pas',

-  Thrift.Stream in '..\..\src\Thrift.Stream.pas',

-  Thrift.Console in '..\..\src\Thrift.Console.pas',

-  Thrift.Utils in '..\..\src\Thrift.Utils.pas';

-

+  SysUtils,
+  Multiplex.Client.Main in 'Multiplex.Client.Main.pas',
+  Thrift in '..\..\src\Thrift.pas',
+  Thrift.Transport in '..\..\src\Thrift.Transport.pas',
+  Thrift.Transport.Pipes in '..\..\src\Thrift.Transport.Pipes.pas',
+  Thrift.Protocol in '..\..\src\Thrift.Protocol.pas',
+  Thrift.Protocol.Multiplex in '..\..\src\Thrift.Protocol.Multiplex.pas',
+  Thrift.Collections in '..\..\src\Thrift.Collections.pas',
+  Thrift.Server in '..\..\src\Thrift.Server.pas',
+  Thrift.Stream in '..\..\src\Thrift.Stream.pas',
+  Thrift.Console in '..\..\src\Thrift.Console.pas',
+  Thrift.Utils in '..\..\src\Thrift.Utils.pas';
+
 var
   nParamCount : Integer;
   args : array of string;
diff --git a/lib/delphi/test/multiplexed/Multiplex.Test.Common.pas b/lib/delphi/test/multiplexed/Multiplex.Test.Common.pas
index 231c3ad..2caf081 100644
--- a/lib/delphi/test/multiplexed/Multiplex.Test.Common.pas
+++ b/lib/delphi/test/multiplexed/Multiplex.Test.Common.pas
@@ -1,35 +1,35 @@
-(*

- * Licensed to the Apache Software Foundation (ASF) under one

- * or more contributor license agreements. See the NOTICE file

- * distributed with this work for additional information

- * regarding copyright ownership. The ASF licenses this file

- * to you under the Apache License, Version 2.0 (the

- * "License"); you may not use this file except in compliance

- * with the License. You may obtain a copy of the License at

- *

- *   http://www.apache.org/licenses/LICENSE-2.0

- *

- * Unless required by applicable law or agreed to in writing,

- * software distributed under the License is distributed on an

- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

- * KIND, either express or implied. See the License for the

- * specific language governing permissions and limitations

- * under the License.

- *)

-

-unit Multiplex.Test.Common;

-

-interface

-

-const

-  NAME_BENCHMARKSERVICE = 'BenchmarkService';

-  NAME_AGGR             = 'Aggr';

-

-

-implementation

-

-// nix

-

-end.

-

-

+(*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *)
+
+unit Multiplex.Test.Common;
+
+interface
+
+const
+  NAME_BENCHMARKSERVICE = 'BenchmarkService';
+  NAME_AGGR             = 'Aggr';
+
+
+implementation
+
+// nix
+
+end.
+
+
diff --git a/lib/delphi/test/multiplexed/Multiplex.Test.Server.dpr b/lib/delphi/test/multiplexed/Multiplex.Test.Server.dpr
index 9da1cdc..cf03c44 100644
--- a/lib/delphi/test/multiplexed/Multiplex.Test.Server.dpr
+++ b/lib/delphi/test/multiplexed/Multiplex.Test.Server.dpr
@@ -22,20 +22,20 @@
 {$APPTYPE CONSOLE}
 
 uses
-  SysUtils,

-  Multiplex.Server.Main in 'Multiplex.Server.Main.pas',

-  Thrift in '..\..\src\Thrift.pas',

-  Thrift.Transport in '..\..\src\Thrift.Transport.pas',

-  Thrift.Transport.Pipes in '..\..\src\Thrift.Transport.Pipes.pas',

-  Thrift.Protocol in '..\..\src\Thrift.Protocol.pas',

-  Thrift.Protocol.Multiplex in '..\..\src\Thrift.Protocol.Multiplex.pas',

-  Thrift.Processor.Multiplex in '..\..\src\Thrift.Processor.Multiplex.pas',

-  Thrift.Collections in '..\..\src\Thrift.Collections.pas',

-  Thrift.Server in '..\..\src\Thrift.Server.pas',

-  Thrift.Console in '..\..\src\Thrift.Console.pas',

-  Thrift.Utils in '..\..\src\Thrift.Utils.pas',

-  Thrift.Stream in '..\..\src\Thrift.Stream.pas';

-

+  SysUtils,
+  Multiplex.Server.Main in 'Multiplex.Server.Main.pas',
+  Thrift in '..\..\src\Thrift.pas',
+  Thrift.Transport in '..\..\src\Thrift.Transport.pas',
+  Thrift.Transport.Pipes in '..\..\src\Thrift.Transport.Pipes.pas',
+  Thrift.Protocol in '..\..\src\Thrift.Protocol.pas',
+  Thrift.Protocol.Multiplex in '..\..\src\Thrift.Protocol.Multiplex.pas',
+  Thrift.Processor.Multiplex in '..\..\src\Thrift.Processor.Multiplex.pas',
+  Thrift.Collections in '..\..\src\Thrift.Collections.pas',
+  Thrift.Server in '..\..\src\Thrift.Server.pas',
+  Thrift.Console in '..\..\src\Thrift.Console.pas',
+  Thrift.Utils in '..\..\src\Thrift.Utils.pas',
+  Thrift.Stream in '..\..\src\Thrift.Stream.pas';
+
 var
   nParamCount : Integer;
   args : array of string;
diff --git a/lib/delphi/test/skip/README.md b/lib/delphi/test/skip/README.md
index 90d5ff5..9975a0b 100644
--- a/lib/delphi/test/skip/README.md
+++ b/lib/delphi/test/skip/README.md
@@ -1,11 +1,11 @@
-These two projects belong together. Both programs 
-simulate server and client for different versions 
+These two projects belong together. Both programs
+simulate server and client for different versions
 of the same protocol.
 
 The intention of this test is to ensure fully
-working compatibilty features of the Delphi Thrift 
+working compatibilty features of the Delphi Thrift
 implementation.
 
-The expected test result is, that no errors occur 
-with both programs, regardless in which order they 
+The expected test result is, that no errors occur
+with both programs, regardless in which order they
 might be started.
diff --git a/lib/delphi/test/typeregistry/TestTypeRegistry.dpr b/lib/delphi/test/typeregistry/TestTypeRegistry.dpr
index 64d5771..9a6503a 100644
--- a/lib/delphi/test/typeregistry/TestTypeRegistry.dpr
+++ b/lib/delphi/test/typeregistry/TestTypeRegistry.dpr
@@ -48,42 +48,42 @@
 begin
   instance := TypeRegistry.Construct<T>;
   name := GetTypeName(TypeInfo(T));
-  if instance <> nil

-  then Writeln( name, ' = ok')

-  else begin

-    Writeln( name, ' = failed');

-    raise Exception.Create( 'Test with '+name+' failed!');

-  end;

+  if instance <> nil
+  then Writeln( name, ' = ok')
+  else begin
+    Writeln( name, ' = failed');
+    raise Exception.Create( 'Test with '+name+' failed!');
+  end;
 end;
 
 begin
   Writeln('Testing ...');
   Tester<IDoubles>.Test;
-  Tester<IOneOfEach>.Test;

-  Tester<IBonk>.Test;

-  Tester<INesting>.Test;

-  Tester<IHolyMoley>.Test;

-  Tester<IBackwards>.Test;

-  Tester<IEmpty>.Test;

-  Tester<IWrapper>.Test;

-  Tester<IRandomStuff>.Test;

-  Tester<IBase64>.Test;

-  Tester<ICompactProtoTestStruct>.Test;

-  Tester<ISingleMapTestStruct>.Test;

-  Tester<IBlowUp>.Test;

-  Tester<IReverseOrderStruct>.Test;

-  Tester<IStructWithSomeEnum>.Test;

-  Tester<ITestUnion>.Test;

-  Tester<ITestUnionMinusStringField>.Test;

-  Tester<IComparableUnion>.Test;

-  Tester<IStructWithAUnion>.Test;

-  Tester<IPrimitiveThenStruct>.Test;

-  Tester<IStructWithASomemap>.Test;

-  Tester<IBigFieldIdStruct>.Test;

-  Tester<IBreaksRubyCompactProtocol>.Test;

-  Tester<ITupleProtocolTestStruct>.Test;

-  Writeln('Completed.');

-

-

-end.

+  Tester<IOneOfEach>.Test;
+  Tester<IBonk>.Test;
+  Tester<INesting>.Test;
+  Tester<IHolyMoley>.Test;
+  Tester<IBackwards>.Test;
+  Tester<IEmpty>.Test;
+  Tester<IWrapper>.Test;
+  Tester<IRandomStuff>.Test;
+  Tester<IBase64>.Test;
+  Tester<ICompactProtoTestStruct>.Test;
+  Tester<ISingleMapTestStruct>.Test;
+  Tester<IBlowUp>.Test;
+  Tester<IReverseOrderStruct>.Test;
+  Tester<IStructWithSomeEnum>.Test;
+  Tester<ITestUnion>.Test;
+  Tester<ITestUnionMinusStringField>.Test;
+  Tester<IComparableUnion>.Test;
+  Tester<IStructWithAUnion>.Test;
+  Tester<IPrimitiveThenStruct>.Test;
+  Tester<IStructWithASomemap>.Test;
+  Tester<IBigFieldIdStruct>.Test;
+  Tester<IBreaksRubyCompactProtocol>.Test;
+  Tester<ITupleProtocolTestStruct>.Test;
+  Writeln('Completed.');
+
+
+end.
 
diff --git a/tutorial/csharp/CsharpClient/CsharpClient.csproj b/tutorial/csharp/CsharpClient/CsharpClient.csproj
index 517ad83..afce70d 100644
--- a/tutorial/csharp/CsharpClient/CsharpClient.csproj
+++ b/tutorial/csharp/CsharpClient/CsharpClient.csproj
@@ -1,88 +1,88 @@
-<?xml version="1.0" encoding="utf-8"?>

-<!--

-  Licensed to the Apache Software Foundation (ASF) under one

-  or more contributor license agreements. See the NOTICE file

-  distributed with this work for additional information

-  regarding copyright ownership. The ASF licenses this file

-  to you under the Apache License, Version 2.0 (the

-  "License"); you may not use this file except in compliance

-  with the License. You may obtain a copy of the License at

-

-    http://www.apache.org/licenses/LICENSE-2.0

-

-  Unless required by applicable law or agreed to in writing,

-  software distributed under the License is distributed on an

-  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

-  KIND, either express or implied. See the License for the

-  specific language governing permissions and limitations

-  under the License.

--->

-<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

-  <PropertyGroup>

-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>

-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>

-    <ProductVersion>9.0.30729</ProductVersion>

-    <SchemaVersion>2.0</SchemaVersion>

-    <ProjectGuid>{18F24087-4760-43DA-ACAB-7B9F0E096B11}</ProjectGuid>

-    <OutputType>Exe</OutputType>

-    <AppDesignerFolder>Properties</AppDesignerFolder>

-    <RootNamespace>CsharpClient</RootNamespace>

-    <AssemblyName>CsharpClient</AssemblyName>

-    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>

-    <FileAlignment>512</FileAlignment>

-  </PropertyGroup>

-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">

-    <DebugSymbols>true</DebugSymbols>

-    <DebugType>full</DebugType>

-    <Optimize>false</Optimize>

-    <OutputPath>bin\Debug\</OutputPath>

-    <DefineConstants>DEBUG;TRACE</DefineConstants>

-    <ErrorReport>prompt</ErrorReport>

-    <WarningLevel>4</WarningLevel>

-  </PropertyGroup>

-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">

-    <DebugType>pdbonly</DebugType>

-    <Optimize>true</Optimize>

-    <OutputPath>bin\Release\</OutputPath>

-    <DefineConstants>TRACE</DefineConstants>

-    <ErrorReport>prompt</ErrorReport>

-    <WarningLevel>4</WarningLevel>

-  </PropertyGroup>

-  <ItemGroup>

-    <Reference Include="System" />

-    <Reference Include="System.Core">

-      <RequiredTargetFramework>3.5</RequiredTargetFramework>

-    </Reference>

-    <Reference Include="System.Xml.Linq">

-      <RequiredTargetFramework>3.5</RequiredTargetFramework>

-    </Reference>

-    <Reference Include="System.Data.DataSetExtensions">

-      <RequiredTargetFramework>3.5</RequiredTargetFramework>

-    </Reference>

-    <Reference Include="System.Data" />

-    <Reference Include="System.Xml" />

-    <Reference Include="Thrift, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">

-      <SpecificVersion>False</SpecificVersion>

-      <HintPath>..\..\..\lib\csharp\src\bin\Release\Thrift.dll</HintPath>

-    </Reference>

-  </ItemGroup>

-  <ItemGroup>

-    <Compile Include="CsharpClient.cs" />

-    <Compile Include="Properties\AssemblyInfo.cs" />

-    <Compile Include="..\..\gen-csharp\Calculator.cs" />

-    <Compile Include="..\..\gen-csharp\Constants.cs" />

-    <Compile Include="..\..\gen-csharp\InvalidOperation.cs" />

-    <Compile Include="..\..\gen-csharp\Operation.cs" />

-    <Compile Include="..\..\gen-csharp\SharedService.cs" />

-    <Compile Include="..\..\gen-csharp\SharedStruct.cs" />

-    <Compile Include="..\..\gen-csharp\Work.cs" />

-  </ItemGroup>

-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 

-       Other similar extension points exist, see Microsoft.Common.targets.

-  <Target Name="BeforeBuild">

-  </Target>

-  <Target Name="AfterBuild">

-  </Target>

-  -->

+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>9.0.30729</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{18F24087-4760-43DA-ACAB-7B9F0E096B11}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>CsharpClient</RootNamespace>
+    <AssemblyName>CsharpClient</AssemblyName>
+    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core">
+      <RequiredTargetFramework>3.5</RequiredTargetFramework>
+    </Reference>
+    <Reference Include="System.Xml.Linq">
+      <RequiredTargetFramework>3.5</RequiredTargetFramework>
+    </Reference>
+    <Reference Include="System.Data.DataSetExtensions">
+      <RequiredTargetFramework>3.5</RequiredTargetFramework>
+    </Reference>
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+    <Reference Include="Thrift, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\lib\csharp\src\bin\Release\Thrift.dll</HintPath>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="CsharpClient.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="..\..\gen-csharp\Calculator.cs" />
+    <Compile Include="..\..\gen-csharp\Constants.cs" />
+    <Compile Include="..\..\gen-csharp\InvalidOperation.cs" />
+    <Compile Include="..\..\gen-csharp\Operation.cs" />
+    <Compile Include="..\..\gen-csharp\SharedService.cs" />
+    <Compile Include="..\..\gen-csharp\SharedStruct.cs" />
+    <Compile Include="..\..\gen-csharp\Work.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
 </Project>
\ No newline at end of file
diff --git a/tutorial/csharp/CsharpClient/Properties/AssemblyInfo.cs b/tutorial/csharp/CsharpClient/Properties/AssemblyInfo.cs
index ffbc40d..72ae616 100644
--- a/tutorial/csharp/CsharpClient/Properties/AssemblyInfo.cs
+++ b/tutorial/csharp/CsharpClient/Properties/AssemblyInfo.cs
@@ -1,55 +1,55 @@
-/*

- * Licensed to the Apache Software Foundation (ASF) under one

- * or more contributor license agreements. See the NOTICE file

- * distributed with this work for additional information

- * regarding copyright ownership. The ASF licenses this file

- * to you under the Apache License, Version 2.0 (the

- * "License"); you may not use this file except in compliance

- * with the License. You may obtain a copy of the License at

- *

- *   http://www.apache.org/licenses/LICENSE-2.0

- *

- * Unless required by applicable law or agreed to in writing,

- * software distributed under the License is distributed on an

- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

- * KIND, either express or implied. See the License for the

- * specific language governing permissions and limitations

- * under the License.

- */

-

-using System.Reflection;

-using System.Runtime.CompilerServices;

-using System.Runtime.InteropServices;

-

-// General Information about an assembly is controlled through the following

-// set of attributes. Change these attribute values to modify the information

-// associated with an assembly.

-[assembly: AssemblyTitle("CsharpClient")]

-[assembly: AssemblyDescription("")]

-[assembly: AssemblyConfiguration("")]

-[assembly: AssemblyCompany("")]

-[assembly: AssemblyProduct("CsharpClient")]

-[assembly: AssemblyCopyright("Copyright © 2010 The Apache Software Foundation")]

-[assembly: AssemblyTrademark("")]

-[assembly: AssemblyCulture("")]

-

-// Setting ComVisible to false makes the types in this assembly not visible

-// to COM components.  If you need to access a type in this assembly from

-// COM, set the ComVisible attribute to true on that type.

-[assembly: ComVisible(false)]

-

-// The following GUID is for the ID of the typelib if this project is exposed to COM

-[assembly: Guid("1a461214-fa28-452a-bd1d-d23ca8e947e3")]

-

-// Version information for an assembly consists of the following four values:

-//

-//      Major Version

-//      Minor Version

-//      Build Number

-//      Revision

-//

-// You can specify all the values or you can default the Build and Revision Numbers

-// by using the '*' as shown below:

-// [assembly: AssemblyVersion("1.0.*")]

-[assembly: AssemblyVersion("1.0.0.0")]

-[assembly: AssemblyFileVersion("1.0.0.0")]

+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("CsharpClient")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("CsharpClient")]
+[assembly: AssemblyCopyright("Copyright © 2010 The Apache Software Foundation")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components.  If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("1a461214-fa28-452a-bd1d-d23ca8e947e3")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/tutorial/csharp/CsharpServer/CsharpServer.cs b/tutorial/csharp/CsharpServer/CsharpServer.cs
index 0d37c99..d32016f 100644
--- a/tutorial/csharp/CsharpServer/CsharpServer.cs
+++ b/tutorial/csharp/CsharpServer/CsharpServer.cs
@@ -15,115 +15,115 @@
  * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
- */

-

-using System;

-using System.Collections.Generic;

-using Thrift.Server;

-using Thrift.Transport;

-

-namespace CSharpTutorial

-{

-    public class CalculatorHandler : Calculator.Iface

-    {

-        Dictionary<int, SharedStruct> log;

-

-        public CalculatorHandler()

-        {

-            log = new Dictionary<int, SharedStruct>();

-        }

-

-        public void ping()

-        {

-            Console.WriteLine("ping()");

-        }

-

-        public int add(int n1, int n2)

-        {

-            Console.WriteLine("add({0},{1})", n1, n2);

-            return n1 + n2;

-        }

-

-        public int calculate(int logid, Work work)

-        {

-            Console.WriteLine("calculate({0}, [{1},{2},{3}])", logid, work.Op, work.Num1, work.Num2);

-            int val = 0;

-            switch (work.Op)

-            {

-                case Operation.ADD:

-                    val = work.Num1 + work.Num2;

-                    break;

-

-                case Operation.SUBTRACT:

-                    val = work.Num1 - work.Num2;

-                    break;

-

-                case Operation.MULTIPLY:

-                    val = work.Num1 * work.Num2;

-                    break;

-

-                case Operation.DIVIDE:

-                    if (work.Num2 == 0)

-                    {

-                        InvalidOperation io = new InvalidOperation();

-                        io.What = (int)work.Op;

-                        io.Why = "Cannot divide by 0";

-                        throw io;

-                    }

-                    val = work.Num1 / work.Num2;

-                    break;

-

-                default:

-                    {

-                        InvalidOperation io = new InvalidOperation();

-                        io.What = (int)work.Op;

-                        io.Why = "Unknown operation";

-                        throw io;

-                    }

-            }

-

-            SharedStruct entry = new SharedStruct();

-            entry.Key = logid;

-            entry.Value = val.ToString();

-            log[logid] = entry;

-

-            return val;

-        }

-

-        public SharedStruct getStruct(int key)

-        {

-            Console.WriteLine("getStruct({0})", key);

-            return log[key];

-        }

-

-        public void zip()

-        {

-            Console.WriteLine("zip()");

-        }

-    }

-

-    public class CSharpServer

-    {

-        public static void Main()

-        {

-            try

-            {

-                CalculatorHandler handler = new CalculatorHandler();

-                Calculator.Processor processor = new Calculator.Processor(handler);

-                TServerTransport serverTransport = new TServerSocket(9090);

-                TServer server = new TSimpleServer(processor, serverTransport);

-

-                // Use this for a multithreaded server

-                // server = new TThreadPoolServer(processor, serverTransport);

-

-                Console.WriteLine("Starting the server...");

-                server.Serve();

-            }

-            catch (Exception x)

-            {

-                Console.WriteLine(x.StackTrace);

-            }

-            Console.WriteLine("done.");

-        }

-    }

-}

+ */
+
+using System;
+using System.Collections.Generic;
+using Thrift.Server;
+using Thrift.Transport;
+
+namespace CSharpTutorial
+{
+    public class CalculatorHandler : Calculator.Iface
+    {
+        Dictionary<int, SharedStruct> log;
+
+        public CalculatorHandler()
+        {
+            log = new Dictionary<int, SharedStruct>();
+        }
+
+        public void ping()
+        {
+            Console.WriteLine("ping()");
+        }
+
+        public int add(int n1, int n2)
+        {
+            Console.WriteLine("add({0},{1})", n1, n2);
+            return n1 + n2;
+        }
+
+        public int calculate(int logid, Work work)
+        {
+            Console.WriteLine("calculate({0}, [{1},{2},{3}])", logid, work.Op, work.Num1, work.Num2);
+            int val = 0;
+            switch (work.Op)
+            {
+                case Operation.ADD:
+                    val = work.Num1 + work.Num2;
+                    break;
+
+                case Operation.SUBTRACT:
+                    val = work.Num1 - work.Num2;
+                    break;
+
+                case Operation.MULTIPLY:
+                    val = work.Num1 * work.Num2;
+                    break;
+
+                case Operation.DIVIDE:
+                    if (work.Num2 == 0)
+                    {
+                        InvalidOperation io = new InvalidOperation();
+                        io.What = (int)work.Op;
+                        io.Why = "Cannot divide by 0";
+                        throw io;
+                    }
+                    val = work.Num1 / work.Num2;
+                    break;
+
+                default:
+                    {
+                        InvalidOperation io = new InvalidOperation();
+                        io.What = (int)work.Op;
+                        io.Why = "Unknown operation";
+                        throw io;
+                    }
+            }
+
+            SharedStruct entry = new SharedStruct();
+            entry.Key = logid;
+            entry.Value = val.ToString();
+            log[logid] = entry;
+
+            return val;
+        }
+
+        public SharedStruct getStruct(int key)
+        {
+            Console.WriteLine("getStruct({0})", key);
+            return log[key];
+        }
+
+        public void zip()
+        {
+            Console.WriteLine("zip()");
+        }
+    }
+
+    public class CSharpServer
+    {
+        public static void Main()
+        {
+            try
+            {
+                CalculatorHandler handler = new CalculatorHandler();
+                Calculator.Processor processor = new Calculator.Processor(handler);
+                TServerTransport serverTransport = new TServerSocket(9090);
+                TServer server = new TSimpleServer(processor, serverTransport);
+
+                // Use this for a multithreaded server
+                // server = new TThreadPoolServer(processor, serverTransport);
+
+                Console.WriteLine("Starting the server...");
+                server.Serve();
+            }
+            catch (Exception x)
+            {
+                Console.WriteLine(x.StackTrace);
+            }
+            Console.WriteLine("done.");
+        }
+    }
+}
diff --git a/tutorial/csharp/CsharpServer/CsharpServer.csproj b/tutorial/csharp/CsharpServer/CsharpServer.csproj
index aa2ac15..0550261 100644
--- a/tutorial/csharp/CsharpServer/CsharpServer.csproj
+++ b/tutorial/csharp/CsharpServer/CsharpServer.csproj
@@ -1,88 +1,88 @@
-<?xml version="1.0" encoding="utf-8"?>

-<!--

-  Licensed to the Apache Software Foundation (ASF) under one

-  or more contributor license agreements. See the NOTICE file

-  distributed with this work for additional information

-  regarding copyright ownership. The ASF licenses this file

-  to you under the Apache License, Version 2.0 (the

-  "License"); you may not use this file except in compliance

-  with the License. You may obtain a copy of the License at

-

-    http://www.apache.org/licenses/LICENSE-2.0

-

-  Unless required by applicable law or agreed to in writing,

-  software distributed under the License is distributed on an

-  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

-  KIND, either express or implied. See the License for the

-  specific language governing permissions and limitations

-  under the License.

--->

-<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

-  <PropertyGroup>

-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>

-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>

-    <ProductVersion>9.0.30729</ProductVersion>

-    <SchemaVersion>2.0</SchemaVersion>

-    <ProjectGuid>{66707BAE-BBF9-4F03-B53E-BE3AD58322F8}</ProjectGuid>

-    <OutputType>Exe</OutputType>

-    <AppDesignerFolder>Properties</AppDesignerFolder>

-    <RootNamespace>CsharpServer</RootNamespace>

-    <AssemblyName>CsharpServer</AssemblyName>

-    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>

-    <FileAlignment>512</FileAlignment>

-  </PropertyGroup>

-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">

-    <DebugSymbols>true</DebugSymbols>

-    <DebugType>full</DebugType>

-    <Optimize>false</Optimize>

-    <OutputPath>bin\Debug\</OutputPath>

-    <DefineConstants>DEBUG;TRACE</DefineConstants>

-    <ErrorReport>prompt</ErrorReport>

-    <WarningLevel>4</WarningLevel>

-  </PropertyGroup>

-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">

-    <DebugType>pdbonly</DebugType>

-    <Optimize>true</Optimize>

-    <OutputPath>bin\Release\</OutputPath>

-    <DefineConstants>TRACE</DefineConstants>

-    <ErrorReport>prompt</ErrorReport>

-    <WarningLevel>4</WarningLevel>

-  </PropertyGroup>

-  <ItemGroup>

-    <Reference Include="System" />

-    <Reference Include="System.Core">

-      <RequiredTargetFramework>3.5</RequiredTargetFramework>

-    </Reference>

-    <Reference Include="System.Xml.Linq">

-      <RequiredTargetFramework>3.5</RequiredTargetFramework>

-    </Reference>

-    <Reference Include="System.Data.DataSetExtensions">

-      <RequiredTargetFramework>3.5</RequiredTargetFramework>

-    </Reference>

-    <Reference Include="System.Data" />

-    <Reference Include="System.Xml" />

-    <Reference Include="Thrift, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">

-      <SpecificVersion>False</SpecificVersion>

-      <HintPath>..\..\..\lib\csharp\src\bin\Release\Thrift.dll</HintPath>

-    </Reference>

-  </ItemGroup>

-  <ItemGroup>

-    <Compile Include="CsharpServer.cs" />

-    <Compile Include="Properties\AssemblyInfo.cs" />

-    <Compile Include="..\..\gen-csharp\Calculator.cs" />

-    <Compile Include="..\..\gen-csharp\Constants.cs" />

-    <Compile Include="..\..\gen-csharp\InvalidOperation.cs" />

-    <Compile Include="..\..\gen-csharp\Operation.cs" />

-    <Compile Include="..\..\gen-csharp\SharedService.cs" />

-    <Compile Include="..\..\gen-csharp\SharedStruct.cs" />

-    <Compile Include="..\..\gen-csharp\Work.cs" />

-  </ItemGroup>

-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 

-       Other similar extension points exist, see Microsoft.Common.targets.

-  <Target Name="BeforeBuild">

-  </Target>

-  <Target Name="AfterBuild">

-  </Target>

-  -->

+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>9.0.30729</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{66707BAE-BBF9-4F03-B53E-BE3AD58322F8}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>CsharpServer</RootNamespace>
+    <AssemblyName>CsharpServer</AssemblyName>
+    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core">
+      <RequiredTargetFramework>3.5</RequiredTargetFramework>
+    </Reference>
+    <Reference Include="System.Xml.Linq">
+      <RequiredTargetFramework>3.5</RequiredTargetFramework>
+    </Reference>
+    <Reference Include="System.Data.DataSetExtensions">
+      <RequiredTargetFramework>3.5</RequiredTargetFramework>
+    </Reference>
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+    <Reference Include="Thrift, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\lib\csharp\src\bin\Release\Thrift.dll</HintPath>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="CsharpServer.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="..\..\gen-csharp\Calculator.cs" />
+    <Compile Include="..\..\gen-csharp\Constants.cs" />
+    <Compile Include="..\..\gen-csharp\InvalidOperation.cs" />
+    <Compile Include="..\..\gen-csharp\Operation.cs" />
+    <Compile Include="..\..\gen-csharp\SharedService.cs" />
+    <Compile Include="..\..\gen-csharp\SharedStruct.cs" />
+    <Compile Include="..\..\gen-csharp\Work.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
 </Project>
\ No newline at end of file
diff --git a/tutorial/csharp/CsharpServer/Properties/AssemblyInfo.cs b/tutorial/csharp/CsharpServer/Properties/AssemblyInfo.cs
index 9981163..28a69d2 100644
--- a/tutorial/csharp/CsharpServer/Properties/AssemblyInfo.cs
+++ b/tutorial/csharp/CsharpServer/Properties/AssemblyInfo.cs
@@ -1,55 +1,55 @@
-/*

- * Licensed to the Apache Software Foundation (ASF) under one

- * or more contributor license agreements. See the NOTICE file

- * distributed with this work for additional information

- * regarding copyright ownership. The ASF licenses this file

- * to you under the Apache License, Version 2.0 (the

- * "License"); you may not use this file except in compliance

- * with the License. You may obtain a copy of the License at

- *

- *   http://www.apache.org/licenses/LICENSE-2.0

- *

- * Unless required by applicable law or agreed to in writing,

- * software distributed under the License is distributed on an

- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

- * KIND, either express or implied. See the License for the

- * specific language governing permissions and limitations

- * under the License.

- */

-

-using System.Reflection;

-using System.Runtime.CompilerServices;

-using System.Runtime.InteropServices;

-

-// General Information about an assembly is controlled through the following

-// set of attributes. Change these attribute values to modify the information

-// associated with an assembly.

-[assembly: AssemblyTitle("CsharpServer")]

-[assembly: AssemblyDescription("")]

-[assembly: AssemblyConfiguration("")]

-[assembly: AssemblyCompany("")]

-[assembly: AssemblyProduct("CsharpServer")]

-[assembly: AssemblyCopyright("Copyright © 2010 The Apache Software Foundation")]

-[assembly: AssemblyTrademark("")]

-[assembly: AssemblyCulture("")]

-

-// Setting ComVisible to false makes the types in this assembly not visible

-// to COM components.  If you need to access a type in this assembly from

-// COM, set the ComVisible attribute to true on that type.

-[assembly: ComVisible(false)]

-

-// The following GUID is for the ID of the typelib if this project is exposed to COM

-[assembly: Guid("e3b428f4-b2e9-4fc1-8a34-84abc4339860")]

-

-// Version information for an assembly consists of the following four values:

-//

-//      Major Version

-//      Minor Version

-//      Build Number

-//      Revision

-//

-// You can specify all the values or you can default the Build and Revision Numbers

-// by using the '*' as shown below:

-// [assembly: AssemblyVersion("1.0.*")]

-[assembly: AssemblyVersion("1.0.0.0")]

-[assembly: AssemblyFileVersion("1.0.0.0")]

+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("CsharpServer")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("CsharpServer")]
+[assembly: AssemblyCopyright("Copyright © 2010 The Apache Software Foundation")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components.  If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("e3b428f4-b2e9-4fc1-8a34-84abc4339860")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/tutorial/csharp/tutorial.sln b/tutorial/csharp/tutorial.sln
index 5c03e7c..ec57a18 100644
--- a/tutorial/csharp/tutorial.sln
+++ b/tutorial/csharp/tutorial.sln
@@ -1,39 +1,39 @@
-

-Microsoft Visual Studio Solution File, Format Version 11.00

-# Visual Studio 2010

-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Thrift", "..\..\lib\csharp\src\Thrift.csproj", "{499EB63C-D74C-47E8-AE48-A2FC94538E9D}"

-EndProject

-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CsharpClient", "CsharpClient\CsharpClient.csproj", "{18F24087-4760-43DA-ACAB-7B9F0E096B11}"

-	ProjectSection(ProjectDependencies) = postProject

-		{499EB63C-D74C-47E8-AE48-A2FC94538E9D} = {499EB63C-D74C-47E8-AE48-A2FC94538E9D}

-		{66707BAE-BBF9-4F03-B53E-BE3AD58322F8} = {66707BAE-BBF9-4F03-B53E-BE3AD58322F8}

-	EndProjectSection

-EndProject

-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CsharpServer", "CsharpServer\CsharpServer.csproj", "{66707BAE-BBF9-4F03-B53E-BE3AD58322F8}"

-	ProjectSection(ProjectDependencies) = postProject

-		{499EB63C-D74C-47E8-AE48-A2FC94538E9D} = {499EB63C-D74C-47E8-AE48-A2FC94538E9D}

-	EndProjectSection

-EndProject

-Global

-	GlobalSection(SolutionConfigurationPlatforms) = preSolution

-		Debug|Any CPU = Debug|Any CPU

-		Release|Any CPU = Release|Any CPU

-	EndGlobalSection

-	GlobalSection(ProjectConfigurationPlatforms) = postSolution

-		{499EB63C-D74C-47E8-AE48-A2FC94538E9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU

-		{499EB63C-D74C-47E8-AE48-A2FC94538E9D}.Debug|Any CPU.Build.0 = Debug|Any CPU

-		{499EB63C-D74C-47E8-AE48-A2FC94538E9D}.Release|Any CPU.ActiveCfg = Release|Any CPU

-		{499EB63C-D74C-47E8-AE48-A2FC94538E9D}.Release|Any CPU.Build.0 = Release|Any CPU

-		{18F24087-4760-43DA-ACAB-7B9F0E096B11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU

-		{18F24087-4760-43DA-ACAB-7B9F0E096B11}.Debug|Any CPU.Build.0 = Debug|Any CPU

-		{18F24087-4760-43DA-ACAB-7B9F0E096B11}.Release|Any CPU.ActiveCfg = Release|Any CPU

-		{18F24087-4760-43DA-ACAB-7B9F0E096B11}.Release|Any CPU.Build.0 = Release|Any CPU

-		{66707BAE-BBF9-4F03-B53E-BE3AD58322F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU

-		{66707BAE-BBF9-4F03-B53E-BE3AD58322F8}.Debug|Any CPU.Build.0 = Debug|Any CPU

-		{66707BAE-BBF9-4F03-B53E-BE3AD58322F8}.Release|Any CPU.ActiveCfg = Release|Any CPU

-		{66707BAE-BBF9-4F03-B53E-BE3AD58322F8}.Release|Any CPU.Build.0 = Release|Any CPU

-	EndGlobalSection

-	GlobalSection(SolutionProperties) = preSolution

-		HideSolutionNode = FALSE

-	EndGlobalSection

-EndGlobal

+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Thrift", "..\..\lib\csharp\src\Thrift.csproj", "{499EB63C-D74C-47E8-AE48-A2FC94538E9D}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CsharpClient", "CsharpClient\CsharpClient.csproj", "{18F24087-4760-43DA-ACAB-7B9F0E096B11}"
+    ProjectSection(ProjectDependencies) = postProject
+        {499EB63C-D74C-47E8-AE48-A2FC94538E9D} = {499EB63C-D74C-47E8-AE48-A2FC94538E9D}
+        {66707BAE-BBF9-4F03-B53E-BE3AD58322F8} = {66707BAE-BBF9-4F03-B53E-BE3AD58322F8}
+    EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CsharpServer", "CsharpServer\CsharpServer.csproj", "{66707BAE-BBF9-4F03-B53E-BE3AD58322F8}"
+    ProjectSection(ProjectDependencies) = postProject
+        {499EB63C-D74C-47E8-AE48-A2FC94538E9D} = {499EB63C-D74C-47E8-AE48-A2FC94538E9D}
+    EndProjectSection
+EndProject
+Global
+    GlobalSection(SolutionConfigurationPlatforms) = preSolution
+        Debug|Any CPU = Debug|Any CPU
+        Release|Any CPU = Release|Any CPU
+    EndGlobalSection
+    GlobalSection(ProjectConfigurationPlatforms) = postSolution
+        {499EB63C-D74C-47E8-AE48-A2FC94538E9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+        {499EB63C-D74C-47E8-AE48-A2FC94538E9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+        {499EB63C-D74C-47E8-AE48-A2FC94538E9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+        {499EB63C-D74C-47E8-AE48-A2FC94538E9D}.Release|Any CPU.Build.0 = Release|Any CPU
+        {18F24087-4760-43DA-ACAB-7B9F0E096B11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+        {18F24087-4760-43DA-ACAB-7B9F0E096B11}.Debug|Any CPU.Build.0 = Debug|Any CPU
+        {18F24087-4760-43DA-ACAB-7B9F0E096B11}.Release|Any CPU.ActiveCfg = Release|Any CPU
+        {18F24087-4760-43DA-ACAB-7B9F0E096B11}.Release|Any CPU.Build.0 = Release|Any CPU
+        {66707BAE-BBF9-4F03-B53E-BE3AD58322F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+        {66707BAE-BBF9-4F03-B53E-BE3AD58322F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+        {66707BAE-BBF9-4F03-B53E-BE3AD58322F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+        {66707BAE-BBF9-4F03-B53E-BE3AD58322F8}.Release|Any CPU.Build.0 = Release|Any CPU
+    EndGlobalSection
+    GlobalSection(SolutionProperties) = preSolution
+        HideSolutionNode = FALSE
+    EndGlobalSection
+EndGlobal
diff --git a/tutorial/delphi/DelphiClient/DelphiClient.dproj b/tutorial/delphi/DelphiClient/DelphiClient.dproj
index ab0a1c1..34aa533 100644
--- a/tutorial/delphi/DelphiClient/DelphiClient.dproj
+++ b/tutorial/delphi/DelphiClient/DelphiClient.dproj
@@ -1,119 +1,119 @@
-	<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-		<PropertyGroup>
-			<ProjectGuid>{2B8FB3A1-2F9E-4883-8C53-0F56220B34F6}</ProjectGuid>
-			<MainSource>DelphiClient.dpr</MainSource>
-			<ProjectVersion>12.3</ProjectVersion>
-			<Basis>True</Basis>
-			<Config Condition="'$(Config)'==''">Debug</Config>
-			<Platform>Win32</Platform>
-			<AppType>Console</AppType>
-			<FrameworkType>None</FrameworkType>
-			<DCC_DCCCompiler>DCC32</DCC_DCCCompiler>
-		</PropertyGroup>
-		<PropertyGroup Condition="'$(Config)'=='Basis' or '$(Base)'!=''">
-			<Base>true</Base>
-		</PropertyGroup>
-		<PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_1)'!=''">
-			<Cfg_1>true</Cfg_1>
-			<CfgParent>Base</CfgParent>
-			<Base>true</Base>
-		</PropertyGroup>
-		<PropertyGroup Condition="'$(Config)'=='Release' or '$(Cfg_2)'!=''">
-			<Cfg_2>true</Cfg_2>
-			<CfgParent>Base</CfgParent>
-			<Base>true</Base>
-		</PropertyGroup>
-		<PropertyGroup Condition="'$(Base)'!=''">
-			<DCC_UnitSearchPath>..\..\..\lib\delphi\src;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
-			<DCC_ImageBase>00400000</DCC_ImageBase>
-			<DCC_DcuOutput>.\dcu\$(Config)\$(Platform)</DCC_DcuOutput>
-			<DCC_UnitAlias>WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;$(DCC_UnitAlias)</DCC_UnitAlias>
-			<DCC_ExeOutput>..\bin\$(Config)\$(Platform)</DCC_ExeOutput>
-			<DCC_E>false</DCC_E>
-			<DCC_N>false</DCC_N>
-			<DCC_S>false</DCC_S>
-			<DCC_F>false</DCC_F>
-			<DCC_K>false</DCC_K>
-		</PropertyGroup>
-		<PropertyGroup Condition="'$(Cfg_1)'!=''">
-			<DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
-			<DCC_Optimize>false</DCC_Optimize>
-			<DCC_GenerateStackFrames>true</DCC_GenerateStackFrames>
-		</PropertyGroup>
-		<PropertyGroup Condition="'$(Cfg_2)'!=''">
-			<DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
-			<DCC_Define>RELEASE;$(DCC_Define)</DCC_Define>
-			<DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
-			<DCC_DebugInformation>false</DCC_DebugInformation>
-		</PropertyGroup>
-		<ItemGroup>
-			<DelphiCompile Include="DelphiClient.dpr">
-				<MainSource>MainSource</MainSource>
-			</DelphiCompile>
-			<DCCReference Include="..\..\..\lib\delphi\src\Thrift.pas"/>
-			<DCCReference Include="..\..\..\lib\delphi\src\Thrift.Collections.pas"/>
-			<DCCReference Include="..\..\..\lib\delphi\src\Thrift.Console.pas"/>
-			<DCCReference Include="..\..\..\lib\delphi\src\Thrift.Utils.pas"/>
-			<DCCReference Include="..\..\..\lib\delphi\src\Thrift.Stream.pas"/>
-			<DCCReference Include="..\..\..\lib\delphi\src\Thrift.Protocol.pas"/>
-			<DCCReference Include="..\..\..\lib\delphi\src\Thrift.Server.pas"/>
-			<DCCReference Include="..\..\..\lib\delphi\src\Thrift.Transport.pas"/>
-			<DCCReference Include="..\..\gen-delphi\Shared.pas"/>
-			<DCCReference Include="..\..\gen-delphi\Tutorial.pas"/>
-			<BuildConfiguration Include="Release">
-				<Key>Cfg_2</Key>
-				<CfgParent>Base</CfgParent>
-			</BuildConfiguration>
-			<BuildConfiguration Include="Basis">
-				<Key>Base</Key>
-			</BuildConfiguration>
-			<BuildConfiguration Include="Debug">
-				<Key>Cfg_1</Key>
-				<CfgParent>Base</CfgParent>
-			</BuildConfiguration>
-		</ItemGroup>
-		<Import Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')" Project="$(BDS)\Bin\CodeGear.Delphi.Targets"/>
-		<Import Condition="Exists('$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj')" Project="$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj"/>
-		<ProjectExtensions>
-			<Borland.Personality>Delphi.Personality.12</Borland.Personality>
-			<Borland.ProjectType/>
-			<BorlandProject>
-				<Delphi.Personality>
-					<VersionInfo>
-						<VersionInfo Name="IncludeVerInfo">True</VersionInfo>
-						<VersionInfo Name="AutoIncBuild">False</VersionInfo>
-						<VersionInfo Name="MajorVer">1</VersionInfo>
-						<VersionInfo Name="MinorVer">0</VersionInfo>
-						<VersionInfo Name="Release">0</VersionInfo>
-						<VersionInfo Name="Build">0</VersionInfo>
-						<VersionInfo Name="Debug">False</VersionInfo>
-						<VersionInfo Name="PreRelease">False</VersionInfo>
-						<VersionInfo Name="Special">False</VersionInfo>
-						<VersionInfo Name="Private">False</VersionInfo>
-						<VersionInfo Name="DLL">False</VersionInfo>
-						<VersionInfo Name="Locale">1033</VersionInfo>
-						<VersionInfo Name="CodePage">1252</VersionInfo>
-					</VersionInfo>
-					<VersionInfoKeys>
-						<VersionInfoKeys Name="CompanyName"/>
-						<VersionInfoKeys Name="FileDescription">Thrift Tutorial</VersionInfoKeys>
-						<VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys>
-						<VersionInfoKeys Name="InternalName">DelphiClient</VersionInfoKeys>
-						<VersionInfoKeys Name="LegalCopyright">Copyright © 2012 The Apache Software Foundation</VersionInfoKeys>
-						<VersionInfoKeys Name="LegalTrademarks"/>
-						<VersionInfoKeys Name="OriginalFilename">DelphiClient.exe</VersionInfoKeys>
-						<VersionInfoKeys Name="ProductName">Thrift</VersionInfoKeys>
-						<VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
-						<VersionInfoKeys Name="Comments"/>
-					</VersionInfoKeys>
-					<Source>
-						<Source Name="MainSource">DelphiClient.dpr</Source>
-					</Source>
-				</Delphi.Personality>
-				<Platforms>
-					<Platform value="Win32">True</Platform>
-				</Platforms>
-			</BorlandProject>
-			<ProjectFileVersion>12</ProjectFileVersion>
-		</ProjectExtensions>
-	</Project>
+    <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+        <PropertyGroup>
+            <ProjectGuid>{2B8FB3A1-2F9E-4883-8C53-0F56220B34F6}</ProjectGuid>
+            <MainSource>DelphiClient.dpr</MainSource>
+            <ProjectVersion>12.3</ProjectVersion>
+            <Basis>True</Basis>
+            <Config Condition="'$(Config)'==''">Debug</Config>
+            <Platform>Win32</Platform>
+            <AppType>Console</AppType>
+            <FrameworkType>None</FrameworkType>
+            <DCC_DCCCompiler>DCC32</DCC_DCCCompiler>
+        </PropertyGroup>
+        <PropertyGroup Condition="'$(Config)'=='Basis' or '$(Base)'!=''">
+            <Base>true</Base>
+        </PropertyGroup>
+        <PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_1)'!=''">
+            <Cfg_1>true</Cfg_1>
+            <CfgParent>Base</CfgParent>
+            <Base>true</Base>
+        </PropertyGroup>
+        <PropertyGroup Condition="'$(Config)'=='Release' or '$(Cfg_2)'!=''">
+            <Cfg_2>true</Cfg_2>
+            <CfgParent>Base</CfgParent>
+            <Base>true</Base>
+        </PropertyGroup>
+        <PropertyGroup Condition="'$(Base)'!=''">
+            <DCC_UnitSearchPath>..\..\..\lib\delphi\src;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
+            <DCC_ImageBase>00400000</DCC_ImageBase>
+            <DCC_DcuOutput>.\dcu\$(Config)\$(Platform)</DCC_DcuOutput>
+            <DCC_UnitAlias>WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;$(DCC_UnitAlias)</DCC_UnitAlias>
+            <DCC_ExeOutput>..\bin\$(Config)\$(Platform)</DCC_ExeOutput>
+            <DCC_E>false</DCC_E>
+            <DCC_N>false</DCC_N>
+            <DCC_S>false</DCC_S>
+            <DCC_F>false</DCC_F>
+            <DCC_K>false</DCC_K>
+        </PropertyGroup>
+        <PropertyGroup Condition="'$(Cfg_1)'!=''">
+            <DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
+            <DCC_Optimize>false</DCC_Optimize>
+            <DCC_GenerateStackFrames>true</DCC_GenerateStackFrames>
+        </PropertyGroup>
+        <PropertyGroup Condition="'$(Cfg_2)'!=''">
+            <DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
+            <DCC_Define>RELEASE;$(DCC_Define)</DCC_Define>
+            <DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
+            <DCC_DebugInformation>false</DCC_DebugInformation>
+        </PropertyGroup>
+        <ItemGroup>
+            <DelphiCompile Include="DelphiClient.dpr">
+                <MainSource>MainSource</MainSource>
+            </DelphiCompile>
+            <DCCReference Include="..\..\..\lib\delphi\src\Thrift.pas"/>
+            <DCCReference Include="..\..\..\lib\delphi\src\Thrift.Collections.pas"/>
+            <DCCReference Include="..\..\..\lib\delphi\src\Thrift.Console.pas"/>
+            <DCCReference Include="..\..\..\lib\delphi\src\Thrift.Utils.pas"/>
+            <DCCReference Include="..\..\..\lib\delphi\src\Thrift.Stream.pas"/>
+            <DCCReference Include="..\..\..\lib\delphi\src\Thrift.Protocol.pas"/>
+            <DCCReference Include="..\..\..\lib\delphi\src\Thrift.Server.pas"/>
+            <DCCReference Include="..\..\..\lib\delphi\src\Thrift.Transport.pas"/>
+            <DCCReference Include="..\..\gen-delphi\Shared.pas"/>
+            <DCCReference Include="..\..\gen-delphi\Tutorial.pas"/>
+            <BuildConfiguration Include="Release">
+                <Key>Cfg_2</Key>
+                <CfgParent>Base</CfgParent>
+            </BuildConfiguration>
+            <BuildConfiguration Include="Basis">
+                <Key>Base</Key>
+            </BuildConfiguration>
+            <BuildConfiguration Include="Debug">
+                <Key>Cfg_1</Key>
+                <CfgParent>Base</CfgParent>
+            </BuildConfiguration>
+        </ItemGroup>
+        <Import Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')" Project="$(BDS)\Bin\CodeGear.Delphi.Targets"/>
+        <Import Condition="Exists('$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj')" Project="$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj"/>
+        <ProjectExtensions>
+            <Borland.Personality>Delphi.Personality.12</Borland.Personality>
+            <Borland.ProjectType/>
+            <BorlandProject>
+                <Delphi.Personality>
+                    <VersionInfo>
+                        <VersionInfo Name="IncludeVerInfo">True</VersionInfo>
+                        <VersionInfo Name="AutoIncBuild">False</VersionInfo>
+                        <VersionInfo Name="MajorVer">1</VersionInfo>
+                        <VersionInfo Name="MinorVer">0</VersionInfo>
+                        <VersionInfo Name="Release">0</VersionInfo>
+                        <VersionInfo Name="Build">0</VersionInfo>
+                        <VersionInfo Name="Debug">False</VersionInfo>
+                        <VersionInfo Name="PreRelease">False</VersionInfo>
+                        <VersionInfo Name="Special">False</VersionInfo>
+                        <VersionInfo Name="Private">False</VersionInfo>
+                        <VersionInfo Name="DLL">False</VersionInfo>
+                        <VersionInfo Name="Locale">1033</VersionInfo>
+                        <VersionInfo Name="CodePage">1252</VersionInfo>
+                    </VersionInfo>
+                    <VersionInfoKeys>
+                        <VersionInfoKeys Name="CompanyName"/>
+                        <VersionInfoKeys Name="FileDescription">Thrift Tutorial</VersionInfoKeys>
+                        <VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys>
+                        <VersionInfoKeys Name="InternalName">DelphiClient</VersionInfoKeys>
+                        <VersionInfoKeys Name="LegalCopyright">Copyright © 2012 The Apache Software Foundation</VersionInfoKeys>
+                        <VersionInfoKeys Name="LegalTrademarks"/>
+                        <VersionInfoKeys Name="OriginalFilename">DelphiClient.exe</VersionInfoKeys>
+                        <VersionInfoKeys Name="ProductName">Thrift</VersionInfoKeys>
+                        <VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
+                        <VersionInfoKeys Name="Comments"/>
+                    </VersionInfoKeys>
+                    <Source>
+                        <Source Name="MainSource">DelphiClient.dpr</Source>
+                    </Source>
+                </Delphi.Personality>
+                <Platforms>
+                    <Platform value="Win32">True</Platform>
+                </Platforms>
+            </BorlandProject>
+            <ProjectFileVersion>12</ProjectFileVersion>
+        </ProjectExtensions>
+    </Project>
diff --git a/tutorial/delphi/DelphiServer/DelphiServer.dproj b/tutorial/delphi/DelphiServer/DelphiServer.dproj
index c5071a3..74811bc 100644
--- a/tutorial/delphi/DelphiServer/DelphiServer.dproj
+++ b/tutorial/delphi/DelphiServer/DelphiServer.dproj
@@ -1,118 +1,118 @@
-	<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-		<PropertyGroup>
-			<ProjectGuid>{2B8FB3A1-2F9E-4883-8C53-0F56220B34F6}</ProjectGuid>
-			<MainSource>DelphiServer.dpr</MainSource>
-			<ProjectVersion>12.3</ProjectVersion>
-			<Basis>True</Basis>
-			<Config Condition="'$(Config)'==''">Debug</Config>
-			<Platform>Win32</Platform>
-			<AppType>Console</AppType>
-			<FrameworkType>None</FrameworkType>
-			<DCC_DCCCompiler>DCC32</DCC_DCCCompiler>
-		</PropertyGroup>
-		<PropertyGroup Condition="'$(Config)'=='Basis' or '$(Base)'!=''">
-			<Base>true</Base>
-		</PropertyGroup>
-		<PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_1)'!=''">
-			<Cfg_1>true</Cfg_1>
-			<CfgParent>Base</CfgParent>
-			<Base>true</Base>
-		</PropertyGroup>
-		<PropertyGroup Condition="'$(Config)'=='Release' or '$(Cfg_2)'!=''">
-			<Cfg_2>true</Cfg_2>
-			<CfgParent>Base</CfgParent>
-			<Base>true</Base>
-		</PropertyGroup>
-		<PropertyGroup Condition="'$(Base)'!=''">
-			<DCC_ImageBase>00400000</DCC_ImageBase>
-			<DCC_DcuOutput>.\dcu\$(Config)\$(Platform)</DCC_DcuOutput>
-			<DCC_UnitAlias>WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;$(DCC_UnitAlias)</DCC_UnitAlias>
-			<DCC_ExeOutput>..\bin\$(Config)\$(Platform)</DCC_ExeOutput>
-			<DCC_E>false</DCC_E>
-			<DCC_N>false</DCC_N>
-			<DCC_S>false</DCC_S>
-			<DCC_F>false</DCC_F>
-			<DCC_K>false</DCC_K>
-		</PropertyGroup>
-		<PropertyGroup Condition="'$(Cfg_1)'!=''">
-			<DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
-			<DCC_Optimize>false</DCC_Optimize>
-			<DCC_GenerateStackFrames>true</DCC_GenerateStackFrames>
-		</PropertyGroup>
-		<PropertyGroup Condition="'$(Cfg_2)'!=''">
-			<DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
-			<DCC_Define>RELEASE;$(DCC_Define)</DCC_Define>
-			<DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
-			<DCC_DebugInformation>false</DCC_DebugInformation>
-		</PropertyGroup>
-		<ItemGroup>
-			<DelphiCompile Include="DelphiServer.dpr">
-				<MainSource>MainSource</MainSource>
-			</DelphiCompile>
-			<DCCReference Include="..\..\..\lib\delphi\src\Thrift.pas"/>
-			<DCCReference Include="..\..\..\lib\delphi\src\Thrift.Collections.pas"/>
-			<DCCReference Include="..\..\..\lib\delphi\src\Thrift.Console.pas"/>
-			<DCCReference Include="..\..\..\lib\delphi\src\Thrift.Utils.pas"/>
-			<DCCReference Include="..\..\..\lib\delphi\src\Thrift.Stream.pas"/>
-			<DCCReference Include="..\..\..\lib\delphi\src\Thrift.Protocol.pas"/>
-			<DCCReference Include="..\..\..\lib\delphi\src\Thrift.Server.pas"/>
-			<DCCReference Include="..\..\..\lib\delphi\src\Thrift.Transport.pas"/>
-			<DCCReference Include="..\..\gen-delphi\Shared.pas"/>
-			<DCCReference Include="..\..\gen-delphi\Tutorial.pas"/>
-			<BuildConfiguration Include="Release">
-				<Key>Cfg_2</Key>
-				<CfgParent>Base</CfgParent>
-			</BuildConfiguration>
-			<BuildConfiguration Include="Basis">
-				<Key>Base</Key>
-			</BuildConfiguration>
-			<BuildConfiguration Include="Debug">
-				<Key>Cfg_1</Key>
-				<CfgParent>Base</CfgParent>
-			</BuildConfiguration>
-		</ItemGroup>
-		<Import Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')" Project="$(BDS)\Bin\CodeGear.Delphi.Targets"/>
-		<Import Condition="Exists('$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj')" Project="$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj"/>
-		<ProjectExtensions>
-			<Borland.Personality>Delphi.Personality.12</Borland.Personality>
-			<Borland.ProjectType/>
-			<BorlandProject>
-				<Delphi.Personality>
-					<VersionInfo>
-						<VersionInfo Name="IncludeVerInfo">True</VersionInfo>
-						<VersionInfo Name="AutoIncBuild">False</VersionInfo>
-						<VersionInfo Name="MajorVer">1</VersionInfo>
-						<VersionInfo Name="MinorVer">0</VersionInfo>
-						<VersionInfo Name="Release">0</VersionInfo>
-						<VersionInfo Name="Build">0</VersionInfo>
-						<VersionInfo Name="Debug">False</VersionInfo>
-						<VersionInfo Name="PreRelease">False</VersionInfo>
-						<VersionInfo Name="Special">False</VersionInfo>
-						<VersionInfo Name="Private">False</VersionInfo>
-						<VersionInfo Name="DLL">False</VersionInfo>
-						<VersionInfo Name="Locale">1033</VersionInfo>
-						<VersionInfo Name="CodePage">1252</VersionInfo>
-					</VersionInfo>
-					<VersionInfoKeys>
-						<VersionInfoKeys Name="CompanyName"/>
-						<VersionInfoKeys Name="FileDescription">Thrift Tutorial</VersionInfoKeys>
-						<VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys>
-						<VersionInfoKeys Name="InternalName">DelphiServer</VersionInfoKeys>
-						<VersionInfoKeys Name="LegalCopyright">Copyright © 2012 The Apache Software Foundation</VersionInfoKeys>
-						<VersionInfoKeys Name="LegalTrademarks"/>
-						<VersionInfoKeys Name="OriginalFilename">DelphiServer.exe</VersionInfoKeys>
-						<VersionInfoKeys Name="ProductName">Thrift</VersionInfoKeys>
-						<VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
-						<VersionInfoKeys Name="Comments"/>
-					</VersionInfoKeys>
-					<Source>
-						<Source Name="MainSource">DelphiServer.dpr</Source>
-					</Source>
-				</Delphi.Personality>
-				<Platforms>
-					<Platform value="Win32">True</Platform>
-				</Platforms>
-			</BorlandProject>
-			<ProjectFileVersion>12</ProjectFileVersion>
-		</ProjectExtensions>
-	</Project>
+    <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+        <PropertyGroup>
+            <ProjectGuid>{2B8FB3A1-2F9E-4883-8C53-0F56220B34F6}</ProjectGuid>
+            <MainSource>DelphiServer.dpr</MainSource>
+            <ProjectVersion>12.3</ProjectVersion>
+            <Basis>True</Basis>
+            <Config Condition="'$(Config)'==''">Debug</Config>
+            <Platform>Win32</Platform>
+            <AppType>Console</AppType>
+            <FrameworkType>None</FrameworkType>
+            <DCC_DCCCompiler>DCC32</DCC_DCCCompiler>
+        </PropertyGroup>
+        <PropertyGroup Condition="'$(Config)'=='Basis' or '$(Base)'!=''">
+            <Base>true</Base>
+        </PropertyGroup>
+        <PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_1)'!=''">
+            <Cfg_1>true</Cfg_1>
+            <CfgParent>Base</CfgParent>
+            <Base>true</Base>
+        </PropertyGroup>
+        <PropertyGroup Condition="'$(Config)'=='Release' or '$(Cfg_2)'!=''">
+            <Cfg_2>true</Cfg_2>
+            <CfgParent>Base</CfgParent>
+            <Base>true</Base>
+        </PropertyGroup>
+        <PropertyGroup Condition="'$(Base)'!=''">
+            <DCC_ImageBase>00400000</DCC_ImageBase>
+            <DCC_DcuOutput>.\dcu\$(Config)\$(Platform)</DCC_DcuOutput>
+            <DCC_UnitAlias>WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;$(DCC_UnitAlias)</DCC_UnitAlias>
+            <DCC_ExeOutput>..\bin\$(Config)\$(Platform)</DCC_ExeOutput>
+            <DCC_E>false</DCC_E>
+            <DCC_N>false</DCC_N>
+            <DCC_S>false</DCC_S>
+            <DCC_F>false</DCC_F>
+            <DCC_K>false</DCC_K>
+        </PropertyGroup>
+        <PropertyGroup Condition="'$(Cfg_1)'!=''">
+            <DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
+            <DCC_Optimize>false</DCC_Optimize>
+            <DCC_GenerateStackFrames>true</DCC_GenerateStackFrames>
+        </PropertyGroup>
+        <PropertyGroup Condition="'$(Cfg_2)'!=''">
+            <DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
+            <DCC_Define>RELEASE;$(DCC_Define)</DCC_Define>
+            <DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
+            <DCC_DebugInformation>false</DCC_DebugInformation>
+        </PropertyGroup>
+        <ItemGroup>
+            <DelphiCompile Include="DelphiServer.dpr">
+                <MainSource>MainSource</MainSource>
+            </DelphiCompile>
+            <DCCReference Include="..\..\..\lib\delphi\src\Thrift.pas"/>
+            <DCCReference Include="..\..\..\lib\delphi\src\Thrift.Collections.pas"/>
+            <DCCReference Include="..\..\..\lib\delphi\src\Thrift.Console.pas"/>
+            <DCCReference Include="..\..\..\lib\delphi\src\Thrift.Utils.pas"/>
+            <DCCReference Include="..\..\..\lib\delphi\src\Thrift.Stream.pas"/>
+            <DCCReference Include="..\..\..\lib\delphi\src\Thrift.Protocol.pas"/>
+            <DCCReference Include="..\..\..\lib\delphi\src\Thrift.Server.pas"/>
+            <DCCReference Include="..\..\..\lib\delphi\src\Thrift.Transport.pas"/>
+            <DCCReference Include="..\..\gen-delphi\Shared.pas"/>
+            <DCCReference Include="..\..\gen-delphi\Tutorial.pas"/>
+            <BuildConfiguration Include="Release">
+                <Key>Cfg_2</Key>
+                <CfgParent>Base</CfgParent>
+            </BuildConfiguration>
+            <BuildConfiguration Include="Basis">
+                <Key>Base</Key>
+            </BuildConfiguration>
+            <BuildConfiguration Include="Debug">
+                <Key>Cfg_1</Key>
+                <CfgParent>Base</CfgParent>
+            </BuildConfiguration>
+        </ItemGroup>
+        <Import Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')" Project="$(BDS)\Bin\CodeGear.Delphi.Targets"/>
+        <Import Condition="Exists('$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj')" Project="$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj"/>
+        <ProjectExtensions>
+            <Borland.Personality>Delphi.Personality.12</Borland.Personality>
+            <Borland.ProjectType/>
+            <BorlandProject>
+                <Delphi.Personality>
+                    <VersionInfo>
+                        <VersionInfo Name="IncludeVerInfo">True</VersionInfo>
+                        <VersionInfo Name="AutoIncBuild">False</VersionInfo>
+                        <VersionInfo Name="MajorVer">1</VersionInfo>
+                        <VersionInfo Name="MinorVer">0</VersionInfo>
+                        <VersionInfo Name="Release">0</VersionInfo>
+                        <VersionInfo Name="Build">0</VersionInfo>
+                        <VersionInfo Name="Debug">False</VersionInfo>
+                        <VersionInfo Name="PreRelease">False</VersionInfo>
+                        <VersionInfo Name="Special">False</VersionInfo>
+                        <VersionInfo Name="Private">False</VersionInfo>
+                        <VersionInfo Name="DLL">False</VersionInfo>
+                        <VersionInfo Name="Locale">1033</VersionInfo>
+                        <VersionInfo Name="CodePage">1252</VersionInfo>
+                    </VersionInfo>
+                    <VersionInfoKeys>
+                        <VersionInfoKeys Name="CompanyName"/>
+                        <VersionInfoKeys Name="FileDescription">Thrift Tutorial</VersionInfoKeys>
+                        <VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys>
+                        <VersionInfoKeys Name="InternalName">DelphiServer</VersionInfoKeys>
+                        <VersionInfoKeys Name="LegalCopyright">Copyright © 2012 The Apache Software Foundation</VersionInfoKeys>
+                        <VersionInfoKeys Name="LegalTrademarks"/>
+                        <VersionInfoKeys Name="OriginalFilename">DelphiServer.exe</VersionInfoKeys>
+                        <VersionInfoKeys Name="ProductName">Thrift</VersionInfoKeys>
+                        <VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
+                        <VersionInfoKeys Name="Comments"/>
+                    </VersionInfoKeys>
+                    <Source>
+                        <Source Name="MainSource">DelphiServer.dpr</Source>
+                    </Source>
+                </Delphi.Personality>
+                <Platforms>
+                    <Platform value="Win32">True</Platform>
+                </Platforms>
+            </BorlandProject>
+            <ProjectFileVersion>12</ProjectFileVersion>
+        </ProjectExtensions>
+    </Project>
diff --git a/tutorial/delphi/Tutorial.groupproj b/tutorial/delphi/Tutorial.groupproj
index 486e612..3a2a237 100644
--- a/tutorial/delphi/Tutorial.groupproj
+++ b/tutorial/delphi/Tutorial.groupproj
@@ -1,48 +1,48 @@
-	<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-		<PropertyGroup>
-			<ProjectGuid>{3D042C7F-3EF2-4574-8304-AB7FB79F814C}</ProjectGuid>
-		</PropertyGroup>
-		<ItemGroup>
-			<Projects Include="DelphiServer\DelphiServer.dproj">
-				<Dependencies/>
-			</Projects>
-			<Projects Include="DelphiClient\DelphiClient.dproj">
-				<Dependencies/>
-			</Projects>
-		</ItemGroup>
-		<ProjectExtensions>
-			<Borland.Personality>Default.Personality.12</Borland.Personality>
-			<Borland.ProjectType/>
-			<BorlandProject>
-				<Default.Personality/>
-			</BorlandProject>
-		</ProjectExtensions>
-		<Target Name="DelphiServer">
-			<MSBuild Projects="DelphiServer\DelphiServer.dproj"/>
-		</Target>
-		<Target Name="DelphiServer:Clean">
-			<MSBuild Projects="DelphiServer\DelphiServer.dproj" Targets="Clean"/>
-		</Target>
-		<Target Name="DelphiServer:Make">
-			<MSBuild Projects="DelphiServer\DelphiServer.dproj" Targets="Make"/>
-		</Target>
-		<Target Name="DelphiClient">
-			<MSBuild Projects="DelphiClient\DelphiClient.dproj"/>
-		</Target>
-		<Target Name="DelphiClient:Clean">
-			<MSBuild Projects="DelphiClient\DelphiClient.dproj" Targets="Clean"/>
-		</Target>
-		<Target Name="DelphiClient:Make">
-			<MSBuild Projects="DelphiClient\DelphiClient.dproj" Targets="Make"/>
-		</Target>
-		<Target Name="Build">
-			<CallTarget Targets="DelphiServer;DelphiClient"/>
-		</Target>
-		<Target Name="Clean">
-			<CallTarget Targets="DelphiServer:Clean;DelphiClient:Clean"/>
-		</Target>
-		<Target Name="Make">
-			<CallTarget Targets="DelphiServer:Make;DelphiClient:Make"/>
-		</Target>
-		<Import Condition="Exists('$(BDS)\Bin\CodeGear.Group.Targets')" Project="$(BDS)\Bin\CodeGear.Group.Targets"/>
-	</Project>
+    <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+        <PropertyGroup>
+            <ProjectGuid>{3D042C7F-3EF2-4574-8304-AB7FB79F814C}</ProjectGuid>
+        </PropertyGroup>
+        <ItemGroup>
+            <Projects Include="DelphiServer\DelphiServer.dproj">
+                <Dependencies/>
+            </Projects>
+            <Projects Include="DelphiClient\DelphiClient.dproj">
+                <Dependencies/>
+            </Projects>
+        </ItemGroup>
+        <ProjectExtensions>
+            <Borland.Personality>Default.Personality.12</Borland.Personality>
+            <Borland.ProjectType/>
+            <BorlandProject>
+                <Default.Personality/>
+            </BorlandProject>
+        </ProjectExtensions>
+        <Target Name="DelphiServer">
+            <MSBuild Projects="DelphiServer\DelphiServer.dproj"/>
+        </Target>
+        <Target Name="DelphiServer:Clean">
+            <MSBuild Projects="DelphiServer\DelphiServer.dproj" Targets="Clean"/>
+        </Target>
+        <Target Name="DelphiServer:Make">
+            <MSBuild Projects="DelphiServer\DelphiServer.dproj" Targets="Make"/>
+        </Target>
+        <Target Name="DelphiClient">
+            <MSBuild Projects="DelphiClient\DelphiClient.dproj"/>
+        </Target>
+        <Target Name="DelphiClient:Clean">
+            <MSBuild Projects="DelphiClient\DelphiClient.dproj" Targets="Clean"/>
+        </Target>
+        <Target Name="DelphiClient:Make">
+            <MSBuild Projects="DelphiClient\DelphiClient.dproj" Targets="Make"/>
+        </Target>
+        <Target Name="Build">
+            <CallTarget Targets="DelphiServer;DelphiClient"/>
+        </Target>
+        <Target Name="Clean">
+            <CallTarget Targets="DelphiServer:Clean;DelphiClient:Clean"/>
+        </Target>
+        <Target Name="Make">
+            <CallTarget Targets="DelphiServer:Make;DelphiClient:Make"/>
+        </Target>
+        <Import Condition="Exists('$(BDS)\Bin\CodeGear.Group.Targets')" Project="$(BDS)\Bin\CodeGear.Group.Targets"/>
+    </Project>