Skip to content

Commit 616f4c5

Browse files
committed
Hotfix #81 - added JSON formatting to complex argument and return value types
1 parent c9e9178 commit 616f4c5

5 files changed

Lines changed: 21 additions & 3 deletions

File tree

src/Patterns.Testing.Autofac/Patterns.Testing.Autofac.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<ErrorReport>prompt</ErrorReport>
2626
<WarningLevel>4</WarningLevel>
2727
<DocumentationFile>bin\Debug\Patterns.Testing.Autofac.XML</DocumentationFile>
28+
<Prefer32Bit>false</Prefer32Bit>
2829
</PropertyGroup>
2930
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
3031
<DebugType>pdbonly</DebugType>
@@ -33,6 +34,7 @@
3334
<DefineConstants>TRACE</DefineConstants>
3435
<ErrorReport>prompt</ErrorReport>
3536
<WarningLevel>4</WarningLevel>
37+
<Prefer32Bit>false</Prefer32Bit>
3638
</PropertyGroup>
3739
<ItemGroup>
3840
<Reference Include="Autofac">

src/Patterns/Logging/LoggingInterceptor.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@
2121

2222
using System;
2323
using System.Linq;
24+
using System.Web.Script.Serialization;
2425

2526
using Castle.DynamicProxy;
2627

2728
using Common.Logging;
2829

30+
using Patterns.Collections.Strategies;
31+
2932
namespace Patterns.Logging
3033
{
3134
/// <summary>
@@ -42,6 +45,14 @@ public class LoggingInterceptor : IInterceptor
4245
private readonly LoggingConfig _config;
4346
private readonly Func<Type, ILog> _logFactory;
4447

48+
private static readonly FuncStrategies<Type, object, object> _displayStrategies
49+
= new FuncStrategies<Type, object, object>
50+
{
51+
{typeof (string), value => string.Format(_stringDisplayFormat, value)}
52+
};
53+
54+
private static readonly JavaScriptSerializer _jsonSerializer = new JavaScriptSerializer();
55+
4556
/// <summary>
4657
/// Initializes a new instance of the <see cref="LoggingInterceptor" /> class.
4758
/// </summary>
@@ -92,7 +103,11 @@ private static string GetMethodArguments(IInvocation invocation)
92103
private static object ConvertValueForDisplay(object value)
93104
{
94105
if (value == null) return _nullArgument;
95-
return value is string ? string.Format(_stringDisplayFormat, value) : value;
106+
107+
Type valueType = value.GetType();
108+
object newValue = _displayStrategies.Execute(valueType, value);
109+
110+
return newValue ?? _jsonSerializer.Serialize(value);
96111
}
97112
}
98113
}

src/Patterns/Patterns.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
<Reference Include="System" />
5050
<Reference Include="System.configuration" />
5151
<Reference Include="System.Core" />
52+
<Reference Include="System.Web.Extensions" />
5253
<Reference Include="System.Xml.Linq" />
5354
<Reference Include="System.Data.DataSetExtensions" />
5455
<Reference Include="Microsoft.CSharp" />

src/Patterns/SolutionAssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@
3131
[assembly: AssemblyCulture("")]
3232
[assembly: ComVisible(false)]
3333
[assembly: NeutralResourcesLanguage("en-US")]
34-
[assembly: AssemblyVersion("3.9.0")]
34+
[assembly: AssemblyVersion("3.9.1")]

src/Patterns/SolutionAssemblyInfo.settings.tt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Settings.Initialize(
33
majorNumber: 3,
44
minorNumber: 9,
5-
patchNumber: 0,
5+
patchNumber: 1,
66
buildNumber: null,
77
buildLevel: BuildLevels.None
88
);

0 commit comments

Comments
 (0)