using System;
using System.Collections;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Runtime.Serialization.Formatters;

namespace QC.QSPRAutomation.Internal;

public class Channel
{
	public static void Register(int port)
	{
		BinaryClientFormatterSinkProvider clientSinkProvider = null;
		BinaryServerFormatterSinkProvider binaryServerFormatterSinkProvider = new BinaryServerFormatterSinkProvider();
		binaryServerFormatterSinkProvider.TypeFilterLevel = TypeFilterLevel.Full;
		IDictionary dictionary = new Hashtable();
		dictionary["port"] = port.ToString();
		dictionary["typeFilterLevel"] = TypeFilterLevel.Full;
		dictionary["name"] = Guid.NewGuid().ToString();
		TcpChannel chnl = new TcpChannel(dictionary, clientSinkProvider, binaryServerFormatterSinkProvider);
		ChannelServices.RegisterChannel(chnl, ensureSecurity: false);
		dictionary.Clear();
		dictionary = null;
	}
}
