📄 ex-19-07
字号:
// Example 19-07: Replacement of Main() from Example 19-4 (the client)
public static void Main()
{
int[] myIntArray = new int[3];
Console.WriteLine("Watson, come here I need you...");
// create an Http channel and register it
// uses port 0 to indicate you won't be listening
HttpChannel chan = new HttpChannel(0);
ChannelServices.RegisterChannel(chan);
FileStream fileStream =
new FileStream ("calculatorSoap.txt", FileMode.Open);
SoapFormatter soapFormatter =
new SoapFormatter ();
try
{
ObjRef objRef =
(ObjRef) soapFormatter.Deserialize (fileStream);
ICalc calc =
(ICalc) RemotingServices.Unmarshal(objRef);
// use the interface to call methods
double sum = calc.Add(3.0,4.0);
double difference = calc.Sub(3,4);
double product = calc.Mult(3,4);
double quotient = calc.Div(3,4);
// print the results
Console.WriteLine("3+4 = {0}", sum);
Console.WriteLine("3-4 = {0}", difference);
Console.WriteLine("3*4 = {0}", product);
Console.WriteLine("3/4 = {0}", quotient);
}
catch( System.Exception ex )
{
Console.WriteLine("Exception caught: ");
Console.WriteLine(ex.Message);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -