Skip to content

Commit 4ad9526

Browse files
authored
Merge pull request #17 from dolphy17/dotnet-core-support
Dotnet core support
2 parents e40ef23 + 04a274d commit 4ad9526

File tree

195 files changed

+450
-226347
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

195 files changed

+450
-226347
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,3 +232,6 @@ _Pvt_Extensions
232232

233233
# FAKE - F# Make
234234
.fake/
235+
236+
# Visual Studio Code hidden folder
237+
.vscode

PingPonger/App.config

Lines changed: 0 additions & 14 deletions
This file was deleted.

PingPonger/PingPonger.csproj

Lines changed: 14 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,15 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4-
<PropertyGroup>
5-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7-
<ProjectGuid>{2A1F9BA1-211F-49BF-8EC5-A1A1C437C7F6}</ProjectGuid>
8-
<OutputType>Exe</OutputType>
9-
<AppDesignerFolder>Properties</AppDesignerFolder>
10-
<RootNamespace>PingPonger</RootNamespace>
11-
<AssemblyName>PingPonger</AssemblyName>
12-
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13-
<FileAlignment>512</FileAlignment>
14-
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
15-
<TargetFrameworkProfile />
16-
</PropertyGroup>
17-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
18-
<PlatformTarget>AnyCPU</PlatformTarget>
19-
<DebugSymbols>true</DebugSymbols>
20-
<DebugType>full</DebugType>
21-
<Optimize>false</Optimize>
22-
<OutputPath>bin\Debug\</OutputPath>
23-
<DefineConstants>DEBUG;TRACE</DefineConstants>
24-
<ErrorReport>prompt</ErrorReport>
25-
<WarningLevel>4</WarningLevel>
26-
</PropertyGroup>
27-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
28-
<PlatformTarget>AnyCPU</PlatformTarget>
29-
<DebugType>pdbonly</DebugType>
30-
<Optimize>true</Optimize>
31-
<OutputPath>bin\Release\</OutputPath>
32-
<DefineConstants>TRACE</DefineConstants>
33-
<ErrorReport>prompt</ErrorReport>
34-
<WarningLevel>4</WarningLevel>
35-
</PropertyGroup>
36-
<ItemGroup>
37-
<Reference Include="CommandLine, Version=1.9.71.2, Culture=neutral, PublicKeyToken=de6f01bd326f8c32, processorArchitecture=MSIL">
38-
<HintPath>..\packages\CommandLineParser.1.9.71\lib\net45\CommandLine.dll</HintPath>
39-
<Private>True</Private>
40-
</Reference>
41-
<Reference Include="Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
42-
<HintPath>..\packages\Serilog.2.3.0\lib\net45\Serilog.dll</HintPath>
43-
<Private>True</Private>
44-
</Reference>
45-
<Reference Include="Serilog.Sinks.ColoredConsole, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
46-
<HintPath>..\packages\Serilog.Sinks.ColoredConsole.2.0.0\lib\net45\Serilog.Sinks.ColoredConsole.dll</HintPath>
47-
<Private>True</Private>
48-
</Reference>
49-
<Reference Include="System" />
50-
<Reference Include="System.Core" />
51-
<Reference Include="System.Xml.Linq" />
52-
<Reference Include="System.Data.DataSetExtensions" />
53-
<Reference Include="Microsoft.CSharp" />
54-
<Reference Include="System.Data" />
55-
<Reference Include="System.Net.Http" />
56-
<Reference Include="System.Xml" />
57-
</ItemGroup>
58-
<ItemGroup>
59-
<Compile Include="Program.cs" />
60-
<Compile Include="Properties\AssemblyInfo.cs" />
61-
</ItemGroup>
62-
<ItemGroup>
63-
<None Include="App.config" />
64-
<None Include="packages.config" />
65-
</ItemGroup>
66-
<ItemGroup>
67-
<ProjectReference Include="..\Serilog.Sinks.Network\Serilog.Sinks.Network.csproj">
68-
<Project>{0c62d696-fa1b-4567-bb5b-fa42f9fa1bcf}</Project>
69-
<Name>Serilog.Sinks.Network</Name>
70-
</ProjectReference>
71-
</ItemGroup>
72-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
73-
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
74-
Other similar extension points exist, see Microsoft.Common.targets.
75-
<Target Name="BeforeBuild">
76-
</Target>
77-
<Target Name="AfterBuild">
78-
</Target>
79-
-->
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<Project Sdk="Microsoft.NET.Sdk">
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp1.1</TargetFramework>
6+
</PropertyGroup>
7+
<ItemGroup>
8+
<PackageReference Include="Serilog" Version="2.5.0"/>
9+
<PackageReference Include="Serilog.Sinks.ColoredConsole" Version="3.0.1"/>
10+
<PackageReference Include="CommandLineParser" Version="2.1.1-beta"/>
11+
</ItemGroup>
12+
<ItemGroup>
13+
<ProjectReference Include="..\Serilog.Sinks.Network\Serilog.Sinks.Network.csproj"/>
14+
</ItemGroup>
8015
</Project>

PingPonger/Program.cs

Lines changed: 100 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -9,113 +9,113 @@
99

1010
namespace PingPonger
1111
{
12-
internal class Options
13-
{
14-
[Option('u', "udp", Required = false,
15-
HelpText = "Ping Pong over UDP")]
16-
public bool UDP { get; set; }
17-
18-
[Option('t', "tcp", Required = false,
19-
HelpText = "Ping Pong over TCP")]
20-
public bool TCP { get; set; }
21-
22-
[Option('i', "ip", Required = false,
23-
HelpText = "IP to send to")]
24-
public string IP { get; set; }
25-
26-
[Option('l', "url", Required = false,
27-
HelpText = "URL to send to")]
28-
public string Url { get; set; }
29-
30-
[Option('p', "port", Required = false,
31-
HelpText = "the Port to send to")]
32-
public int Port { get; set; }
33-
}
34-
35-
public class Program
36-
{
37-
public static int Main(string[] args)
12+
internal class Options
3813
{
39-
try
40-
{
41-
var options = new Options();
42-
if (!Parser.Default.ParseArgumentsStrict(args, options))
43-
{
44-
Console.WriteLine(@"Failed parsing command line arguments");
45-
args.ToList().ForEach(a => Console.WriteLine(@"arg: {0}", a));
46-
return 1;
47-
}
48-
49-
if ((!options.UDP && !options.TCP) || (options.TCP && options.UDP))
50-
{
51-
Console.WriteLine("You must select either TCP or UDP");
52-
return 1;
53-
}
54-
55-
var logConfig = new LoggerConfiguration();
56-
57-
logConfig.Enrich.WithProperty("application", "woodlandtrust_website");
58-
logConfig.Enrich.WithProperty("type", "SiteMapGenerator");
59-
logConfig.Enrich.WithProperty("environment", "production");
60-
61-
logConfig.WriteTo.ColoredConsole();
14+
[Option('u', "udp", Required = false,
15+
HelpText = "Ping Pong over UDP")]
16+
public bool UDP { get; set; }
6217

63-
if (options.Url.Length > 0)
64-
{
65-
if (options.UDP)
66-
{
67-
logConfig.WriteTo.UDPSink(options.Url, options.Port, new LogstashJsonFormatter());
68-
}
69-
if (options.TCP)
70-
{
71-
logConfig.WriteTo.TCPSink(options.Url, options.Port, new LogstashJsonFormatter());
72-
}
73-
}
74-
else if (options.IP.Length > 0)
75-
{
76-
IPAddress ipAddress;
77-
if (!IPAddress.TryParse(options.IP, out ipAddress))
78-
{
79-
Console.WriteLine("Could not parse " + options.IP + " as an IP address");
80-
return 1;
81-
}
82-
83-
if (options.UDP)
84-
{
85-
logConfig.WriteTo.UDPSink(ipAddress, options.Port, new LogstashJsonFormatter());
86-
}
87-
if (options.TCP)
88-
{
89-
logConfig.WriteTo.TCPSink(ipAddress, options.Port, new LogstashJsonFormatter());
90-
}
91-
}
92-
else
93-
{
94-
Console.WriteLine("You must provide a URL or IP to connect to");
95-
return 1;
96-
}
18+
[Option('t', "tcp", Required = false,
19+
HelpText = "Ping Pong over TCP")]
20+
public bool TCP { get; set; }
9721

22+
[Option('i', "ip", Required = false,
23+
HelpText = "IP to send to")]
24+
public string IP { get; set; }
9825

99-
var logger = logConfig.CreateLogger();
26+
[Option('l', "url", Required = false,
27+
HelpText = "URL to send to")]
28+
public string Url { get; set; }
10029

101-
var cancelled = false;
102-
Console.CancelKeyPress += delegate { cancelled = true; };
30+
[Option('p', "port", Required = false,
31+
HelpText = "the Port to send to")]
32+
public int Port { get; set; }
33+
}
10334

104-
var i = 0;
105-
while (!cancelled)
35+
public class Program
36+
{
37+
public static int Main(string[] args)
10638
{
107-
logger.Information("ping: {ping} and pong: {pong}", i++, i++);
108-
Thread.Sleep(1500);
39+
try
40+
{
41+
var options = new Options();
42+
if (Parser.Default.ParseArguments<Options>(args).Tag == ParserResultType.NotParsed)
43+
{
44+
Console.WriteLine(@"Failed parsing command line arguments");
45+
args.ToList().ForEach(a => Console.WriteLine(@"arg: {0}", a));
46+
return 1;
47+
}
48+
49+
if ((!options.UDP && !options.TCP) || (options.TCP && options.UDP))
50+
{
51+
Console.WriteLine("You must select either TCP or UDP");
52+
return 1;
53+
}
54+
55+
var logConfig = new LoggerConfiguration();
56+
57+
logConfig.Enrich.WithProperty("application", "woodlandtrust_website");
58+
logConfig.Enrich.WithProperty("type", "SiteMapGenerator");
59+
logConfig.Enrich.WithProperty("environment", "production");
60+
61+
logConfig.WriteTo.ColoredConsole();
62+
63+
if (options.Url.Length > 0)
64+
{
65+
if (options.UDP)
66+
{
67+
logConfig.WriteTo.UDPSink(options.Url, options.Port, new LogstashJsonFormatter());
68+
}
69+
if (options.TCP)
70+
{
71+
logConfig.WriteTo.TCPSink(options.Url, options.Port, new LogstashJsonFormatter());
72+
}
73+
}
74+
else if (options.IP.Length > 0)
75+
{
76+
IPAddress ipAddress;
77+
if (!IPAddress.TryParse(options.IP, out ipAddress))
78+
{
79+
Console.WriteLine("Could not parse " + options.IP + " as an IP address");
80+
return 1;
81+
}
82+
83+
if (options.UDP)
84+
{
85+
logConfig.WriteTo.UDPSink(ipAddress, options.Port, new LogstashJsonFormatter());
86+
}
87+
if (options.TCP)
88+
{
89+
logConfig.WriteTo.TCPSink(ipAddress, options.Port, new LogstashJsonFormatter());
90+
}
91+
}
92+
else
93+
{
94+
Console.WriteLine("You must provide a URL or IP to connect to");
95+
return 1;
96+
}
97+
98+
99+
var logger = logConfig.CreateLogger();
100+
101+
var cancelled = false;
102+
Console.CancelKeyPress += delegate { cancelled = true; };
103+
104+
var i = 0;
105+
while (!cancelled)
106+
{
107+
logger.Information("ping: {ping} and pong: {pong}", i++, i++);
108+
Thread.Sleep(1500);
109+
}
110+
}
111+
catch (Exception ex)
112+
{
113+
Console.WriteLine("ping ponging failed");
114+
Console.WriteLine(ex);
115+
return 1;
116+
}
117+
118+
return 0;
109119
}
110-
}
111-
catch (Exception ex)
112-
{
113-
Console.WriteLine("ping ponging failed");
114-
Console.WriteLine(ex);
115-
return 1;
116-
}
117-
118-
return 0;
119120
}
120-
}
121121
}

PingPonger/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 36 deletions
This file was deleted.

PingPonger/packages.config

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)