Advertisement
Guest User

contract/host

a guest
Dec 11th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.94 KB | None | 0 0
  1. WCFServiceContract
  2. -------------------------------------------------------------------------------------------
  3. IService1 - interfejs
  4. -----------------------------------------------
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Runtime.Serialization;
  9. using System.ServiceModel;
  10. using System.Text;
  11.  
  12. namespace WcfServiceContract
  13. {
  14.     [ServiceContract] public interface IKalkulator  
  15.     {    
  16.     [OperationContract]
  17.     double Dodaj(double n1, double n2);
  18.     [OperationContract]
  19.     double Odejmij(double n1, double n2);
  20.     [OperationContract]
  21.     double Pomnoz(double n1, double n2);
  22.     }
  23. }
  24.  
  25. ------------------------------------------------------------
  26. Service1 - klasa implementująca interfejs
  27. ------------------------------------------------------------
  28. using System;
  29. using System.Collections.Generic;
  30. using System.Linq;
  31. using System.Runtime.Serialization;
  32. using System.ServiceModel;
  33. using System.Text;
  34.  
  35. namespace WcfServiceContract
  36. {
  37.     public class mojKalkulator : IKalkulator  
  38.     { public double Dodaj(double n1, double n2)
  39.         {
  40.             return n1 + n2;
  41.         }
  42.         public double Odejmij(double n1, double n2)
  43.         {
  44.             return n1 - n2;
  45.         }
  46.         public double Pomnoz(double n1, double n2)
  47.         {
  48.             return n1 * n2;
  49.         }
  50.     }
  51. }
  52. ------------------------------------------------------------
  53. WCFServiceHost
  54. ------------------------------------------------------------
  55. using System;
  56. using System.Collections.Generic;
  57. using System.Linq;
  58. using System.Runtime.Serialization;
  59. using System.ServiceModel;
  60. using System.Text;
  61.  
  62. namespace WcfServiceContract
  63. {
  64.     [ServiceContract] public interface IKalkulator  
  65.     {    
  66.     [OperationContract]
  67.     double Dodaj(double n1, double n2);
  68.     [OperationContract]
  69.     double Odejmij(double n1, double n2);
  70.     [OperationContract]
  71.     double Pomnoz(double n1, double n2);
  72.     }
  73.  
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement