-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de9e814
commit 0073100
Showing
14 changed files
with
239 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"sdk": { | ||
"version": "2.2.401" | ||
"version": "3.0.100" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> | ||
</startup> | ||
<runtime> | ||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Prism" publicKeyToken="40ee6c3a2184dc59" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-7.2.0.1367" newVersion="7.2.0.1367" /> | ||
</dependentAssembly> | ||
</assemblyBinding> | ||
</runtime> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="CommonServiceLocator" version="2.0.4" targetFramework="net45" /> | ||
<package id="Prism.Core" version="7.1.0.431" targetFramework="net45" /> | ||
<package id="Prism.Unity" version="7.1.0.431" targetFramework="net45" /> | ||
<package id="Prism.Wpf" version="7.1.0.431" targetFramework="net45" /> | ||
<package id="Prism.Core" version="7.2.0.1367" targetFramework="net45" /> | ||
<package id="Prism.Unity" version="7.2.0.1367" targetFramework="net45" /> | ||
<package id="Prism.Wpf" version="7.2.0.1367" targetFramework="net45" /> | ||
<package id="Serilog" version="2.8.0" targetFramework="net45" /> | ||
<package id="Serilog.Sinks.File" version="4.0.0" targetFramework="net45" /> | ||
<package id="Unity.Abstractions" version="3.3.1" targetFramework="net45" /> | ||
<package id="Unity.Container" version="5.8.11" targetFramework="net45" /> | ||
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="net45" /> | ||
<package id="System.ValueTuple" version="4.5.0" targetFramework="net45" /> | ||
<package id="Unity.Abstractions" version="4.1.3" targetFramework="net45" /> | ||
<package id="Unity.Container" version="5.10.3" targetFramework="net45" /> | ||
</packages> |
9 changes: 9 additions & 0 deletions
9
sample/netcoreapp3.0/PrismSerilogWpfDemoNetCoreApp30/App.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<prism:PrismApplication x:Class="PrismSerilogWpfDemoNetCoreApp30.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:prism="http://prismlibrary.com/" | ||
xmlns:local="clr-namespace:PrismSerilogWpfDemoNetCoreApp30"> | ||
<Application.Resources> | ||
|
||
</Application.Resources> | ||
</prism:PrismApplication> |
38 changes: 38 additions & 0 deletions
38
sample/netcoreapp3.0/PrismSerilogWpfDemoNetCoreApp30/App.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System.Text; | ||
using System.Windows; | ||
using Prism.Ioc; | ||
using Serilog; | ||
using PrismSerilogWpfDemoNetCoreApp30.Views; | ||
|
||
namespace PrismSerilogWpfDemoNetCoreApp30 | ||
{ | ||
public partial class App | ||
{ | ||
protected override void OnStartup(StartupEventArgs e) | ||
{ | ||
Log.Logger = new LoggerConfiguration() | ||
.MinimumLevel.Debug() | ||
.WriteTo.File(path: "DemoLog.txt", encoding: Encoding.UTF8) | ||
.CreateLogger(); | ||
|
||
base.OnStartup(e); | ||
} | ||
|
||
protected override void OnExit(ExitEventArgs e) | ||
{ | ||
Log.CloseAndFlush(); | ||
|
||
base.OnExit(e); | ||
} | ||
|
||
protected override void RegisterTypes(IContainerRegistry containerRegistry) | ||
{ | ||
containerRegistry.RegisterSerilog(); | ||
} | ||
|
||
protected override Window CreateShell() | ||
{ | ||
return Container.Resolve<MainWindow>(); | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
sample/netcoreapp3.0/PrismSerilogWpfDemoNetCoreApp30/PrismSerilogWpfDemoNetCoreApp30.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> | ||
|
||
<PropertyGroup> | ||
<OutputType>WinExe</OutputType> | ||
<TargetFramework>netcoreapp3.0</TargetFramework> | ||
<UseWPF>true</UseWPF> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\src\Prism.Logging.Serilog\Prism.Logging.Serilog.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Prism.Unity" Version="7.2.0.1367" /> | ||
|
||
<PackageReference Include="Serilog" Version="2.8.0" /> | ||
<PackageReference Include="Serilog.Sinks.File" Version="4.0.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
86 changes: 86 additions & 0 deletions
86
sample/netcoreapp3.0/PrismSerilogWpfDemoNetCoreApp30/ViewModels/MainWindowViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
using System; | ||
using System.IO; | ||
using System.Text; | ||
using Prism.Commands; | ||
using Prism.Logging; | ||
using Prism.Mvvm; | ||
|
||
namespace PrismSerilogWpfDemoNetCoreApp30.ViewModels | ||
{ | ||
public class MainWindowViewModel : BindableBase | ||
{ | ||
private readonly ILoggerFacade _logger; | ||
private string _title = "Prism Serilog WPF Demo (.NET Core 3.0)"; | ||
|
||
public MainWindowViewModel(ILoggerFacade logger) | ||
{ | ||
_logger = logger ?? throw new ArgumentNullException(nameof(logger)); | ||
|
||
LogDebugCommand = new DelegateCommand(LogDebug); | ||
LogInformationCommand = new DelegateCommand(LogInformation); | ||
LogWarningCommand = new DelegateCommand(LogWarning); | ||
LogExceptionCommand = new DelegateCommand(LogException); | ||
} | ||
|
||
public string Title | ||
{ | ||
get => _title; | ||
set => SetProperty(ref _title, value); | ||
} | ||
|
||
public string Text | ||
{ | ||
get | ||
{ | ||
const string logFileName = "DemoLog.txt"; | ||
|
||
if (!File.Exists(logFileName)) | ||
{ | ||
return null; | ||
} | ||
|
||
// FileShare.ReadWrite required for Serilog to continue writing - File.ReadAllText doesn't allow that | ||
using (var stream = new FileStream(logFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) | ||
{ | ||
using (var reader = new StreamReader(stream, Encoding.UTF8, detectEncodingFromByteOrderMarks: true)) | ||
{ | ||
return reader.ReadToEnd(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
public DelegateCommand LogDebugCommand { get; } | ||
public DelegateCommand LogInformationCommand { get; } | ||
public DelegateCommand LogWarningCommand { get; } | ||
public DelegateCommand LogExceptionCommand { get; } | ||
|
||
private void LogDebug() | ||
{ | ||
_logger.Log("This is a Debug message!", Category.Debug, Priority.High); | ||
|
||
RaisePropertyChanged(nameof(Text)); | ||
} | ||
|
||
private void LogInformation() | ||
{ | ||
_logger.Log("This is an Information message!", Category.Info, Priority.High); | ||
|
||
RaisePropertyChanged(nameof(Text)); | ||
} | ||
|
||
private void LogWarning() | ||
{ | ||
_logger.Log("This is an Warning message!", Category.Warn, Priority.High); | ||
|
||
RaisePropertyChanged(nameof(Text)); | ||
} | ||
|
||
private void LogException() | ||
{ | ||
_logger.Log("This is an Exception message!", Category.Exception, Priority.High); | ||
|
||
RaisePropertyChanged(nameof(Text)); | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
sample/netcoreapp3.0/PrismSerilogWpfDemoNetCoreApp30/Views/MainWindow.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<Window x:Class="PrismSerilogWpfDemoNetCoreApp30.Views.MainWindow" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:prism="http://prismlibrary.com/" | ||
prism:ViewModelLocator.AutoWireViewModel="True" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:local="clr-namespace:PrismSerilogWpfDemoNetCoreApp30" | ||
mc:Ignorable="d" | ||
Title="{Binding Title}" Height="490" Width="480" | ||
WindowStartupLocation="CenterScreen" WindowStyle="SingleBorderWindow"> | ||
<Grid Margin="0 10 0 0"> | ||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Top"> | ||
<TextBlock TextWrapping="Wrap" FontSize="14" Margin="0 0 0 10">Log messages are being written to `DemoLog.txt`</TextBlock> | ||
<TextBox Height="330" Width="440" Margin="5 0 0 0" Padding="5" Text="{Binding Text, Mode=OneWay}" VerticalScrollBarVisibility="Visible" IsReadOnly="True" /> | ||
</StackPanel> | ||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Bottom" Orientation="Horizontal"> | ||
<Button Margin="10 0 0 30" Padding="5" Command="{Binding LogDebugCommand}" Content="Log Debug" /> | ||
<Button Margin="10 0 0 30" Padding="5" Command="{Binding LogInformationCommand}" Content="Log Information" /> | ||
<Button Margin="10 0 0 30" Padding="5" Command="{Binding LogWarningCommand}" Content="Log Warning" /> | ||
<Button Margin="10 0 0 30" Padding="5" Command="{Binding LogExceptionCommand}" Content="Log Exception" /> | ||
</StackPanel> | ||
</Grid> | ||
</Window> |
12 changes: 12 additions & 0 deletions
12
sample/netcoreapp3.0/PrismSerilogWpfDemoNetCoreApp30/Views/MainWindow.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Windows; | ||
|
||
namespace PrismSerilogWpfDemoNetCoreApp30.Views | ||
{ | ||
public partial class MainWindow : Window | ||
{ | ||
public MainWindow() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/Prism.Logging.Serilog.Tests/Prism.Logging.Serilog.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters