11 changed files with 246 additions and 13 deletions
@ -0,0 +1,32 @@ |
|||
// Copyright (c) The Perspex Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
|
|||
namespace Perspex.Data |
|||
{ |
|||
/// <summary>
|
|||
/// Represents a recoverable binding error.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// When produced by a binding source observable, informs the binding system that an error
|
|||
/// occurred. It causes a binding error to be logged: the value of the bound property will not
|
|||
/// change.
|
|||
/// </remarks>
|
|||
public class BindingError |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="BindingError"/> class.
|
|||
/// </summary>
|
|||
/// <param name="exception">An exception describing the binding error.</param>
|
|||
public BindingError(Exception exception) |
|||
{ |
|||
Exception = exception; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets the exception describing the binding error.
|
|||
/// </summary>
|
|||
public Exception Exception { get; } |
|||
} |
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
// Copyright (c) The Perspex Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
using System.Reactive.Disposables; |
|||
using Perspex.Logging; |
|||
|
|||
namespace Perspex.UnitTests |
|||
{ |
|||
public delegate void LogCallback( |
|||
LogEventLevel level, |
|||
string area, |
|||
object source, |
|||
string messageTemplate, |
|||
params object[] propertyValues); |
|||
|
|||
public class TestLogSink : ILogSink |
|||
{ |
|||
private LogCallback _callback; |
|||
|
|||
public TestLogSink(LogCallback callback) |
|||
{ |
|||
_callback = callback; |
|||
} |
|||
|
|||
public static IDisposable Start(LogCallback callback) |
|||
{ |
|||
var sink = new TestLogSink(callback); |
|||
Logger.Sink = sink; |
|||
return Disposable.Create(() => Logger.Sink = null); |
|||
} |
|||
|
|||
public void Log(LogEventLevel level, string area, object source, string messageTemplate, params object[] propertyValues) |
|||
{ |
|||
_callback(level, area, source, messageTemplate, propertyValues); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue