Prechádzať zdrojové kódy

commit: patch external

码农 6 rokov pred
rodič
commit
59121677ea

+ 4 - 1
DataExchange.Tests/App.cs

@@ -7,16 +7,19 @@ namespace DataExchange.Tests
     public class App
     {
         private const string InterfaceName = "BrApi0";
+        private static readonly ExternalDataExchangeApi DxApi;
 
         static App()
         {
             if (Script.Undefined == (Window.Get(InterfaceName)))
                 Window.Set(InterfaceName, new DummyDataExchangeApi());
+
+            DxApi = Window.Get<ExternalDataExchangeApi>(InterfaceName);
         }
 
         public static void Main()
         {
-            var dxs = new DataExchangeService(Window.Get<IDataExchangeApi>(InterfaceName));
+            var dxs = new DataExchangeService(DxApi);
 
             var svc = dxs.Create<IInterface1>("Svc1Name");
             svc.Op0(DateTime.Now);

+ 1 - 0
DataExchange/DataExchange.csproj

@@ -37,6 +37,7 @@
   </PropertyGroup>
   <ItemGroup>
     <Compile Include="DataExchangeService.cs" />
+    <Compile Include="ExternalDataExchangeApi.cs" />
     <Compile Include="IDataExchangeApi.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
   </ItemGroup>

+ 2 - 2
DataExchange/DataExchangeService.cs

@@ -7,9 +7,9 @@ namespace DataExchange
 {
     public class DataExchangeService
     {
-        private readonly IDataExchangeApi _dataExchangeApi;
+        private readonly ExternalDataExchangeApi _dataExchangeApi;
 
-        public DataExchangeService(IDataExchangeApi dataExchangeApi)
+        public DataExchangeService(ExternalDataExchangeApi dataExchangeApi)
         {
             _dataExchangeApi = dataExchangeApi;
         }

+ 10 - 0
DataExchange/ExternalDataExchangeApi.cs

@@ -0,0 +1,10 @@
+using Bridge;
+
+namespace DataExchange
+{
+    public class ExternalDataExchangeApi : IDataExchangeApi
+    {
+        [External]
+        public extern string InvokeService(string serviceName, string actionName, string inputJson);
+    }
+}