Cycle de progression Faire (quelque chose qui marche) -> comprendre ce que l’on fait/comment cela marche -> pousser plus loin les notions
| using System; using System.Collections.Generic; using System.Text; namespace NET2CsRemotingAppConf.Serv { ///<summary> /// 1 - Objet MBR (objet distant) ///</summary> public class Surface : System.MarshalByRefObject { public Surface() { } public Single CalculateSquareSurface(Single Rayon) { Console.WriteLine("Execution CalculateSquareSurface"); Single Result; Result = (Single)(Rayon * Rayon); return Result; } } } |
| using System; using System.Collections.Generic; using System.Text; namespace NET2CsRemotingAppConf.Serv { class Program { static void Main(string[] args) { System.Runtime.Remoting.RemotingConfiguration.Configure("NET2CsRemotingAppConf.Serv.exe.config", false); // Fin du service Console.WriteLine("Appuyer sur une touche pour stopper le serveur"); Console.ReadLine(); } } } |
| <?xmlversion="1.0"encoding="utf-8" ?> <configuration> <system.runtime.remoting> <applcation> <service> <wellknown type="NET2CsRemotingAppConf.Serv.Surface,NET2CsRemotingAppConf.Serv" mode="Singleton" objectUri="RemoteSurface"/> </service> <channels> <channel port="60001" ref="tcp" /> </channels> </applcation> </system.runtime.remoting> </configuration> |
| using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace NET2CsRemotingAppConf.Cli { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { this.CallCalcultateSquareSurface(); } // Methods public void CallCalcultateSquareSurface() { NET2CsRemotingAppConf.Serv.Surface oSurface; Single Result; try { System.Runtime.Remoting.RemotingConfiguration.Configure("NET2CsRemotingAppConf.Cli.exe.config", false); oSurface = new NET2CsRemotingAppConf.Serv.Surface(); // 2 Dialogue - apppel de méthodes Result = oSurface.CalculateSquareSurface(Convert.ToSingle(textBox1.Text)); // Affichage du résultat formaté lblResult.Text = Result.ToString(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } } } } |
| <?xmlversion="1.0"encoding="utf-8" ?> <configuration> <system.runtime.remoting> <applcation> <service> <wellknown type="NET2CsRemotingAppConf.Serv.Surface,NET2CsRemotingAppConf.Serv" url="tcp://localhost:60001/RemoteSurface"/> </service> </applcation> </system.runtime.remoting> </configuration> |