Public feed
#727233
public OGS1InventoryService(string serverName, int serverPort, IUserServices userServices)
{
_userServices = userServices;
// we only need to register the tcp channel once, and we don't know which other modules use remoting
if (ChannelServices.GetChannel("tcp") == null)
{
// Creating a custom formatter for a TcpChannel sink chain.
BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider();
serverProvider.TypeFilterLevel = TypeFilterLevel.Full;
BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider();
IDictionary props = new Hashtable();
props["typeFilterLevel"] = TypeFilterLevel.Full;
// Pass the properties for the port setting and the server provider in the server chain argument. (Client remains null here.)
TcpChannel chan = new TcpChannel(props, clientProvider, serverProvider);
ChannelServices.RegisterChannel(chan, true);
}
string remotingUrl = string.Format("tcp://{0}:{1}/Inventory", serverName, serverPort);
_inventoryServices = (IInventoryServices)Activator.GetObject(typeof(IInventoryServices), remotingUrl);
}
class InventoryService
{
InventoryServiceSingleton _inventoryServiceMethods;
public InventoryService(InventoryManager inventoryManager, InventoryConfig cfg)
{
// we only need to register the tcp channel once, and we don't know which other modules use remoting
if (ChannelServices.GetChannel("tcp") == null)
{
// Creating a custom formatter for a TcpChannel sink chain.
BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider();
serverProvider.TypeFilterLevel = TypeFilterLevel.Full;
IDictionary props = new Hashtable();
props["port"] = cfg.RemotingPort;
props["typeFilterLevel"] = TypeFilterLevel.Full;
// Pass the properties for the port setting and the server provider in the server chain argument. (Client remains null here.)
ChannelServices.RegisterChannel(new TcpChannel(props, null, serverProvider), true);
}
// Register the object
RemotingConfiguration.RegisterWellKnownServiceType(typeof(InventoryServiceSingleton), "Inventory", WellKnownObjectMode.Singleton);
_inventoryServiceMethods = InventoryServiceSingleton.Instance;
InventoryServiceSingleton.InventoryManager = inventoryManager;
}
}