Skip to content

Commit 0c4aea4

Browse files
committed
A minimal NetCore test project added
1 parent d8cff7d commit 0c4aea4

File tree

3 files changed

+81
-3
lines changed

3 files changed

+81
-3
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp2.1</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="BasicConsoleUtilities" Version="1.0.0.6" />
10+
</ItemGroup>
11+
12+
<ItemGroup>
13+
<ProjectReference Include="..\WindowsFirewallHelper\WindowsFirewallHelper.csproj" />
14+
</ItemGroup>
15+
16+
</Project>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using System;
2+
using System.Linq;
3+
using WindowsFirewallHelper;
4+
using ConsoleUtilities;
5+
6+
namespace ConWindowsFirewallHelper.NetCoreSample
7+
{
8+
internal class Program
9+
{
10+
private static void Main()
11+
{
12+
var firewallInstance = FirewallManager.Instance;
13+
14+
ConsoleWriter.Default.PrintMessage($"Firewall Version: {FirewallManager.Version}");
15+
ConsoleWriter.Default.PrintMessage($"Firewall Name: {firewallInstance?.Name ?? "[NULL]"}");
16+
ConsoleWriter.Default.PrintMessage(
17+
$"Firewall Status: {(firewallInstance?.IsSupported == true ? "Supported" : "NotSupported")}"
18+
);
19+
20+
if (firewallInstance?.IsSupported != true)
21+
{
22+
ConsoleWriter.Default.PrintMessage("Press any key to exit.");
23+
Console.ReadKey();
24+
25+
return;
26+
}
27+
28+
ConsoleWriter.Default.PrintCaption(firewallInstance.Name);
29+
30+
ConsoleNavigation.Default.PrintNavigation(new[]
31+
{
32+
new ConsoleNavigationItem("Profiles", (i, item) =>
33+
{
34+
ConsoleNavigation.Default.PrintNavigation(firewallInstance.Profiles, (i1, profile) =>
35+
{
36+
ConsoleWriter.Default.WriteObject(profile);
37+
ConsoleWriter.Default.PrintMessage("Press any key to get one step back.");
38+
Console.ReadKey();
39+
}, "Select a profile to view its settings.");
40+
}),
41+
new ConsoleNavigationItem("Rules", (i, item) =>
42+
{
43+
ConsoleNavigation.Default.PrintNavigation(firewallInstance.Rules.ToArray(), (i1, rule) =>
44+
{
45+
ConsoleWriter.Default.WriteObject(rule);
46+
ConsoleWriter.Default.PrintMessage("Press any key to get one step back.");
47+
Console.ReadKey();
48+
}, "Select a rule to view its settings.");
49+
})
50+
}, "Select an execution path.");
51+
}
52+
}
53+
}

WindowsFirewallHelper.sln

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
Microsoft Visual Studio Solution File, Format Version 12.00
2-
# Visual Studio 14
3-
VisualStudioVersion = 14.0.25420.1
2+
# Visual Studio 15
3+
VisualStudioVersion = 15.0.28307.168
44
MinimumVisualStudioVersion = 10.0.40219.1
5-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsFirewallHelper", "WindowsFirewallHelper\WindowsFirewallHelper.csproj", "{5D71AD0C-A697-4CB1-B7A4-8395BA7D6D4C}"
5+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WindowsFirewallHelper", "WindowsFirewallHelper\WindowsFirewallHelper.csproj", "{5D71AD0C-A697-4CB1-B7A4-8395BA7D6D4C}"
66
EndProject
77
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsFirewallHelper.Sample", "WindowsFirewallHelper.Sample\WindowsFirewallHelper.Sample.csproj", "{A16AB986-7576-4BC5-ACBF-7728A55A6E13}"
88
EndProject
9+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConWindowsFirewallHelper.NetCoreSample", "ConWindowsFirewallHelper.NetCoreSample\ConWindowsFirewallHelper.NetCoreSample.csproj", "{8B2C0C23-8B5E-4760-A08F-263A055A8DE9}"
10+
EndProject
911
Global
1012
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1113
Debug|Any CPU = Debug|Any CPU
@@ -20,8 +22,15 @@ Global
2022
{A16AB986-7576-4BC5-ACBF-7728A55A6E13}.Debug|Any CPU.Build.0 = Debug|Any CPU
2123
{A16AB986-7576-4BC5-ACBF-7728A55A6E13}.Release|Any CPU.ActiveCfg = Release|Any CPU
2224
{A16AB986-7576-4BC5-ACBF-7728A55A6E13}.Release|Any CPU.Build.0 = Release|Any CPU
25+
{8B2C0C23-8B5E-4760-A08F-263A055A8DE9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26+
{8B2C0C23-8B5E-4760-A08F-263A055A8DE9}.Debug|Any CPU.Build.0 = Debug|Any CPU
27+
{8B2C0C23-8B5E-4760-A08F-263A055A8DE9}.Release|Any CPU.ActiveCfg = Release|Any CPU
28+
{8B2C0C23-8B5E-4760-A08F-263A055A8DE9}.Release|Any CPU.Build.0 = Release|Any CPU
2329
EndGlobalSection
2430
GlobalSection(SolutionProperties) = preSolution
2531
HideSolutionNode = FALSE
2632
EndGlobalSection
33+
GlobalSection(ExtensibilityGlobals) = postSolution
34+
SolutionGuid = {0C39D722-F354-443C-8C16-8FB8FA156042}
35+
EndGlobalSection
2736
EndGlobal

0 commit comments

Comments
 (0)