Skip to content

Commit 45250eb

Browse files
author
Jacques Kang
committed
initial commit
1 parent 68a1507 commit 45250eb

File tree

15 files changed

+266
-0
lines changed

15 files changed

+266
-0
lines changed

src/IpcServiceFramework.sln

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.27004.2002
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JKang.IpcServiceFramework", "JKang.IpcServiceFramework\JKang.IpcServiceFramework.csproj", "{83931898-A23F-4D45-8F3F-D63481352862}"
7+
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{03210BFB-17B1-4775-A8A2-D302ECBF2F46}"
9+
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IpcServiceSample.ServiceContracts", "IpcServiceSample.ServiceContracts\IpcServiceSample.ServiceContracts.csproj", "{D1ADB92C-B4FB-40DD-911E-46360A23381B}"
11+
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IpcServiceSample.ConsoleServer", "IpcServiceSample.ConsoleServer\IpcServiceSample.ConsoleServer.csproj", "{24A3C4D2-95A2-48D9-86F2-648879EC74F4}"
13+
EndProject
14+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IpcServiceSample.ConsoleClient", "IpcServiceSample.ConsoleClient\IpcServiceSample.ConsoleClient.csproj", "{8D54E62A-ECFF-4FFF-B9D1-DB343D456451}"
15+
EndProject
16+
Global
17+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
18+
Debug|Any CPU = Debug|Any CPU
19+
Release|Any CPU = Release|Any CPU
20+
EndGlobalSection
21+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
22+
{83931898-A23F-4D45-8F3F-D63481352862}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23+
{83931898-A23F-4D45-8F3F-D63481352862}.Debug|Any CPU.Build.0 = Debug|Any CPU
24+
{83931898-A23F-4D45-8F3F-D63481352862}.Release|Any CPU.ActiveCfg = Release|Any CPU
25+
{83931898-A23F-4D45-8F3F-D63481352862}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{D1ADB92C-B4FB-40DD-911E-46360A23381B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{D1ADB92C-B4FB-40DD-911E-46360A23381B}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{D1ADB92C-B4FB-40DD-911E-46360A23381B}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{D1ADB92C-B4FB-40DD-911E-46360A23381B}.Release|Any CPU.Build.0 = Release|Any CPU
30+
{24A3C4D2-95A2-48D9-86F2-648879EC74F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31+
{24A3C4D2-95A2-48D9-86F2-648879EC74F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
32+
{24A3C4D2-95A2-48D9-86F2-648879EC74F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
33+
{24A3C4D2-95A2-48D9-86F2-648879EC74F4}.Release|Any CPU.Build.0 = Release|Any CPU
34+
{8D54E62A-ECFF-4FFF-B9D1-DB343D456451}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35+
{8D54E62A-ECFF-4FFF-B9D1-DB343D456451}.Debug|Any CPU.Build.0 = Debug|Any CPU
36+
{8D54E62A-ECFF-4FFF-B9D1-DB343D456451}.Release|Any CPU.ActiveCfg = Release|Any CPU
37+
{8D54E62A-ECFF-4FFF-B9D1-DB343D456451}.Release|Any CPU.Build.0 = Release|Any CPU
38+
EndGlobalSection
39+
GlobalSection(SolutionProperties) = preSolution
40+
HideSolutionNode = FALSE
41+
EndGlobalSection
42+
GlobalSection(NestedProjects) = preSolution
43+
{D1ADB92C-B4FB-40DD-911E-46360A23381B} = {03210BFB-17B1-4775-A8A2-D302ECBF2F46}
44+
{24A3C4D2-95A2-48D9-86F2-648879EC74F4} = {03210BFB-17B1-4775-A8A2-D302ECBF2F46}
45+
{8D54E62A-ECFF-4FFF-B9D1-DB343D456451} = {03210BFB-17B1-4775-A8A2-D302ECBF2F46}
46+
EndGlobalSection
47+
GlobalSection(ExtensibilityGlobals) = postSolution
48+
SolutionGuid = {F87E0D46-F461-4E41-9A3B-64710A6DFB2F}
49+
EndGlobalSection
50+
EndGlobal
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp2.0</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<ProjectReference Include="..\IpcServiceSample.ServiceContracts\IpcServiceSample.ServiceContracts.csproj" />
10+
<ProjectReference Include="..\JKang.IpcServiceFramework\JKang.IpcServiceFramework.csproj" />
11+
</ItemGroup>
12+
13+
</Project>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using JKang.IpcServiceFramework;
2+
using System;
3+
using System.Threading.Tasks;
4+
5+
namespace IpcServiceSample.ConsoleClient
6+
{
7+
class MyClient : IpcServiceClient<IMyIpcService>, IMyIpcService
8+
{
9+
public MyClient(string pipeName)
10+
: base(pipeName)
11+
{
12+
}
13+
14+
public Task<MyResponse> GetDataAsync(MyRequest request, bool iAmHandsome)
15+
{
16+
throw new NotImplementedException();
17+
}
18+
}
19+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
using System.Threading.Tasks;
3+
4+
namespace IpcServiceSample.ConsoleClient
5+
{
6+
class Program
7+
{
8+
static void Main(string[] args)
9+
{
10+
MainAsync().Wait();
11+
}
12+
13+
private static async Task MainAsync()
14+
{
15+
var client = new MyClient("testpipe");
16+
var request = new MyRequest
17+
{
18+
Message = "Hello"
19+
};
20+
21+
Console.WriteLine("Invoking IpcService...");
22+
MyResponse response = await client.GetDataAsync(request, true);
23+
24+
Console.WriteLine($"Received response: {response.Message}");
25+
}
26+
}
27+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp2.0</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<ProjectReference Include="..\IpcServiceSample.ServiceContracts\IpcServiceSample.ServiceContracts.csproj" />
10+
<ProjectReference Include="..\JKang.IpcServiceFramework\JKang.IpcServiceFramework.csproj" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.0.0" />
15+
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.0.0" />
16+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.0" />
17+
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.0.0" />
18+
</ItemGroup>
19+
20+
</Project>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Microsoft.Extensions.Logging;
2+
using System.Threading.Tasks;
3+
4+
namespace IpcServiceSample.ConsoleServer
5+
{
6+
public class MyIpcService : IMyIpcService
7+
{
8+
private readonly ILogger<MyIpcService> _logger;
9+
10+
public MyIpcService(ILogger<MyIpcService> logger)
11+
{
12+
_logger = logger;
13+
}
14+
15+
public Task<MyResponse> GetDataAsync(MyRequest request, bool iAmHandsome)
16+
{
17+
_logger.LogInformation($"{nameof(GetDataAsync)} called.");
18+
19+
var response = new MyResponse
20+
{
21+
Message = $"What you said '{request.Message}' is {(iAmHandsome ? "correct." : "wrong")}"
22+
};
23+
return Task.FromResult(response);
24+
}
25+
}
26+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using JKang.IpcServiceFramework;
2+
using Microsoft.Extensions.Configuration;
3+
using Microsoft.Extensions.DependencyInjection;
4+
using Microsoft.Extensions.Logging;
5+
using System;
6+
7+
namespace IpcServiceSample.ConsoleServer
8+
{
9+
class Program
10+
{
11+
public static IConfigurationRoot Configuration { get; private set; }
12+
13+
static void Main(string[] args)
14+
{
15+
// build configuration
16+
IConfigurationBuilder builder = new ConfigurationBuilder();
17+
Configuration = builder.Build();
18+
19+
// build service provider
20+
IServiceCollection services = ConfigureServices(new ServiceCollection());
21+
ServiceProvider serviceProvider = services.BuildServiceProvider();
22+
23+
// configure console logging
24+
serviceProvider.GetRequiredService<ILoggerFactory>()
25+
.AddConsole(LogLevel.Debug);
26+
27+
// TODO start IPC service host
28+
IpcServiceHost
29+
.Buid(serviceProvider as IServiceProvider)
30+
.Start();
31+
32+
}
33+
34+
private static IServiceCollection ConfigureServices(IServiceCollection services)
35+
{
36+
return services
37+
.AddLogging()
38+
.AddScoped<IMyIpcService, MyIpcService>()
39+
;
40+
}
41+
}
42+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using System.Threading.Tasks;
2+
3+
namespace IpcServiceSample
4+
{
5+
public interface IMyIpcService
6+
{
7+
Task<MyResponse> GetDataAsync(MyRequest request, bool iAmHandsome);
8+
}
9+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
<RootNamespace>IpcServiceSample</RootNamespace>
6+
</PropertyGroup>
7+
8+
</Project>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace IpcServiceSample
2+
{
3+
public class MyRequest
4+
{
5+
public string Message { get; set; }
6+
}
7+
}

0 commit comments

Comments
 (0)