I have a WCF service that provides a common interface (and the service has a common class that implements this interface).
Then I try to host this service in a managed console application (for testing purposes only right now). String ThreadStart leads to the fact that the type of the expression type T is not found.
Now I cannot make Main generic by doing Main <T> (string [] args), where T: IComparable <T>, because then it says that the main entry point was not found.
My question is how to handle this case as a whole?
static void Main(string[] args)
{
new Thread(new ThreadStart(StartBSTService<T>)).Start();
}
static void StartBSTService<T>() where T : IComparable<T>
{
string baseAddress = "http://localhost:8080/bst";
StartAService(typeof(BSTService<T>), baseAddress);
}
EDIT: Adding a Service Class
[ServiceContract(Namespace = "http://Microsoft.Samples.GettingStarted")]
public interface IBSTService<T> where T : IComparable<T>
{
[OperationContract]
void Add(T toAdd);
}
public class BSTService<T> : IBSTService<T> where T : IComparable<T>
{
BinarySearchTree<T> tree = new BinarySearchTree<T>();
public void Add(T toAdd)
{
tree.Add(toAdd);
}
}
The client will use it as if you were using some common type:
BSTService<string> client = new BSTService<string>;
BSTService<int> client = new BSTService<int>;
EDIT2:
@asawyer point , Main , , ? . , , : INIT (Type typeOfBST). , , int, BST. , , BST.
?