class1.cs

来自「应用框架的设计与实现的源代码(SAF) 《应用框架的设计与实现》随书源码」· CS 代码 · 共 48 行

CS
48
字号
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels.Http;
using System.Runtime.Remoting.Channels;
using SAF.EventNotification;
using SAF.Configuration;
using System.Configuration;
using System.Collections;
using System.Runtime.Serialization.Formatters;

namespace TestConsole
{
	/// <summary>
	/// This console application show how to install EventNotification service on the event server.
	/// </summary>
	class Class1
	{
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main(string[] args)
		{

			ConfigurationManager cm = (ConfigurationManager)ConfigurationSettings.GetConfig("Framework");
			EventNotificationConfiguration enc = cm.EventNotificationConfig;
			//set up the network channel for accepting calls from event clients and making calls
			//to the event clients.
			IDictionary props = new Hashtable();
			props["port"] = Int32.Parse(enc.GetPortNumber());

			BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider();
			provider.TypeFilterLevel = TypeFilterLevel.Full;
			HttpChannel channel = new HttpChannel(props,null,provider);

			ChannelServices.RegisterChannel(channel);
			//register the remote object type.
			WellKnownServiceTypeEntry wste= new WellKnownServiceTypeEntry(typeof(EventServer),enc.GetObjectUri(),WellKnownObjectMode.Singleton);
			RemotingConfiguration.ApplicationName = enc.GetApplicationName();
			RemotingConfiguration.RegisterWellKnownServiceType(wste);
			Console.WriteLine("Press Enter to exit");
			Console.ReadLine();


		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?