Skip to content

Commit

Permalink
Updated Dapplo.LogFacade and Dapplo.Utils, cleanup of code
Browse files Browse the repository at this point in the history
[release]
  • Loading branch information
Lakritzator committed May 16, 2016
1 parent b12555b commit 4d0c8cf
Show file tree
Hide file tree
Showing 30 changed files with 152 additions and 168 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
<DocumentationFile>bin\Release\Dapplo.HttpExtensions.XML</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="Dapplo.LogFacade, Version=0.2.43.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Dapplo.LogFacade.0.2.43\lib\net45\Dapplo.LogFacade.dll</HintPath>
<Reference Include="Dapplo.LogFacade, Version=0.2.44.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Dapplo.LogFacade.0.2.44\lib\net45\Dapplo.LogFacade.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Dapplo.Utils, Version=0.1.28.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Dapplo.Utils.0.1.28\lib\net45\Dapplo.Utils.dll</HintPath>
<Reference Include="Dapplo.Utils, Version=0.1.30.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Dapplo.Utils.0.1.30\lib\net45\Dapplo.Utils.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="PresentationCore" />
Expand Down
4 changes: 2 additions & 2 deletions Dapplo.HttpExtensions.Net45/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Dapplo.LogFacade" version="0.2.43" targetFramework="net45" />
<package id="Dapplo.Utils" version="0.1.28" targetFramework="net45" />
<package id="Dapplo.LogFacade" version="0.2.44" targetFramework="net45" />
<package id="Dapplo.Utils" version="0.1.30" targetFramework="net45" />
</packages>
4 changes: 2 additions & 2 deletions Dapplo.HttpExtensions.PCL/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.

[assembly: AssemblyTitle("Dapplo.HttpExtensions.PCL")]
[assembly: AssemblyTitle("Dapplo.HttpExtensions")]
[assembly: AssemblyDescription("Extensions which simplify usage of Http services.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Dapplo")]
[assembly: AssemblyProduct("Dapplo.HttpExtensions.PCL")]
[assembly: AssemblyProduct("Dapplo.HttpExtensions")]
[assembly: AssemblyCopyright("Copyright © Dapplo 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
Expand Down
4 changes: 2 additions & 2 deletions Dapplo.HttpExtensions.PCL/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"dnxcore50.app": {}
},
"dependencies": {
"Dapplo.LogFacade": "0.2.43",
"Dapplo.Utils": "0.1.28",
"Dapplo.LogFacade": "0.2.44",
"Dapplo.Utils": "0.1.30",
"Microsoft.NETCore": "5.0.0",
"Microsoft.NETCore.Portable.Compatibility": "1.0.0",
"System.ComponentModel": "4.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

#region using

#region using

using System;
using System.Collections.Generic;
using System.Net.Http;
Expand All @@ -33,8 +31,6 @@
using Dapplo.LogFacade;
using Dapplo.Utils.Extensions;

#endregion

#if _PCL_
using System.Reflection;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#region using

using Dapplo.LogFacade;
using System.Net;
using System.Net.Http;

Expand All @@ -35,8 +34,6 @@ namespace Dapplo.HttpExtensions.Factory
/// </summary>
public static partial class HttpMessageHandlerFactory
{
private static readonly LogSource Log = new LogSource();

/// <summary>
/// This creates a HttpMessageHandler
/// Should be the preferred method to use to create a HttpMessageHandler
Expand Down
4 changes: 0 additions & 4 deletions Dapplo.HttpExtensions.Shared/HttpExtensionsGlobals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@

#endregion

#if !_PCL_

#endif

namespace Dapplo.HttpExtensions
{
/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions Dapplo.HttpExtensions.Shared/Support/HttpSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@

using System;
using System.Net;
using System.Net.Security;
using System.Reflection;
using System.Security.Principal;
using System.Text;

#if !_PCL_
using System.Net.Cache;
using System.Security.Principal;
using System.Net.Security;
#endif

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

#region using

using Dapplo.LogFacade;
using System.Net.Cache;
using System.Net.Http;
using Dapplo.LogFacade;

#endregion

Expand All @@ -35,6 +35,8 @@ namespace Dapplo.HttpExtensions.Factory
/// </summary>
public static partial class HttpMessageHandlerFactory
{
private static readonly LogSource Log = new LogSource();

/// <summary>
/// This creates an advanced HttpMessageHandler, used in desktop applications
/// Should be preferred
Expand Down
4 changes: 2 additions & 2 deletions Dapplo.HttpExtensions.Tests.Shared/GithubTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Dapplo - building blocks for desktop applications
// Copyright (C) 2015-2016 Dapplo
// Copyright (C) 2016 Dapplo
//
// For more information see: http://dapplo.net/
// Dapplo repositories are hosted on GitHub: https://github.com/dapplo
Expand All @@ -25,11 +25,11 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Dapplo.HttpExtensions.Tests.Logger;
using Dapplo.HttpExtensions.Tests.TestEntities;
using Dapplo.LogFacade;
using Xunit;
using Xunit.Abstractions;
using Dapplo.HttpExtensions.Tests.Logger;

#endregion

Expand Down
10 changes: 4 additions & 6 deletions Dapplo.HttpExtensions.Tests.Shared/HttpPartsPostTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Dapplo - building blocks for desktop applications
// Copyright (C) 2015-2016 Dapplo
// Copyright (C) 2016 Dapplo
//
// For more information see: http://dapplo.net/
// Dapplo repositories are hosted on GitHub: https://github.com/dapplo
Expand Down Expand Up @@ -35,7 +35,7 @@
namespace Dapplo.HttpExtensions.Tests
{
/// <summary>
/// Test posting parts
/// Test posting parts
/// </summary>
public class HttpPartsPostTest
{
Expand All @@ -48,7 +48,7 @@ public HttpPartsPostTest(ITestOutputHelper testOutputHelper)
}

/// <summary>
/// Test posting
/// Test posting
/// </summary>
[Fact]
public async Task TestPost()
Expand All @@ -57,9 +57,7 @@ public async Task TestPost()
var uploadBehaviour = HttpBehaviour.Current.Clone();

uploadBehaviour.UseProgressStream = true;
uploadBehaviour.UploadProgress += progress => {
Log.Info().WriteLine("Progress {0}", (int)(progress * 100));
};
uploadBehaviour.UploadProgress += progress => { Log.Info().WriteLine("Progress {0}", (int) (progress*100)); };
uploadBehaviour.MakeCurrent();
var testObject = new MyMultiPartRequest
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Dapplo - building blocks for desktop applications
// Copyright (C) 2015-2016 Dapplo
// Copyright (C) 2016 Dapplo
//
// For more information see: http://dapplo.net/
// Dapplo repositories are hosted on GitHub: https://github.com/dapplo
Expand All @@ -24,10 +24,10 @@
using System;
using System.Threading.Tasks;
using Dapplo.HttpExtensions.Factory;
using Dapplo.HttpExtensions.Tests.Logger;
using Dapplo.LogFacade;
using Xunit;
using Xunit.Abstractions;
using Dapplo.HttpExtensions.Tests.Logger;

#endregion

Expand All @@ -38,7 +38,6 @@ namespace Dapplo.HttpExtensions.Tests
/// </summary>
public class HttpRequestMessageExtensionsTests
{

public HttpRequestMessageExtensionsTests(ITestOutputHelper testOutputHelper)
{
XUnitLogger.RegisterLogger(testOutputHelper, LogLevel.Verbose);
Expand Down
6 changes: 3 additions & 3 deletions Dapplo.HttpExtensions.Tests.Shared/JsonTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Dapplo - building blocks for desktop applications
// Copyright (C) 2015-2016 Dapplo
// Copyright (C) 2016 Dapplo
//
// For more information see: http://dapplo.net/
// Dapplo repositories are hosted on GitHub: https://github.com/dapplo
Expand All @@ -22,18 +22,18 @@
#region using

using System;
using Dapplo.HttpExtensions.Tests.Logger;
using Dapplo.HttpExtensions.Tests.TestEntities;
using Dapplo.LogFacade;
using Xunit;
using Xunit.Abstractions;
using Dapplo.HttpExtensions.Tests.Logger;

#endregion

namespace Dapplo.HttpExtensions.Tests
{
/// <summary>
/// Tests for (de)serializing Json
/// Tests for (de)serializing Json
/// </summary>
public class JsonTests
{
Expand Down
43 changes: 20 additions & 23 deletions Dapplo.HttpExtensions.Tests.Shared/Logger/XUnitLogger.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Dapplo - building blocks for desktop applications
// Copyright (C) 2015-2016 Dapplo
// Copyright (C) 2016 Dapplo
//
// For more information see: http://dapplo.net/
// Dapplo repositories are hosted on GitHub: https://github.com/dapplo
Expand All @@ -22,10 +22,10 @@
#region using

using System;
using System.Threading;
using Dapplo.LogFacade;
using Xunit.Abstractions;
using Dapplo.LogFacade.Loggers;
using System.Threading;
using Xunit.Abstractions;

#endregion

Expand Down Expand Up @@ -55,10 +55,7 @@ private XUnitLogger()
/// </summary>
public override LogLevel Level
{
get
{
return LogLevelAsyncLocal.Value;
}
get { return LogLevelAsyncLocal.Value; }
set { LogLevelAsyncLocal.Value = value; }
}

Expand All @@ -73,6 +70,22 @@ public override bool IsLogLevelEnabled(LogLevel level)
return level != LogLevel.None && level >= Level;
}

/// <summary>
/// Register the XUnitLogger, as the global LogFacade logger
/// This also places the ITestOutputHelper in the CallContext, so the output is mapped to the xUnit test
/// </summary>
/// <param name="testOutputHelper">ITestOutputHelper</param>
/// <param name="level">LogLevel, when none is given the LogSettings.DefaultLevel is used</param>
public static void RegisterLogger(ITestOutputHelper testOutputHelper, LogLevel level = default(LogLevel))
{
TestOutputHelperAsyncLocal.Value = testOutputHelper;
LogLevelAsyncLocal.Value = level == LogLevel.None ? LogSettings.DefaultLevel : level;
if (!(LogSettings.Logger is XUnitLogger))
{
LogSettings.Logger = new XUnitLogger();
}
}

public override void Write(LogInfo logInfo, string messageTemplate, params object[] logParameters)
{
var testOutputHelper = TestOutputHelperAsyncLocal.Value;
Expand All @@ -99,21 +112,5 @@ public override void Write(LogInfo logInfo, Exception exception, string messageT
testOutputHelper.WriteLine(exception.ToString());
}
}

/// <summary>
/// Register the XUnitLogger, as the global LogFacade logger
/// This also places the ITestOutputHelper in the CallContext, so the output is mapped to the xUnit test
/// </summary>
/// <param name="testOutputHelper">ITestOutputHelper</param>
/// <param name="level">LogLevel, when none is given the LogSettings.DefaultLevel is used</param>
public static void RegisterLogger(ITestOutputHelper testOutputHelper, LogLevel level = default(LogLevel))
{
TestOutputHelperAsyncLocal.Value = testOutputHelper;
LogLevelAsyncLocal.Value = level == LogLevel.None ? LogSettings.DefaultLevel : level;
if (!(LogSettings.Logger is XUnitLogger))
{
LogSettings.Logger = new XUnitLogger();
}
}
}
}
4 changes: 2 additions & 2 deletions Dapplo.HttpExtensions.Tests.Shared/OAuth/OAuth2Tests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Dapplo - building blocks for desktop applications
// Copyright (C) 2015-2016 Dapplo
// Copyright (C) 2016 Dapplo
//
// For more information see: http://dapplo.net/
// Dapplo repositories are hosted on GitHub: https://github.com/dapplo
Expand All @@ -25,10 +25,10 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Dapplo.HttpExtensions.OAuth;
using Dapplo.HttpExtensions.Tests.Logger;
using Dapplo.LogFacade;
using Xunit;
using Xunit.Abstractions;
using Dapplo.HttpExtensions.Tests.Logger;

#endregion

Expand Down
6 changes: 3 additions & 3 deletions Dapplo.HttpExtensions.Tests.Shared/OAuth/OAuthTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Dapplo - building blocks for desktop applications
// Copyright (C) 2015-2016 Dapplo
// Copyright (C) 2016 Dapplo
//
// For more information see: http://dapplo.net/
// Dapplo repositories are hosted on GitHub: https://github.com/dapplo
Expand Down Expand Up @@ -27,17 +27,17 @@
using System.Text;
using System.Threading.Tasks;
using Dapplo.HttpExtensions.OAuth;
using Dapplo.HttpExtensions.Tests.Logger;
using Dapplo.LogFacade;
using Xunit;
using Xunit.Abstractions;
using Dapplo.HttpExtensions.Tests.Logger;

#endregion

namespace Dapplo.HttpExtensions.Tests.OAuth
{
/// <summary>
/// This tests some of the basic oauth 1 logic, together with a server at: http://term.ie/oauth/example/
/// This tests some of the basic oauth 1 logic, together with a server at: http://term.ie/oauth/example/
/// </summary>
public class OAuthTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Dapplo - building blocks for desktop applications
// Copyright (C) 2015-2016 Dapplo
// Copyright (C) 2016 Dapplo
//
// For more information see: http://dapplo.net/
// Dapplo repositories are hosted on GitHub: https://github.com/dapplo
Expand All @@ -23,9 +23,9 @@

using System.Threading.Tasks;
using Dapplo.HttpExtensions.Listener;
using Dapplo.HttpExtensions.Tests.Logger;
using Xunit;
using Xunit.Abstractions;
using Dapplo.HttpExtensions.Tests.Logger;

#endregion

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Dapplo - building blocks for desktop applications
// Copyright (C) 2015-2016 Dapplo
// Copyright (C) 2016 Dapplo
//
// For more information see: http://dapplo.net/
// Dapplo repositories are hosted on GitHub: https://github.com/dapplo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Dapplo - building blocks for desktop applications
// Copyright (C) 2015-2016 Dapplo
// Copyright (C) 2016 Dapplo
//
// For more information see: http://dapplo.net/
// Dapplo repositories are hosted on GitHub: https://github.com/dapplo
Expand Down
Loading

0 comments on commit 4d0c8cf

Please sign in to comment.