Skip to content

Commit

Permalink
Merge pull request #4 from sirkirby/dev
Browse files Browse the repository at this point in the history
.NET Standard 2.0 compatibility
  • Loading branch information
nblumhardt committed Sep 20, 2017
2 parents 27a4446 + a84f8db commit bf40944
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/Destructurama.JsonNet/Destructurama.JsonNet.csproj
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net452;netcoreapp1.1</TargetFrameworks>
<TargetFrameworks>net452;netcoreapp1.1;netstandard2.0</TargetFrameworks>
<RootNamespace>Destructurama</RootNamespace>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\assets\Destructurama.snk</AssemblyOriginatorKeyFile>
Expand All @@ -15,7 +15,7 @@
<Product />
<Company />
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<VersionPrefix>1.1.0</VersionPrefix>
<VersionPrefix>1.2.0</VersionPrefix>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
33 changes: 12 additions & 21 deletions src/Destructurama.JsonNet/JsonNet/JsonNetDestructuringPolicy.cs
Expand Up @@ -20,29 +20,21 @@

namespace Destructurama.JsonNet
{
class JsonNetDestructuringPolicy : IDestructuringPolicy
internal class JsonNetDestructuringPolicy : IDestructuringPolicy
{
public bool TryDestructure(object value, ILogEventPropertyValueFactory propertyValueFactory, out LogEventPropertyValue result)
{
var jo = value as JObject;
if (jo != null)
switch (value)
{
result = Destructure(jo, propertyValueFactory);
return true;
}

var ja = value as JArray;
if (ja != null)
{
result = Destructure(ja, propertyValueFactory);
return true;
}

var jv = value as JValue;
if (jv != null)
{
result = Destructure(jv, propertyValueFactory);
return true;
case JObject jo:
result = Destructure(jo, propertyValueFactory);
return true;
case JArray ja:
result = Destructure(ja, propertyValueFactory);
return true;
case JValue jv:
result = Destructure(jv, propertyValueFactory);
return true;
}

result = null;
Expand All @@ -69,8 +61,7 @@ LogEventPropertyValue Destructure(JObject jo, ILogEventPropertyValueFactory prop
{
if (prop.Name == "$type")
{
var typeVal = prop.Value as JValue;
if (typeVal != null && typeVal.Value is string)
if (prop.Value is JValue typeVal && typeVal.Value is string)
{
typeTag = (string)typeVal.Value;
continue;
Expand Down
Expand Up @@ -5,8 +5,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.4.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="Serilog" Version="2.5.0" />
<PackageReference Include="xunit" Version="2.2.0" />
Expand Down

0 comments on commit bf40944

Please sign in to comment.