"using System.Collections.Generic;\n" +
"using System.Text;\n" +
"using System.IO;\n" +
- "using Thrift;\n";
+ "using Thrift;\n" +
+ "using Thrift.Collections;\n";
}
string t_csharp_generator::csharp_thrift_usings() {
", " + type_name(tmap->get_val_type(), true) + ">";
} else if (ttype->is_set()) {
t_set* tset = (t_set*) ttype;
- return "HashSet<" + type_name(tset->get_elem_type(), true) + ">";
+ return "THashSet<" + type_name(tset->get_elem_type(), true) + ">";
} else if (ttype->is_list()) {
t_list* tlist = (t_list*) ttype;
return "List<" + type_name(tlist->get_elem_type(), true) + ">";
AX_THRIFT_LIB(csharp, [C#], yes)
if test "$with_csharp" = "yes"; then
- PKG_CHECK_MODULES(MONO, mono >= 1.2.6, have_mono=yes, have_mono=no)
+ PKG_CHECK_MODULES(MONO, mono >= 2.0.0, net_3_5=yes, net_3_5=no)
+ PKG_CHECK_MODULES(MONO, mono >= 1.2.4, have_mono=yes, have_mono=no)
fi
AM_CONDITIONAL(WITH_MONO, [test "$have_mono" = "yes"])
+AM_CONDITIONAL(NET_2_0, [test "$net_3_5" = "no"])
AX_THRIFT_LIB(java, [Java], yes)
if test "$with_java" = "yes"; then
THRIFTCODE= \
+ src/Collections/THashSet.cs \
src/Protocol/TBase.cs \
src/Protocol/TProtocolException.cs \
src/Protocol/TProtocolFactory.cs \
CSC=gmcs
+if NET_2_0
+MONO_DEFINES=/d:NET_2_0
+endif
+
all-local: Thrift.dll
Thrift.dll: $(THRIFTCODE)
- $(CSC) $(THRIFTCODE) /out:Thrift.dll /target:library /langversion:linq
+ $(CSC) $(THRIFTCODE) /out:Thrift.dll /target:library $(MONO_DEFINES)
clean-local:
$(RM) Thrift.dll
--- /dev/null
+/**
+ * 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.Collections;
+using System.Collections.Generic;
+
+namespace Thrift.Collections
+{
+ public class THashSet<T> : ICollection<T>
+ {
+#if NET_2_0
+ TDictSet<T> set = new TDictSet<T>();
+#else
+ HashSet<T> set = new HashSet<T>();
+#endif
+ public int Count
+ {
+ get { return set.Count; }
+ }
+
+ public bool IsReadOnly
+ {
+ get { return set.IsReadOnly; }
+ }
+
+ public void Add(T item)
+ {
+ set.Add(item);
+ }
+
+ public void Clear()
+ {
+ set.Clear();
+ }
+
+ public bool Contains(T item)
+ {
+ return set.Contains(item);
+ }
+
+ public void CopyTo(T[] array, int arrayIndex)
+ {
+ set.CopyTo(array, arrayIndex);
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ return set.GetEnumerator();
+ }
+
+ IEnumerator<T> IEnumerable<T>.GetEnumerator()
+ {
+ return ((IEnumerable<T>)set).GetEnumerator();
+ }
+
+ public bool Remove(T item)
+ {
+ return set.Remove(item);
+ }
+
+#if NET_2_0
+ private class TDictSet<V> : ICollection<V>
+ {
+ Dictionary<V, TDictSet<V>> dict = new Dictionary<V, TDictSet<V>>();
+
+ public int Count
+ {
+ get { return dict.Count; }
+ }
+
+ public bool IsReadOnly
+ {
+ get { return false; }
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ return ((IEnumerable)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;
+ }
+
+ return false;
+ }
+
+ void ICollection<V>.Add(V item)
+ {
+ Add(item);
+ }
+
+ public void Clear()
+ {
+ dict.Clear();
+ }
+
+ public bool Contains(V item)
+ {
+ return dict.ContainsKey(item);
+ }
+
+ public void CopyTo(V[] array, int arrayIndex)
+ {
+ dict.Keys.CopyTo(array, arrayIndex);
+ }
+
+ public bool Remove(V item)
+ {
+ return dict.Remove(item);
+ }
+ }
+#endif
+ }
+
+}
// http://developers.facebook.com/thrift/using
using System;
-using System.Collections.Generic;
using System.Text;
using Thrift.Transport;
{
public struct TField
{
+ private string name;
+ private TType type;
+ private short id;
+
public TField(string name, TType type, short id)
:this()
{
- Name = name;
- Type = type;
- ID = id;
+ this.name = name;
+ this.type = type;
+ this.id = id;
}
public string Name
{
- get;
- set;
+ get { return name; }
+ set { name = value; }
}
public TType Type
{
- get;
- set;
+ get { return type; }
+ set { type = value; }
}
public short ID
{
- get;
- set;
+ get { return id; }
+ set { id = value; }
}
}
}
{
public struct TList
{
+ private TType elementType;
+ private int count;
+
public TList(TType elementType, int count)
:this()
{
- ElementType = elementType;
- Count = count;
+ this.elementType = elementType;
+ this.count = count;
}
public TType ElementType
{
- get;
- set;
+ get { return elementType; }
+ set { elementType = value; }
}
public int Count
{
- get;
- set;
+ get { return count; }
+ set { count = value; }
}
}
}
{
public struct TMap
{
+ private TType keyType;
+ private TType valueType;
+ private int count;
+
public TMap(TType keyType, TType valueType, int count)
:this()
{
- KeyType = keyType;
- ValueType = valueType;
- Count = count;
+ this.keyType = keyType;
+ this.valueType = valueType;
+ this.count = count;
}
public TType KeyType
{
- get;
- set;
+ get { return keyType; }
+ set { keyType = value; }
}
public TType ValueType
{
- get;
- set;
+ get { return valueType; }
+ set { valueType = value; }
}
public int Count
{
- get;
- set;
+ get { return count; }
+ set { count = value; }
}
}
}
{
public struct TMessage
{
+ private string name;
+ private TMessageType type;
+ private int seqID;
+
public TMessage(string name, TMessageType type, int seqid)
:this()
{
- Name = name;
- Type = type;
- SeqID = seqid;
+ this.name = name;
+ this.type = type;
+ this.seqID = seqid;
}
public string Name
{
- get;
- set;
+ get { return name; }
+ set { name = value; }
}
public TMessageType Type
{
- get;
- set;
+ get { return type; }
+ set { type = value; }
}
public int SeqID
{
- get;
- set;
+ get { return seqID; }
+ set { seqID = value; }
}
}
}
// http://developers.facebook.com/thrift/using
using System;
-using System.Collections.Generic;
-using System.Text;
namespace Thrift.Protocol
{
// http://developers.facebook.com/thrift/using
using System;
-using System.Collections.Generic;
using System.Text;
using Thrift.Transport;
using System;
-using System.Collections.Generic;
-using System.Text;
namespace Thrift.Protocol
{
// See accompanying file LICENSE or visit the Thrift site at:
// http://developers.facebook.com/thrift/using
using System;
-using System.Collections.Generic;
-using System.Text;
using Thrift.Transport;
namespace Thrift.Protocol
// http://developers.facebook.com/thrift/using
using System;
-using System.Collections.Generic;
-using System.Text;
namespace Thrift.Protocol
{
{
public struct TSet
{
+ private TType elementType;
+ private int count;
+
public TSet(TType elementType, int count)
:this()
{
- ElementType = elementType;
- Count = count;
+ this.elementType = elementType;
+ this.count = count;
}
public TType ElementType
{
- get;
- set;
+ get { return elementType; }
+ set { elementType = value; }
}
public int Count
{
- get;
- set;
+ get { return count; }
+ set { count = value; }
}
}
}
{
public struct TStruct
{
+ private string name;
+
public TStruct(string name)
:this()
{
- Name = name;
+ this.name = name;
}
public string Name
{
- get;
- set;
+ get { return name; }
+ set { name = value; }
}
}
}
// http://developers.facebook.com/thrift/using
using System;
-using System.Collections.Generic;
-using System.Text;
namespace Thrift.Protocol
{
// http://developers.facebook.com/thrift/using
using System;
-using System.Collections.Generic;
using Thrift.Protocol;
using Thrift.Transport;
using System.IO;
// See accompanying file LICENSE or visit the Thrift site at:
// http://developers.facebook.com/thrift/using
using System;
-using System.Collections.Generic;
-using System.Text;
using Thrift.Transport;
using Thrift.Protocol;
// See accompanying file LICENSE or visit the Thrift site at:
// http://developers.facebook.com/thrift/using
using System;
-using System.Collections.Generic;
-using System.Text;
using System.Threading;
using Thrift.Protocol;
using Thrift.Transport;
// http://developers.facebook.com/thrift/using
using System;
using System.Collections.Generic;
-using System.Text;
using System.Threading;
+using Thrift.Collections;
using Thrift.Protocol;
using Thrift.Transport;
private readonly int maxThreads;
private Queue<TTransport> clientQueue;
- private HashSet<Thread> clientThreads;
+ private THashSet<Thread> clientThreads;
private object clientLock;
private Thread workerThread;
this.maxThreads = maxThreads;
clientQueue = new Queue<TTransport>();
clientLock = new object();
- clientThreads = new HashSet<Thread>();
+ clientThreads = new THashSet<Thread>();
}
/// <summary>
// http://developers.facebook.com/thrift/using
using System;
-using System.Collections.Generic;
-using System.Text;
using Thrift.Protocol;
namespace Thrift
// http://developers.facebook.com/thrift/using
using System;
-using System.Collections.Generic;
-using System.Text;
using Thrift.Protocol;
namespace Thrift
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
- <Reference Include="System.Data" />
- <Reference Include="System.Data.DataSetExtensions" />
- <Reference Include="System.Drawing" />
- <Reference Include="System.Windows.Forms" />
- <Reference Include="System.Xml" />
- <Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="Collections\THashSet.cs" />
<Compile Include="Protocol\TBase.cs" />
<Compile Include="Protocol\TBinaryProtocol.cs" />
<Compile Include="Protocol\TField.cs" />
//
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
using System.IO;
namespace Thrift.Transport
// All rights reserved.
using System;
-using System.Collections.Generic;
-using System.Text;
using System.Net.Sockets;
// Copyright (C) 2007 imeem, inc. <http://www.imeem.com>
// All rights reserved.
using System;
-using System.Collections.Generic;
-using System.Text;
namespace Thrift.Transport
{
//
using System;
-using System.Collections.Generic;
-using System.Text;
using System.Net.Sockets;
namespace Thrift.Transport
//
using System;
-using System.Collections.Generic;
-using System.Text;
using System.IO;
namespace Thrift.Transport
//
using System;
-using System.Collections.Generic;
-using System.Text;
namespace Thrift.Transport
{
//
using System;
-using System.Collections.Generic;
-using System.Text;
namespace Thrift.Transport
{
// All rights reserved.
//
using System;
-using System.Collections.Generic;
-using System.Text;
-
namespace Thrift.Transport
{
\feffusing System;\r
using System.Collections.Generic;\r
-using System.Linq;\r
-using System.Text;\r
using Thrift.Server;\r
using Thrift.Transport;\r
\r
// http://developers.facebook.com/thrift/
using System;
-using System.Collections.Generic;
-using System.Text;
using Thrift.Transport;
using Thrift.Protocol;
using Thrift.Test; //generated code
using System;
using System.Collections.Generic;
-using System.Text;
-
+using System.Threading;
+using Thrift.Collections;
using Thrift.Protocol;
using Thrift.Transport;
using Thrift.Test;
-using System.Threading;
namespace Test
{
Console.WriteLine("}");
//set
- HashSet<int> setout = new HashSet<int>();
+ THashSet<int> setout = new THashSet<int>();
for (int j = -2; j < 3; j++)
{
setout.Add(j);
}
Console.Write("})");
- HashSet<int> setin = client.testSet(setout);
+ THashSet<int> setin = client.testSet(setout);
Console.Write(" = {");
first = true;
// http://developers.facebook.com/thrift/
using System;
using System.Collections.Generic;
-using System.Text;
+using Thrift.Collections;
using Thrift.Test; //generated code
-
using Thrift.Transport;
using Thrift.Protocol;
using Thrift.Server;
return thing;
}
- public HashSet<int> testSet(HashSet<int> thing)
+ public THashSet<int> testSet(THashSet<int> thing)
{
Console.WriteLine("testSet({");
bool first = true;
TServer serverEngine;
// Simple Server
- // serverEngine = new TSimpleServer(testProcessor, tServerSocket);
+ serverEngine = new TSimpleServer(testProcessor, tServerSocket);
// ThreadPool Server
- serverEngine = new TThreadPoolServer(testProcessor, tServerSocket);
+ // serverEngine = new TThreadPoolServer(testProcessor, tServerSocket);
+
+ // Threaded Server
+ // serverEngine = new TThreadedServer(testProcessor, tServerSocket);
testHandler.server = serverEngine;
</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="ThriftImpl, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>.\ThriftImpl.dll</HintPath>
cd $(ProjectDir)
-C:\Windows\Microsoft.NET\Framework\v3.5\Csc.exe /t:library /out:.\ThriftImpl.dll /recurse:.\gen-csharp\* /reference:$(ProjectDir)..\..\..\lib\csharp\src\bin\Debug\Thrift.dll</PreBuildEvent>
+$(MSBuildToolsPath)\Csc.exe /t:library /out:.\ThriftImpl.dll /recurse:.\gen-csharp\* /reference:$(ProjectDir)..\..\..\lib\csharp\src\bin\Debug\Thrift.dll</PreBuildEvent>
</PropertyGroup>
</Project>
--- /dev/null
+#!/bin/sh
+../../../compiler/cpp/thrift --gen csharp -o . ../../ThriftTest.thrift
+gmcs /t:library /out:./ThriftImpl.dll /recurse:./gen-csharp/* /reference:../../../lib/csharp/Thrift.dll