From b36ef621e87c3c591422f3270a57e9cb4d0b54d8 Mon Sep 17 00:00:00 2001 From: Valentin LECERF Date: Sun, 27 Jan 2019 17:51:04 +0100 Subject: [PATCH 1/9] Upgrade target framework to 4.7 --- SharePointLogViewer/SharePointLogViewer.csproj | 11 ++++++++--- SharePointLogViewer/app.config | 17 ++++++++--------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/SharePointLogViewer/SharePointLogViewer.csproj b/SharePointLogViewer/SharePointLogViewer.csproj index 2a1a293..c5c8c10 100644 --- a/SharePointLogViewer/SharePointLogViewer.csproj +++ b/SharePointLogViewer/SharePointLogViewer.csproj @@ -1,5 +1,5 @@  - + Debug AnyCPU @@ -10,7 +10,7 @@ Properties SharePointLogViewer SharePointLogViewer - v3.5 + v4.7.2 512 {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 4 @@ -49,6 +49,7 @@ DEBUG;TRACE prompt 4 + false pdbonly @@ -57,6 +58,7 @@ DEBUG;TRACE prompt 4 + false @@ -70,6 +72,7 @@ + 3.0 @@ -203,7 +206,9 @@ ResXFileCodeGenerator Resources.Designer.cs - + + Designer + SettingsSingleFileGenerator Settings.Designer.cs diff --git a/SharePointLogViewer/app.config b/SharePointLogViewer/app.config index e6054d4..0be9d52 100644 --- a/SharePointLogViewer/app.config +++ b/SharePointLogViewer/app.config @@ -1,11 +1,11 @@ - -
+ +
- + 100 @@ -27,8 +27,7 @@ - + Timestamp Process TID @@ -54,13 +53,13 @@ False - + - + - + True @@ -69,7 +68,7 @@ Information - + From dde461528947bc89994a9f550491342f8824a93d Mon Sep 17 00:00:00 2001 From: Valentin LECERF Date: Sun, 27 Jan 2019 17:54:49 +0100 Subject: [PATCH 2/9] gitignore file added --- SharePointLogViewer/.gitignore | 237 ++++++++++++++++++ .../SharePointLogViewer.csproj | 1 + 2 files changed, 238 insertions(+) create mode 100644 SharePointLogViewer/.gitignore diff --git a/SharePointLogViewer/.gitignore b/SharePointLogViewer/.gitignore new file mode 100644 index 0000000..aa6c475 --- /dev/null +++ b/SharePointLogViewer/.gitignore @@ -0,0 +1,237 @@ +/Properties/launchSettings.json + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +build/ +bld/ +bin/ +Bin/ +obj/ +Obj/ + +# Visual Studio 2015 cache/options directory +.vs/ +/wwwroot/dist/ +/ClientApp/dist/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Microsoft Azure ApplicationInsights config file +ApplicationInsights.config + +# Windows Store app package directory +AppPackages/ +BundleArtifacts/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +orleans.codegen.cs + +/node_modules + +/yarn.lock + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe + +# FAKE - F# Make +.fake/ diff --git a/SharePointLogViewer/SharePointLogViewer.csproj b/SharePointLogViewer/SharePointLogViewer.csproj index c5c8c10..17e2fda 100644 --- a/SharePointLogViewer/SharePointLogViewer.csproj +++ b/SharePointLogViewer/SharePointLogViewer.csproj @@ -206,6 +206,7 @@ ResXFileCodeGenerator Resources.Designer.cs + Designer From 740932277be1318bb0e5db6c58a0bb40ce554bf7 Mon Sep 17 00:00:00 2001 From: Valentin LECERF Date: Sun, 27 Jan 2019 17:57:17 +0100 Subject: [PATCH 3/9] Target Framework changed --- .../Properties/Resources.Designer.cs | 26 +++++++++---------- .../Properties/Settings.Designer.cs | 10 +++---- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/SharePointLogViewer/Properties/Resources.Designer.cs b/SharePointLogViewer/Properties/Resources.Designer.cs index 2a7e1b4..79c528d 100644 --- a/SharePointLogViewer/Properties/Resources.Designer.cs +++ b/SharePointLogViewer/Properties/Resources.Designer.cs @@ -1,10 +1,10 @@ //------------------------------------------------------------------------------ // -// This code was generated by a tool. -// Runtime Version:4.0.21006.1 +// Ce code a été généré par un outil. +// Version du runtime :4.0.30319.42000 // -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. +// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si +// le code est régénéré. // //------------------------------------------------------------------------------ @@ -13,13 +13,13 @@ namespace SharePointLogViewer.Properties { /// - /// A strongly-typed resource class, for looking up localized strings, etc. + /// Une classe de ressource fortement typée destinée, entre autres, à la consultation des chaînes localisées. /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + // Cette classe a été générée automatiquement par la classe StronglyTypedResourceBuilder + // à l'aide d'un outil, tel que ResGen ou Visual Studio. + // Pour ajouter ou supprimer un membre, modifiez votre fichier .ResX, puis réexécutez ResGen + // avec l'option /str ou régénérez votre projet VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { @@ -33,7 +33,7 @@ internal Resources() { } /// - /// Returns the cached ResourceManager instance used by this class. + /// Retourne l'instance ResourceManager mise en cache utilisée par cette classe. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Resources.ResourceManager ResourceManager { @@ -47,8 +47,8 @@ internal Resources() { } /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. + /// Remplace la propriété CurrentUICulture du thread actuel pour toutes + /// les recherches de ressources à l'aide de cette classe de ressource fortement typée. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Globalization.CultureInfo Culture { diff --git a/SharePointLogViewer/Properties/Settings.Designer.cs b/SharePointLogViewer/Properties/Settings.Designer.cs index 91a2d07..7aadb04 100644 --- a/SharePointLogViewer/Properties/Settings.Designer.cs +++ b/SharePointLogViewer/Properties/Settings.Designer.cs @@ -1,10 +1,10 @@ //------------------------------------------------------------------------------ // -// This code was generated by a tool. -// Runtime Version:4.0.30319.1 +// Ce code a été généré par un outil. +// Version du runtime :4.0.30319.42000 // -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. +// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si +// le code est régénéré. // //------------------------------------------------------------------------------ @@ -12,7 +12,7 @@ namespace SharePointLogViewer.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); From c7a2b65772560139bb7d2c15faa8ff71819f8d4a Mon Sep 17 00:00:00 2001 From: Valentin LECERF Date: Sun, 27 Jan 2019 17:57:30 +0100 Subject: [PATCH 4/9] gitignore moved --- .gitignore | 238 +++++++++++++++++- SharePointLogViewer/.gitignore | 237 ----------------- .../SharePointLogViewer.csproj | 1 - 3 files changed, 236 insertions(+), 240 deletions(-) delete mode 100644 SharePointLogViewer/.gitignore diff --git a/.gitignore b/.gitignore index 788e256..aa6c475 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,237 @@ +/Properties/launchSettings.json + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files *.suo -bin -obj \ No newline at end of file +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +build/ +bld/ +bin/ +Bin/ +obj/ +Obj/ + +# Visual Studio 2015 cache/options directory +.vs/ +/wwwroot/dist/ +/ClientApp/dist/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Microsoft Azure ApplicationInsights config file +ApplicationInsights.config + +# Windows Store app package directory +AppPackages/ +BundleArtifacts/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +orleans.codegen.cs + +/node_modules + +/yarn.lock + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe + +# FAKE - F# Make +.fake/ diff --git a/SharePointLogViewer/.gitignore b/SharePointLogViewer/.gitignore deleted file mode 100644 index aa6c475..0000000 --- a/SharePointLogViewer/.gitignore +++ /dev/null @@ -1,237 +0,0 @@ -/Properties/launchSettings.json - -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. - -# User-specific files -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -build/ -bld/ -bin/ -Bin/ -obj/ -Obj/ - -# Visual Studio 2015 cache/options directory -.vs/ -/wwwroot/dist/ -/ClientApp/dist/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUNIT -*.VisualState.xml -TestResult.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -*_i.c -*_p.c -*_i.h -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# JustCode is a .NET coding add-in -.JustCode - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# TODO: Comment the next line if you want to checkin your web deploy settings -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# NuGet Packages -*.nupkg -# The packages folder can be ignored because of Package Restore -**/packages/* -# except build/, which is used as an MSBuild target. -!**/packages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/packages/repositories.config - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Microsoft Azure ApplicationInsights config file -ApplicationInsights.config - -# Windows Store app package directory -AppPackages/ -BundleArtifacts/ - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.pfx -*.publishsettings -orleans.codegen.cs - -/node_modules - -/yarn.lock - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -*.mdf -*.ldf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe - -# FAKE - F# Make -.fake/ diff --git a/SharePointLogViewer/SharePointLogViewer.csproj b/SharePointLogViewer/SharePointLogViewer.csproj index 17e2fda..c5c8c10 100644 --- a/SharePointLogViewer/SharePointLogViewer.csproj +++ b/SharePointLogViewer/SharePointLogViewer.csproj @@ -206,7 +206,6 @@ ResXFileCodeGenerator Resources.Designer.cs - Designer From 9d90ed34520dcc0b76a6bda0e748ff56466c7a5d Mon Sep 17 00:00:00 2001 From: Valentin LECERF Date: Sun, 27 Jan 2019 17:58:46 +0100 Subject: [PATCH 5/9] Unused references removed --- SharePointLogViewer/App.xaml.cs | 6 +----- .../AutoCompleteTextBox/AutoCompleteManager.cs | 1 - .../AutoCompleteTextBox/AutoCompleteTextBox.cs | 2 -- SharePointLogViewer/Controls/BaseWPFHelpers.cs | 13 +------------ SharePointLogViewer/Controls/FilterableListView.cs | 3 --- .../Controls/LoadingAnimation.xaml.cs | 10 ---------- .../Controls/SortableGridViewColumn.cs | 12 +----------- .../Controls/SortableGridViewColumnHeader.cs | 6 +----- SharePointLogViewer/Controls/SortableListView.cs | 1 - SharePointLogViewer/Extensions.cs | 5 +---- SharePointLogViewer/Filters/IFilter.cs | 7 +------ SharePointLogViewer/Filters/ListViewFilter.cs | 6 +----- SharePointLogViewer/Filters/SeverityFilter.cs | 7 +------ .../HiglightBookmarkedValueConverter.cs | 3 --- SharePointLogViewer/LogEntryViewModel.cs | 6 +----- SharePointLogViewer/LogFilterListView.cs | 10 ---------- SharePointLogViewer/MainWindow.xaml.cs | 1 - SharePointLogViewer/Monitoring/FileTail.cs | 2 -- SharePointLogViewer/Monitoring/ILogMonitor.cs | 3 --- .../Monitoring/LogDirectoryWatcher.cs | 3 --- SharePointLogViewer/Monitoring/LogEntry.cs | 6 +----- SharePointLogViewer/Monitoring/LogExporter.cs | 5 +---- SharePointLogViewer/Monitoring/LogMonitor.cs | 3 --- SharePointLogViewer/Monitoring/LogParser.cs | 6 +----- SharePointLogViewer/Monitoring/LogsLoader.cs | 3 --- SharePointLogViewer/Monitoring/MultiLogMonitor.cs | 2 -- SharePointLogViewer/Notifiers/EmailNotifier.cs | 3 --- SharePointLogViewer/Notifiers/EventLogNotifier.cs | 6 +----- SharePointLogViewer/Notifiers/INotifier.cs | 7 +------ SharePointLogViewer/Notifiers/SystemTrayNotifier.cs | 3 --- SharePointLogViewer/Properties/AssemblyInfo.cs | 2 -- SharePointLogViewer/SPUtility.cs | 1 - SharePointLogViewer/SPVersion.cs | 7 +------ SharePointLogViewer/Searching/BookmarkNavigator.cs | 1 - SharePointLogViewer/Searching/DynamicFilter.cs | 2 -- SharePointLogViewer/Searching/FastInvoke.cs | 3 --- SharePointLogViewer/Searching/LogEntryTokenizer.cs | 5 +---- SharePointLogViewer/Searching/OverflowCollection.cs | 2 -- SharePointLogViewer/SettingBinding.cs | 6 +----- SharePointLogViewer/SettingsViewModel.cs | 5 +---- SharePointLogViewer/SettingsWindow.xaml.cs | 8 -------- SharePointLogViewer/ValueConverter.cs | 3 --- 42 files changed, 18 insertions(+), 178 deletions(-) diff --git a/SharePointLogViewer/App.xaml.cs b/SharePointLogViewer/App.xaml.cs index 0b1fa6e..6976c78 100644 --- a/SharePointLogViewer/App.xaml.cs +++ b/SharePointLogViewer/App.xaml.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Data; -using System.Windows; +using System.Windows; namespace SharePointLogViewer { diff --git a/SharePointLogViewer/Controls/AutoCompleteTextBox/AutoCompleteManager.cs b/SharePointLogViewer/Controls/AutoCompleteTextBox/AutoCompleteManager.cs index d8acbb0..735cceb 100644 --- a/SharePointLogViewer/Controls/AutoCompleteTextBox/AutoCompleteManager.cs +++ b/SharePointLogViewer/Controls/AutoCompleteTextBox/AutoCompleteManager.cs @@ -9,7 +9,6 @@ using System.Windows.Interop; using System.Windows.Media; using System.Windows.Shapes; -using System.Windows.Threading; using Microsoft.Windows.Themes; using System.Linq; diff --git a/SharePointLogViewer/Controls/AutoCompleteTextBox/AutoCompleteTextBox.cs b/SharePointLogViewer/Controls/AutoCompleteTextBox/AutoCompleteTextBox.cs index b242a0f..6aa751d 100644 --- a/SharePointLogViewer/Controls/AutoCompleteTextBox/AutoCompleteTextBox.cs +++ b/SharePointLogViewer/Controls/AutoCompleteTextBox/AutoCompleteTextBox.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Text; using System.Windows.Controls; namespace SharePointLogViewer.Controls.AutoCompleteTextBox diff --git a/SharePointLogViewer/Controls/BaseWPFHelpers.cs b/SharePointLogViewer/Controls/BaseWPFHelpers.cs index e4a9754..6f46c09 100644 --- a/SharePointLogViewer/Controls/BaseWPFHelpers.cs +++ b/SharePointLogViewer/Controls/BaseWPFHelpers.cs @@ -8,22 +8,11 @@ #region Using using System; using System.Collections.Generic; -using System.Text; -using System.Data; -using System.Data.Common; -using System.Configuration; -using System.ComponentModel; -using System.Collections.ObjectModel; -using System.Threading; using System.Windows; -using System.Windows.Threading; -using System.IO; using System.Windows.Media.Imaging; using System.Windows.Controls; -using System.Windows.Data; using System.Windows.Media; -using System.Windows.Media.Animation; -using System.Windows.Navigation; + #endregion diff --git a/SharePointLogViewer/Controls/FilterableListView.cs b/SharePointLogViewer/Controls/FilterableListView.cs index 007ec12..9daee3d 100644 --- a/SharePointLogViewer/Controls/FilterableListView.cs +++ b/SharePointLogViewer/Controls/FilterableListView.cs @@ -1,14 +1,11 @@ using System; using System.Collections.Generic; -using System.Text; using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows; -using System.Collections; using System.ComponentModel; using System.Windows.Data; using System.Windows.Input; -using System.Windows.Media; using System.Linq; diff --git a/SharePointLogViewer/Controls/LoadingAnimation.xaml.cs b/SharePointLogViewer/Controls/LoadingAnimation.xaml.cs index d612dc1..34f9d05 100644 --- a/SharePointLogViewer/Controls/LoadingAnimation.xaml.cs +++ b/SharePointLogViewer/Controls/LoadingAnimation.xaml.cs @@ -1,16 +1,6 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; namespace SharePointLogViewer.Controls { diff --git a/SharePointLogViewer/Controls/SortableGridViewColumn.cs b/SharePointLogViewer/Controls/SortableGridViewColumn.cs index 076123f..6babd56 100644 --- a/SharePointLogViewer/Controls/SortableGridViewColumn.cs +++ b/SharePointLogViewer/Controls/SortableGridViewColumn.cs @@ -1,15 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows; +using System.Windows; using System.Windows.Controls; -using System.Windows.Controls.Primitives; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; // SortableListView, from the following blog post: // diff --git a/SharePointLogViewer/Controls/SortableGridViewColumnHeader.cs b/SharePointLogViewer/Controls/SortableGridViewColumnHeader.cs index bea1262..be8a343 100644 --- a/SharePointLogViewer/Controls/SortableGridViewColumnHeader.cs +++ b/SharePointLogViewer/Controls/SortableGridViewColumnHeader.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows.Controls; +using System.Windows.Controls; namespace SharePointLogViewer.Controls { diff --git a/SharePointLogViewer/Controls/SortableListView.cs b/SharePointLogViewer/Controls/SortableListView.cs index a6c93b6..2674b49 100644 --- a/SharePointLogViewer/Controls/SortableListView.cs +++ b/SharePointLogViewer/Controls/SortableListView.cs @@ -4,7 +4,6 @@ using System.ComponentModel; using System.Windows.Data; using System.Collections; -using System.Reflection; using SharePointLogViewer.Searching; // SortableListView, from the following blog post: diff --git a/SharePointLogViewer/Extensions.cs b/SharePointLogViewer/Extensions.cs index 2711982..ceae0bf 100644 --- a/SharePointLogViewer/Extensions.cs +++ b/SharePointLogViewer/Extensions.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Collections.Generic; using System.Collections.ObjectModel; namespace SharePointLogViewer diff --git a/SharePointLogViewer/Filters/IFilter.cs b/SharePointLogViewer/Filters/IFilter.cs index 6fb81e2..1cf5ea0 100644 --- a/SharePointLogViewer/Filters/IFilter.cs +++ b/SharePointLogViewer/Filters/IFilter.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace SharePointLogViewer.Filters +namespace SharePointLogViewer.Filters { interface IFilter { diff --git a/SharePointLogViewer/Filters/ListViewFilter.cs b/SharePointLogViewer/Filters/ListViewFilter.cs index fe0519e..5c3df2b 100644 --- a/SharePointLogViewer/Filters/ListViewFilter.cs +++ b/SharePointLogViewer/Filters/ListViewFilter.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows.Controls; +using System.Windows.Controls; namespace SharePointLogViewer.Filters { diff --git a/SharePointLogViewer/Filters/SeverityFilter.cs b/SharePointLogViewer/Filters/SeverityFilter.cs index ea57fda..4a96eed 100644 --- a/SharePointLogViewer/Filters/SeverityFilter.cs +++ b/SharePointLogViewer/Filters/SeverityFilter.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace SharePointLogViewer.Filters +namespace SharePointLogViewer.Filters { class SeverityFilter: IFilter { diff --git a/SharePointLogViewer/HiglightBookmarkedValueConverter.cs b/SharePointLogViewer/HiglightBookmarkedValueConverter.cs index 836ac01..c5800a2 100644 --- a/SharePointLogViewer/HiglightBookmarkedValueConverter.cs +++ b/SharePointLogViewer/HiglightBookmarkedValueConverter.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Windows.Data; namespace SharePointLogViewer diff --git a/SharePointLogViewer/LogEntryViewModel.cs b/SharePointLogViewer/LogEntryViewModel.cs index 0e9510a..923f233 100644 --- a/SharePointLogViewer/LogEntryViewModel.cs +++ b/SharePointLogViewer/LogEntryViewModel.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.ComponentModel; +using System.ComponentModel; using SharePointLogViewer.Monitoring; namespace SharePointLogViewer diff --git a/SharePointLogViewer/LogFilterListView.cs b/SharePointLogViewer/LogFilterListView.cs index 3a6f31e..693875e 100644 --- a/SharePointLogViewer/LogFilterListView.cs +++ b/SharePointLogViewer/LogFilterListView.cs @@ -1,14 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; -using System.Windows.Controls; -using System.Windows.Controls.Primitives; -using System.Windows; -using System.Collections; -using System.ComponentModel; -using System.Windows.Data; -using System.Windows.Input; -using System.Windows.Media; using SharePointLogViewer.Controls; namespace SharePointLogViewer diff --git a/SharePointLogViewer/MainWindow.xaml.cs b/SharePointLogViewer/MainWindow.xaml.cs index 6a3e9fc..d2021be 100644 --- a/SharePointLogViewer/MainWindow.xaml.cs +++ b/SharePointLogViewer/MainWindow.xaml.cs @@ -9,7 +9,6 @@ using System.Linq; using System.Diagnostics; using SharePointLogViewer.Controls.AutoCompleteTextBox; -using System.Collections; using System.Collections.Generic; using SharePointLogViewer.Searching; using SharePointLogViewer.Monitoring; diff --git a/SharePointLogViewer/Monitoring/FileTail.cs b/SharePointLogViewer/Monitoring/FileTail.cs index 1302bda..8ddcc79 100644 --- a/SharePointLogViewer/Monitoring/FileTail.cs +++ b/SharePointLogViewer/Monitoring/FileTail.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Text; using System.ComponentModel; using System.Threading; using System.IO; diff --git a/SharePointLogViewer/Monitoring/ILogMonitor.cs b/SharePointLogViewer/Monitoring/ILogMonitor.cs index 604c81e..146b854 100644 --- a/SharePointLogViewer/Monitoring/ILogMonitor.cs +++ b/SharePointLogViewer/Monitoring/ILogMonitor.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; namespace SharePointLogViewer.Monitoring { diff --git a/SharePointLogViewer/Monitoring/LogDirectoryWatcher.cs b/SharePointLogViewer/Monitoring/LogDirectoryWatcher.cs index 794bf6b..9647cc5 100644 --- a/SharePointLogViewer/Monitoring/LogDirectoryWatcher.cs +++ b/SharePointLogViewer/Monitoring/LogDirectoryWatcher.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.IO; namespace SharePointLogViewer.Monitoring diff --git a/SharePointLogViewer/Monitoring/LogEntry.cs b/SharePointLogViewer/Monitoring/LogEntry.cs index e9538ee..781aa59 100644 --- a/SharePointLogViewer/Monitoring/LogEntry.cs +++ b/SharePointLogViewer/Monitoring/LogEntry.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace SharePointLogViewer.Monitoring +namespace SharePointLogViewer.Monitoring { class LogEntry { diff --git a/SharePointLogViewer/Monitoring/LogExporter.cs b/SharePointLogViewer/Monitoring/LogExporter.cs index 86df1c3..93a18b3 100644 --- a/SharePointLogViewer/Monitoring/LogExporter.cs +++ b/SharePointLogViewer/Monitoring/LogExporter.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Collections.Generic; using System.IO; namespace SharePointLogViewer.Monitoring diff --git a/SharePointLogViewer/Monitoring/LogMonitor.cs b/SharePointLogViewer/Monitoring/LogMonitor.cs index 0993a56..d63cab1 100644 --- a/SharePointLogViewer/Monitoring/LogMonitor.cs +++ b/SharePointLogViewer/Monitoring/LogMonitor.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.IO; namespace SharePointLogViewer.Monitoring diff --git a/SharePointLogViewer/Monitoring/LogParser.cs b/SharePointLogViewer/Monitoring/LogParser.cs index 9da560c..881119e 100644 --- a/SharePointLogViewer/Monitoring/LogParser.cs +++ b/SharePointLogViewer/Monitoring/LogParser.cs @@ -1,9 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Data; +using System.Collections.Generic; using System.IO; -using System.Linq; namespace SharePointLogViewer.Monitoring { diff --git a/SharePointLogViewer/Monitoring/LogsLoader.cs b/SharePointLogViewer/Monitoring/LogsLoader.cs index 0e92584..8baddfa 100644 --- a/SharePointLogViewer/Monitoring/LogsLoader.cs +++ b/SharePointLogViewer/Monitoring/LogsLoader.cs @@ -1,9 +1,6 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using System.ComponentModel; -using System.Collections.ObjectModel; namespace SharePointLogViewer.Monitoring { diff --git a/SharePointLogViewer/Monitoring/MultiLogMonitor.cs b/SharePointLogViewer/Monitoring/MultiLogMonitor.cs index 469105d..81c78ff 100644 --- a/SharePointLogViewer/Monitoring/MultiLogMonitor.cs +++ b/SharePointLogViewer/Monitoring/MultiLogMonitor.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; namespace SharePointLogViewer.Monitoring { diff --git a/SharePointLogViewer/Notifiers/EmailNotifier.cs b/SharePointLogViewer/Notifiers/EmailNotifier.cs index 4614a86..1d27b12 100644 --- a/SharePointLogViewer/Notifiers/EmailNotifier.cs +++ b/SharePointLogViewer/Notifiers/EmailNotifier.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Net.Mail; namespace SharePointLogViewer.Notifiers diff --git a/SharePointLogViewer/Notifiers/EventLogNotifier.cs b/SharePointLogViewer/Notifiers/EventLogNotifier.cs index b949ce5..3f3c856 100644 --- a/SharePointLogViewer/Notifiers/EventLogNotifier.cs +++ b/SharePointLogViewer/Notifiers/EventLogNotifier.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Diagnostics; +using System.Diagnostics; namespace SharePointLogViewer.Notifiers { diff --git a/SharePointLogViewer/Notifiers/INotifier.cs b/SharePointLogViewer/Notifiers/INotifier.cs index 76039bd..75d9503 100644 --- a/SharePointLogViewer/Notifiers/INotifier.cs +++ b/SharePointLogViewer/Notifiers/INotifier.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace SharePointLogViewer.Notifiers +namespace SharePointLogViewer.Notifiers { interface INotifier { diff --git a/SharePointLogViewer/Notifiers/SystemTrayNotifier.cs b/SharePointLogViewer/Notifiers/SystemTrayNotifier.cs index 5940610..68ead1e 100644 --- a/SharePointLogViewer/Notifiers/SystemTrayNotifier.cs +++ b/SharePointLogViewer/Notifiers/SystemTrayNotifier.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.IO; namespace SharePointLogViewer.Notifiers diff --git a/SharePointLogViewer/Properties/AssemblyInfo.cs b/SharePointLogViewer/Properties/AssemblyInfo.cs index 1227ec6..1ab74aa 100644 --- a/SharePointLogViewer/Properties/AssemblyInfo.cs +++ b/SharePointLogViewer/Properties/AssemblyInfo.cs @@ -1,6 +1,4 @@ using System.Reflection; -using System.Resources; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Windows; diff --git a/SharePointLogViewer/SPUtility.cs b/SharePointLogViewer/SPUtility.cs index f82f077..8db7980 100644 --- a/SharePointLogViewer/SPUtility.cs +++ b/SharePointLogViewer/SPUtility.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; using System.IO; using Microsoft.Win32; using System.Security; diff --git a/SharePointLogViewer/SPVersion.cs b/SharePointLogViewer/SPVersion.cs index 80be7e9..9359482 100644 --- a/SharePointLogViewer/SPVersion.cs +++ b/SharePointLogViewer/SPVersion.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace SharePointLogViewer +namespace SharePointLogViewer { enum SPVersion { diff --git a/SharePointLogViewer/Searching/BookmarkNavigator.cs b/SharePointLogViewer/Searching/BookmarkNavigator.cs index b9b3d9c..92f40f4 100644 --- a/SharePointLogViewer/Searching/BookmarkNavigator.cs +++ b/SharePointLogViewer/Searching/BookmarkNavigator.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; using System.Windows.Controls; using System.ComponentModel; diff --git a/SharePointLogViewer/Searching/DynamicFilter.cs b/SharePointLogViewer/Searching/DynamicFilter.cs index 2733e67..238c30a 100644 --- a/SharePointLogViewer/Searching/DynamicFilter.cs +++ b/SharePointLogViewer/Searching/DynamicFilter.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Text; using System.Reflection; namespace SharePointLogViewer.Searching diff --git a/SharePointLogViewer/Searching/FastInvoke.cs b/SharePointLogViewer/Searching/FastInvoke.cs index 472e738..4f341ca 100644 --- a/SharePointLogViewer/Searching/FastInvoke.cs +++ b/SharePointLogViewer/Searching/FastInvoke.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Reflection; using System.Reflection.Emit; diff --git a/SharePointLogViewer/Searching/LogEntryTokenizer.cs b/SharePointLogViewer/Searching/LogEntryTokenizer.cs index 1e7ca4a..75b48ad 100644 --- a/SharePointLogViewer/Searching/LogEntryTokenizer.cs +++ b/SharePointLogViewer/Searching/LogEntryTokenizer.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Collections.Generic; namespace SharePointLogViewer.Searching { diff --git a/SharePointLogViewer/Searching/OverflowCollection.cs b/SharePointLogViewer/Searching/OverflowCollection.cs index 7fc5f95..c07be8e 100644 --- a/SharePointLogViewer/Searching/OverflowCollection.cs +++ b/SharePointLogViewer/Searching/OverflowCollection.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Collections.ObjectModel; using System.Collections.Specialized; diff --git a/SharePointLogViewer/SettingBinding.cs b/SharePointLogViewer/SettingBinding.cs index deba4fd..013aa00 100644 --- a/SharePointLogViewer/SettingBinding.cs +++ b/SharePointLogViewer/SettingBinding.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows.Data; +using System.Windows.Data; namespace SharePointLogViewer { diff --git a/SharePointLogViewer/SettingsViewModel.cs b/SharePointLogViewer/SettingsViewModel.cs index 0d74782..ebae61b 100644 --- a/SharePointLogViewer/SettingsViewModel.cs +++ b/SharePointLogViewer/SettingsViewModel.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Collections.Generic; namespace SharePointLogViewer { diff --git a/SharePointLogViewer/SettingsWindow.xaml.cs b/SharePointLogViewer/SettingsWindow.xaml.cs index 3f4f040..e2976bd 100644 --- a/SharePointLogViewer/SettingsWindow.xaml.cs +++ b/SharePointLogViewer/SettingsWindow.xaml.cs @@ -1,15 +1,7 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Text; using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; using System.Collections.Specialized; using Microsoft.Win32; using System.Reflection; diff --git a/SharePointLogViewer/ValueConverter.cs b/SharePointLogViewer/ValueConverter.cs index 7964515..d5fcff6 100644 --- a/SharePointLogViewer/ValueConverter.cs +++ b/SharePointLogViewer/ValueConverter.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Windows.Data; using System.Windows.Controls; From 229851383e21832b593bfd83c8a9921d3feb4620 Mon Sep 17 00:00:00 2001 From: Valentin LECERF Date: Sun, 27 Jan 2019 18:00:01 +0100 Subject: [PATCH 6/9] unused reference removed --- SharePointLogViewer/SharePointLogViewer.csproj | 2 -- 1 file changed, 2 deletions(-) diff --git a/SharePointLogViewer/SharePointLogViewer.csproj b/SharePointLogViewer/SharePointLogViewer.csproj index c5c8c10..9a0d465 100644 --- a/SharePointLogViewer/SharePointLogViewer.csproj +++ b/SharePointLogViewer/SharePointLogViewer.csproj @@ -68,9 +68,7 @@ 3.5 - - From cc4771dbc462e6c39f2ec41901db2323971907a1 Mon Sep 17 00:00:00 2001 From: Valentin LECERF Date: Sun, 27 Jan 2019 18:04:48 +0100 Subject: [PATCH 7/9] Code Cleanup --- .../AutoCompleteTextBox/AutoCompleteTextBox.cs | 15 +++++---------- .../Controls/FilterableListView.cs | 12 ++++++------ .../Controls/SortableGridViewColumn.cs | 2 +- SharePointLogViewer/Controls/SortableListView.cs | 15 ++++++++------- SharePointLogViewer/Extensions.cs | 3 +++ SharePointLogViewer/Filters/ListViewFilter.cs | 2 +- .../HiglightBookmarkedValueConverter.cs | 2 +- SharePointLogViewer/LogEntryViewModel.cs | 6 ++++++ SharePointLogViewer/LogFilterListView.cs | 5 +---- SharePointLogViewer/MainWindow.xaml.cs | 12 ++++++------ SharePointLogViewer/Monitoring/FileTail.cs | 2 +- SharePointLogViewer/SPUtility.cs | 12 ++++++------ SharePointLogViewer/Searching/DynamicFilter.cs | 2 +- SharePointLogViewer/Searching/FastInvoke.cs | 6 +++--- .../Searching/LogEntryTokenizer.cs | 2 +- .../Searching/OverflowCollection.cs | 6 +++--- SharePointLogViewer/SettingBinding.cs | 4 ++-- SharePointLogViewer/SettingsViewModel.cs | 5 +---- SharePointLogViewer/SettingsWindow.xaml.cs | 4 ++-- 19 files changed, 58 insertions(+), 59 deletions(-) diff --git a/SharePointLogViewer/Controls/AutoCompleteTextBox/AutoCompleteTextBox.cs b/SharePointLogViewer/Controls/AutoCompleteTextBox/AutoCompleteTextBox.cs index 6aa751d..a3806e5 100644 --- a/SharePointLogViewer/Controls/AutoCompleteTextBox/AutoCompleteTextBox.cs +++ b/SharePointLogViewer/Controls/AutoCompleteTextBox/AutoCompleteTextBox.cs @@ -6,24 +6,19 @@ namespace SharePointLogViewer.Controls.AutoCompleteTextBox { public class AutoCompleteTextBox : TextBox { - private AutoCompleteManager _acm; - - public AutoCompleteManager AutoCompleteManager - { - get { return _acm; } - } + public AutoCompleteManager AutoCompleteManager { get; } public AutoCompleteTextBox() { - _acm = new AutoCompleteManager(); - _acm.DataProvider = new SimpleStaticDataProvider(Enumerable.Empty()); - this.Loaded += AutoCompleteTextBox_Loaded; + AutoCompleteManager = new AutoCompleteManager(); + AutoCompleteManager.DataProvider = new SimpleStaticDataProvider(Enumerable.Empty()); + Loaded += AutoCompleteTextBox_Loaded; } void AutoCompleteTextBox_Loaded(object sender, System.Windows.RoutedEventArgs e) { if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this)) - _acm.AttachTextBox(this); + AutoCompleteManager.AttachTextBox(this); } } diff --git a/SharePointLogViewer/Controls/FilterableListView.cs b/SharePointLogViewer/Controls/FilterableListView.cs index 9daee3d..d60f730 100644 --- a/SharePointLogViewer/Controls/FilterableListView.cs +++ b/SharePointLogViewer/Controls/FilterableListView.cs @@ -62,7 +62,7 @@ class FilterStruct public FilterStruct(PropertyDescriptor propertyDescriptor, Button button, FilterItem value) { this.value = value; - this.Button = button; + Button = button; PropertyDescriptor = propertyDescriptor; } @@ -131,7 +131,7 @@ public override bool Equals(object obj) FilterItem otherItem = obj as FilterItem; if (otherItem != null) - return this.item == otherItem.item; + return item == otherItem.item; return base.Equals(obj); } @@ -140,9 +140,9 @@ public int CompareTo(object obj) { FilterItem otherFilterItem = (FilterItem)obj; - if (this.Item == null && obj == null) + if (Item == null && obj == null) return 0; - else if (otherFilterItem.Item != null && this.Item != null) + else if (otherFilterItem.Item != null && Item != null) return ((IComparable)item).CompareTo((IComparable)otherFilterItem.item); else return -1; @@ -189,7 +189,7 @@ protected override void OnInitialized(EventArgs e) dictionary = Application.LoadComponent(uri) as ResourceDictionary; // cast the ListView's View to a GridView - GridView gridView = this.View as GridView; + GridView gridView = View as GridView; if (gridView != null) { // apply the data template, that includes the popup, button etc ... to each column @@ -329,7 +329,7 @@ protected void SelectionChangedHandler(object sender, SelectionChangedEventArgs if (!column.CanBeFiltered) { FilterStruct filter = (FilterStruct)currentFilters[currentFilterProperty]; - filter.Button.Visibility = System.Windows.Visibility.Hidden; + filter.Button.Visibility = Visibility.Hidden; return; } diff --git a/SharePointLogViewer/Controls/SortableGridViewColumn.cs b/SharePointLogViewer/Controls/SortableGridViewColumn.cs index 6babd56..fe8f125 100644 --- a/SharePointLogViewer/Controls/SortableGridViewColumn.cs +++ b/SharePointLogViewer/Controls/SortableGridViewColumn.cs @@ -9,7 +9,7 @@ namespace SharePointLogViewer.Controls { public class SortableGridViewColumn : GridViewColumn { - static Setter hideSetter = new Setter(GridViewColumnHeader.VisibilityProperty, Visibility.Collapsed); + static Setter hideSetter = new Setter(UIElement.VisibilityProperty, Visibility.Collapsed); public string SortPropertyName { diff --git a/SharePointLogViewer/Controls/SortableListView.cs b/SharePointLogViewer/Controls/SortableListView.cs index 2674b49..fa89356 100644 --- a/SharePointLogViewer/Controls/SortableListView.cs +++ b/SharePointLogViewer/Controls/SortableListView.cs @@ -4,6 +4,7 @@ using System.ComponentModel; using System.Windows.Data; using System.Collections; +using System.Windows.Controls.Primitives; using SharePointLogViewer.Searching; // SortableListView, from the following blog post: @@ -73,10 +74,10 @@ protected override void OnInitialized(EventArgs e) // add the event handler to the GridViewColumnHeader. This strongly ties this ListView to a GridView. - this.AddHandler(GridViewColumnHeader.ClickEvent, new RoutedEventHandler(GridViewColumnHeaderClickedHandler)); + AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(GridViewColumnHeaderClickedHandler)); // cast the ListView's View to a GridView - GridView gridView = this.View as GridView; + GridView gridView = View as GridView; if (gridView != null) { // determine which column is marked as IsDefaultSortColumn. Stops on the first column marked this way. @@ -102,10 +103,10 @@ protected override void OnInitialized(EventArgs e) lastSortedOnColumn = sortableGridViewColumn; Sort(sortableGridViewColumn.SortPropertyName, ListSortDirection.Ascending); - if (!String.IsNullOrEmpty(this.ColumnHeaderSortedAscendingTemplate)) - sortableGridViewColumn.HeaderTemplate = this.TryFindResource(ColumnHeaderSortedAscendingTemplate) as DataTemplate; + if (!String.IsNullOrEmpty(ColumnHeaderSortedAscendingTemplate)) + sortableGridViewColumn.HeaderTemplate = TryFindResource(ColumnHeaderSortedAscendingTemplate) as DataTemplate; - this.SelectedIndex = 0; + SelectedIndex = 0; } } @@ -206,7 +207,7 @@ private void GridViewColumnHeaderClickedHandler(object sender, RoutedEventArgs e private void Sort(string sortBy, ListSortDirection direction) { lastDirection = direction; - ListCollectionView dataView = CollectionViewSource.GetDefaultView(this.ItemsSource) as ListCollectionView; + ListCollectionView dataView = CollectionViewSource.GetDefaultView(ItemsSource) as ListCollectionView; if (dataView != null) { @@ -217,7 +218,7 @@ private void Sort(string sortBy, ListSortDirection direction) private void RemoveSort() { - ListCollectionView dataView = CollectionViewSource.GetDefaultView(this.ItemsSource) as ListCollectionView; + ListCollectionView dataView = CollectionViewSource.GetDefaultView(ItemsSource) as ListCollectionView; if (dataView != null) { diff --git a/SharePointLogViewer/Extensions.cs b/SharePointLogViewer/Extensions.cs index ceae0bf..ad7fec2 100644 --- a/SharePointLogViewer/Extensions.cs +++ b/SharePointLogViewer/Extensions.cs @@ -3,6 +3,8 @@ namespace SharePointLogViewer { +/* + CLASS UNUSED static class Extensions { public static void AddRange(this ObservableCollection collection, IEnumerable list) @@ -11,4 +13,5 @@ public static void AddRange(this ObservableCollection collection, IEnumera collection.Add(item); } } +*/ } diff --git a/SharePointLogViewer/Filters/ListViewFilter.cs b/SharePointLogViewer/Filters/ListViewFilter.cs index 5c3df2b..5cec3bf 100644 --- a/SharePointLogViewer/Filters/ListViewFilter.cs +++ b/SharePointLogViewer/Filters/ListViewFilter.cs @@ -6,7 +6,7 @@ class ListViewFilter: IFilter { ListView lstLog; - public ListViewFilter(System.Windows.Controls.ListView lstLog) + public ListViewFilter(ListView lstLog) { this.lstLog = lstLog; } diff --git a/SharePointLogViewer/HiglightBookmarkedValueConverter.cs b/SharePointLogViewer/HiglightBookmarkedValueConverter.cs index c5800a2..2334492 100644 --- a/SharePointLogViewer/HiglightBookmarkedValueConverter.cs +++ b/SharePointLogViewer/HiglightBookmarkedValueConverter.cs @@ -12,7 +12,7 @@ public object Convert(object[] values, Type targetType, object parameter, System bool bookmarkedAndNotSelected = false; if (values.Length == 2) - bookmarkedAndNotSelected = (bool)values[0] == true && (bool)values[1] == false; + bookmarkedAndNotSelected = (bool)values[0] && (bool)values[1] == false; return bookmarkedAndNotSelected; } diff --git a/SharePointLogViewer/LogEntryViewModel.cs b/SharePointLogViewer/LogEntryViewModel.cs index 923f233..54cb393 100644 --- a/SharePointLogViewer/LogEntryViewModel.cs +++ b/SharePointLogViewer/LogEntryViewModel.cs @@ -47,6 +47,7 @@ public string Process OnPropertyChanged("Process"); } } +/* public string TID { get { return entry.TID; } @@ -56,6 +57,8 @@ public string TID OnPropertyChanged("TID"); } } +*/ +/* public string Area { get { return entry.Area; } @@ -65,6 +68,7 @@ public string Area OnPropertyChanged("Area"); } } +*/ public string Category { get { return entry.Category; } @@ -74,6 +78,7 @@ public string Category OnPropertyChanged("Category"); } } +/* public string EventID { get { return entry.EventID; } @@ -83,6 +88,7 @@ public string EventID OnPropertyChanged("EventID"); } } +*/ public string Level { get { return entry.Level; } diff --git a/SharePointLogViewer/LogFilterListView.cs b/SharePointLogViewer/LogFilterListView.cs index 693875e..aa63734 100644 --- a/SharePointLogViewer/LogFilterListView.cs +++ b/SharePointLogViewer/LogFilterListView.cs @@ -5,9 +5,6 @@ namespace SharePointLogViewer { class LogFilterListView : FilterableListView { - protected override Type ListItemType - { - get { return typeof(LogEntryViewModel); } - } + protected override Type ListItemType => typeof(LogEntryViewModel); } } diff --git a/SharePointLogViewer/MainWindow.xaml.cs b/SharePointLogViewer/MainWindow.xaml.cs index d2021be..5cdc459 100644 --- a/SharePointLogViewer/MainWindow.xaml.cs +++ b/SharePointLogViewer/MainWindow.xaml.cs @@ -61,8 +61,8 @@ public MainWindow() lastWindowState = WindowState; logsLoader.LoadCompleted += new EventHandler(logsLoader_LoadCompleted); - this.Loaded += new RoutedEventHandler(MainWindow_Loaded); - this.Closing += new CancelEventHandler(MainWindow_Closing); + Loaded += new RoutedEventHandler(MainWindow_Loaded); + Closing += new CancelEventHandler(MainWindow_Closing); trayNotifier = new SystemTrayNotifier(); trayNotifier.Click += new EventHandler(trayIcon_Click); @@ -150,7 +150,7 @@ private void InitializeDialogs() void MainWindow_Loaded(object sender, RoutedEventArgs e) { - this.DataContext = logEntries; + DataContext = logEntries; txtFilter.AutoCompleteManager.DataProvider = new SimpleStaticDataProvider((new LogEntryTokenizer(logEntries)).Distinct()); UpdateFilter(); @@ -212,7 +212,7 @@ private void UpdateFilter() CollectionViewSource GetCollectionViewSource() { - CollectionViewSource source = (CollectionViewSource)this.Resources["FilteredCollection"]; + CollectionViewSource source = (CollectionViewSource)Resources["FilteredCollection"]; return source; } @@ -279,7 +279,7 @@ void watcher_LogEntryDiscovered(object sender, LogEntryDiscoveredEventArgs e) { var le = new LogEntryViewModel(e.LogEntry); logEntries.Add(le); - if (this.Visibility == System.Windows.Visibility.Visible) + if (Visibility == Visibility.Visible) lstLog.ScrollIntoView(le); NotifyIfRequired(le); } @@ -355,7 +355,7 @@ void StartProcessing(string message) void StopProcessing() { bdrShadow.Visibility = Visibility.Hidden; - this.Cursor = Cursors.Arrow; + Cursor = Cursors.Arrow; } private void OpenFile_CanExecute(object sender, CanExecuteRoutedEventArgs e) diff --git a/SharePointLogViewer/Monitoring/FileTail.cs b/SharePointLogViewer/Monitoring/FileTail.cs index 8ddcc79..c206ba3 100644 --- a/SharePointLogViewer/Monitoring/FileTail.cs +++ b/SharePointLogViewer/Monitoring/FileTail.cs @@ -60,7 +60,7 @@ void worker_DoWork(object sender, DoWorkEventArgs e) string data = String.Empty; while (!worker.CancellationPending) { - System.Threading.Thread.Sleep(1000); + Thread.Sleep(1000); if (reader.EndOfStream) continue; data += reader.ReadToEnd(); diff --git a/SharePointLogViewer/SPUtility.cs b/SharePointLogViewer/SPUtility.cs index 8db7980..bbd6595 100644 --- a/SharePointLogViewer/SPUtility.cs +++ b/SharePointLogViewer/SPUtility.cs @@ -182,11 +182,11 @@ public static IEnumerable GetServerNames() { Type farmType = null; - if (SPUtility.SPVersion == SPVersion.SP2007) + if (SPVersion == SPVersion.SP2007) farmType = Type.GetType("Microsoft.SharePoint.Administration.SPFarm, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"); - else if (SPUtility.SPVersion == SPVersion.SP2010) + else if (SPVersion == SPVersion.SP2010) farmType = Type.GetType("Microsoft.SharePoint.Administration.SPFarm, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"); - else if (SPUtility.SPVersion == SPVersion.SP2013) + else if (SPVersion == SPVersion.SP2013) farmType = Type.GetType("Microsoft.SharePoint.Administration.SPFarm, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"); @@ -253,11 +253,11 @@ private static string GetSPDiagnosticsLogLocation() { string logLocation = String.Empty; Type diagSvcType = null; - if (SPUtility.SPVersion == SPVersion.SP2007) + if (SPVersion == SPVersion.SP2007) diagSvcType = Type.GetType("Microsoft.SharePoint.Administration.SPDiagnosticsService, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"); - else if (SPUtility.SPVersion == SPVersion.SP2010) + else if (SPVersion == SPVersion.SP2010) diagSvcType = Type.GetType("Microsoft.SharePoint.Administration.SPDiagnosticsService, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"); - else if (SPUtility.SPVersion == SPVersion.SP2013) + else if (SPVersion == SPVersion.SP2013) diagSvcType = Type.GetType("Microsoft.SharePoint.Administration.SPDiagnosticsService, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"); if (diagSvcType != null) diff --git a/SharePointLogViewer/Searching/DynamicFilter.cs b/SharePointLogViewer/Searching/DynamicFilter.cs index 238c30a..d79c83f 100644 --- a/SharePointLogViewer/Searching/DynamicFilter.cs +++ b/SharePointLogViewer/Searching/DynamicFilter.cs @@ -64,7 +64,7 @@ class PropertyValueComparer public PropertyValueComparer(PropertyInfo property, params string[] keywords) { this.keywords = keywords; - this.fastInvoker = FastInvoke.GetMethodInvoker(property.GetGetMethod()); + fastInvoker = FastInvoke.GetMethodInvoker(property.GetGetMethod()); } public PropertyValueComparer(Type type, string propertyName, params string[] keywords) diff --git a/SharePointLogViewer/Searching/FastInvoke.cs b/SharePointLogViewer/Searching/FastInvoke.cs index 4f341ca..9753430 100644 --- a/SharePointLogViewer/Searching/FastInvoke.cs +++ b/SharePointLogViewer/Searching/FastInvoke.cs @@ -111,7 +111,7 @@ public static FastMethodInvoker GetMethodInvoker(MethodInfo methodInfo) } private static void EmitCastToReference(ILGenerator il, - System.Type type) + Type type) { if (type.IsValueType) { @@ -123,7 +123,7 @@ private static void EmitCastToReference(ILGenerator il, } } - private static void EmitBoxIfNeeded(ILGenerator il, System.Type type) + private static void EmitBoxIfNeeded(ILGenerator il, Type type) { if (type.IsValueType) { @@ -180,7 +180,7 @@ private static void EmitFastInt(ILGenerator il, int value) public object TypeConvert(object source, Type DestType) { - object NewObject = System.Convert.ChangeType(source, DestType); + object NewObject = Convert.ChangeType(source, DestType); return (NewObject); } diff --git a/SharePointLogViewer/Searching/LogEntryTokenizer.cs b/SharePointLogViewer/Searching/LogEntryTokenizer.cs index 75b48ad..82fc117 100644 --- a/SharePointLogViewer/Searching/LogEntryTokenizer.cs +++ b/SharePointLogViewer/Searching/LogEntryTokenizer.cs @@ -30,7 +30,7 @@ public IEnumerator GetEnumerator() System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { - return this.GetEnumerator(); + return GetEnumerator(); } #endregion diff --git a/SharePointLogViewer/Searching/OverflowCollection.cs b/SharePointLogViewer/Searching/OverflowCollection.cs index c07be8e..d0eb9a5 100644 --- a/SharePointLogViewer/Searching/OverflowCollection.cs +++ b/SharePointLogViewer/Searching/OverflowCollection.cs @@ -23,7 +23,7 @@ public void AddRange(IEnumerable collection) { deferNotification = true; foreach (T itm in collection) - this.Add(itm); + Add(itm); deferNotification = false; OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); } @@ -34,7 +34,7 @@ protected override void InsertItem(int index, T item) T removeItem = default(T); if (MaxItems > 0 && Count == MaxItems) - foreach (var target in base.Items) + foreach (var target in Items) if (evictionCriterea(target)) { removeItem = target; @@ -44,7 +44,7 @@ protected override void InsertItem(int index, T item) base.InsertItem(index, item); if (itemFound) - base.Remove(removeItem); + Remove(removeItem); } protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e) diff --git a/SharePointLogViewer/SettingBinding.cs b/SharePointLogViewer/SettingBinding.cs index 013aa00..0a8add4 100644 --- a/SharePointLogViewer/SettingBinding.cs +++ b/SharePointLogViewer/SettingBinding.cs @@ -11,8 +11,8 @@ public SettingBinding(string path): base(path) private void Initialize() { - this.Source = SharePointLogViewer.Properties.Settings.Default; - this.Mode = BindingMode.TwoWay; + Source = Properties.Settings.Default; + Mode = BindingMode.TwoWay; } } } diff --git a/SharePointLogViewer/SettingsViewModel.cs b/SharePointLogViewer/SettingsViewModel.cs index ebae61b..e95edee 100644 --- a/SharePointLogViewer/SettingsViewModel.cs +++ b/SharePointLogViewer/SettingsViewModel.cs @@ -25,7 +25,7 @@ class GeneralSettingsViewModel public bool RunAtStartup { get; set; } public bool HideToSystemTray { get; set; } public int LiveLimit { get; set; } - public List Columns { get; private set; } + public List Columns { get; } public GeneralSettingsViewModel() { @@ -35,9 +35,6 @@ public GeneralSettingsViewModel() class NotificationSettingsViewModel { - public NotificationSettingsViewModel() - { - } public bool EnableSystemTrayNotification { get; set; } public bool EnableEmailNotification { get; set; } public bool EnableEventLogNotification { get; set; } diff --git a/SharePointLogViewer/SettingsWindow.xaml.cs b/SharePointLogViewer/SettingsWindow.xaml.cs index e2976bd..289c9aa 100644 --- a/SharePointLogViewer/SettingsWindow.xaml.cs +++ b/SharePointLogViewer/SettingsWindow.xaml.cs @@ -25,7 +25,7 @@ private void Window_Loaded(object sender, RoutedEventArgs e) { LoadGeneralSettings(); LoadNotificationSettings(); - this.DataContext = settingsVm; + DataContext = settingsVm; } private void LoadNotificationSettings() @@ -69,7 +69,7 @@ private void btnOK_Click(object sender, RoutedEventArgs e) { SaveGeneralSettings(); SaveNotificationSettings(); - this.DialogResult = true; + DialogResult = true; Close(); } From e1db2f59d42d1d0907c2a12463ae0c9c8d4ef3eb Mon Sep 17 00:00:00 2001 From: Valentin LECERF Date: Sun, 27 Jan 2019 20:00:09 +0100 Subject: [PATCH 8/9] Commented unused method --- SharePointLogViewer/SPUtility.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/SharePointLogViewer/SPUtility.cs b/SharePointLogViewer/SPUtility.cs index bbd6595..78e0369 100644 --- a/SharePointLogViewer/SPUtility.cs +++ b/SharePointLogViewer/SPUtility.cs @@ -77,6 +77,7 @@ public static bool IsWSSInstalled } } +/* public static bool IsMOSSInstalled { get @@ -99,6 +100,7 @@ public static bool IsMOSSInstalled return false; } } +*/ public static string LatestLogFile { @@ -137,7 +139,7 @@ public static ICollection TraceSeverities public static string GetLogsLocation() { - string logLocation = String.Empty; + string logLocation = string.Empty; if (IsWSSInstalled) { @@ -205,6 +207,7 @@ public static IEnumerable GetServerNames() } } +/* static RegistryKey GetMOSSRegistryKey() { RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Office Server\12.0"); @@ -214,14 +217,13 @@ static RegistryKey GetMOSSRegistryKey() key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Office Server\15.0"); return key; } +*/ static RegistryKey GetWSSRegistryKey() { - RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\15.0"); - if (key == null) - key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0"); - else if (key == null) - key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0"); + RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\15.0") ?? + Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0"); + return key; } From 830c6654e0551043514ee141359ae728053cd808 Mon Sep 17 00:00:00 2001 From: Valentin LECERF Date: Sun, 27 Jan 2019 20:11:17 +0100 Subject: [PATCH 9/9] Code enhancements --- .../AutoCompleteManager.cs | 21 ++- .../AutoCompleteTextBox.cs | 2 +- .../Controls/BaseWPFHelpers.cs | 51 ++---- .../Controls/FilterableListView.cs | 47 +++--- .../Controls/LoadingAnimation.xaml.cs | 6 +- .../Controls/SortableGridViewColumn.cs | 14 +- .../Controls/SortableListView.cs | 146 +++++++++++------- SharePointLogViewer/LogEntryViewModel.cs | 18 ++- SharePointLogViewer/MainWindow.xaml.cs | 30 ++-- SharePointLogViewer/Monitoring/FileTail.cs | 17 +- .../Monitoring/LogDirectoryWatcher.cs | 2 +- SharePointLogViewer/Monitoring/LogMonitor.cs | 6 +- SharePointLogViewer/Monitoring/LogsLoader.cs | 10 +- .../Monitoring/MultiLogMonitor.cs | 4 +- .../Notifiers/EmailNotifier.cs | 6 +- .../Notifiers/SystemTrayNotifier.cs | 4 +- SharePointLogViewer/SPUtility.cs | 61 ++++---- .../Searching/BookmarkNavigator.cs | 5 +- .../Searching/DynamicFilter.cs | 6 +- SharePointLogViewer/Searching/FastInvoke.cs | 8 +- SharePointLogViewer/ValueConverter.cs | 21 +-- 21 files changed, 244 insertions(+), 241 deletions(-) diff --git a/SharePointLogViewer/Controls/AutoCompleteTextBox/AutoCompleteManager.cs b/SharePointLogViewer/Controls/AutoCompleteTextBox/AutoCompleteManager.cs index 735cceb..e111177 100644 --- a/SharePointLogViewer/Controls/AutoCompleteTextBox/AutoCompleteManager.cs +++ b/SharePointLogViewer/Controls/AutoCompleteTextBox/AutoCompleteManager.cs @@ -45,13 +45,13 @@ public class AutoCompleteManager public IAutoCompleteDataProvider DataProvider { - get { return _dataProvider; } - set { _dataProvider = value; } + get => _dataProvider; + set => _dataProvider = value; } public bool Disabled { - get { return _disabled; } + get => _disabled; set { _disabled = value; @@ -62,10 +62,7 @@ public bool Disabled } } - public bool AutoCompleting - { - get { return _popup.IsOpen; } - } + public bool AutoCompleting => _popup.IsOpen; public AutoCompleteManager() { @@ -206,8 +203,8 @@ private void TextBox_TextChanged(object sender, TextChangedEventArgs e) popupDelay = new Timer(_ => { var dispatcher = Application.Current.Dispatcher; - string text = (string)dispatcher.Invoke(new Func(() => GetWordUnderCursor())); - if (String.IsNullOrEmpty(text)) + string text = (string)dispatcher.Invoke(() => GetWordUnderCursor()); + if (string.IsNullOrEmpty(text)) dispatcher.Invoke((Action)(() => _popup.IsOpen = false)); else { @@ -463,7 +460,7 @@ private IntPtr HookHandler(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, r private bool PopupOnTop { - get { return _popupOnTop; } + get => _popupOnTop; set { if (_popupOnTop == value) @@ -548,8 +545,8 @@ private void UpdateText(string text, bool selectAll) int start, end; GetWordUnderCursor(out start, out end); - string prefix = start < _textBeforeChangedByCode.Length ? _textBeforeChangedByCode.Substring(0, start) : String.Empty; - string suffix = end < _textBeforeChangedByCode.Length ? _textBeforeChangedByCode.Substring(end + 1) : String.Empty; + string prefix = start < _textBeforeChangedByCode.Length ? _textBeforeChangedByCode.Substring(0, start) : string.Empty; + string suffix = end < _textBeforeChangedByCode.Length ? _textBeforeChangedByCode.Substring(end + 1) : string.Empty; _textChangedByCode = true; Debug.Print("@@@@@@@" + text); diff --git a/SharePointLogViewer/Controls/AutoCompleteTextBox/AutoCompleteTextBox.cs b/SharePointLogViewer/Controls/AutoCompleteTextBox/AutoCompleteTextBox.cs index a3806e5..e3ed15c 100644 --- a/SharePointLogViewer/Controls/AutoCompleteTextBox/AutoCompleteTextBox.cs +++ b/SharePointLogViewer/Controls/AutoCompleteTextBox/AutoCompleteTextBox.cs @@ -11,7 +11,7 @@ public class AutoCompleteTextBox : TextBox public AutoCompleteTextBox() { AutoCompleteManager = new AutoCompleteManager(); - AutoCompleteManager.DataProvider = new SimpleStaticDataProvider(Enumerable.Empty()); + AutoCompleteManager.DataProvider = new SimpleStaticDataProvider(Enumerable.Empty()); Loaded += AutoCompleteTextBox_Loaded; } diff --git a/SharePointLogViewer/Controls/BaseWPFHelpers.cs b/SharePointLogViewer/Controls/BaseWPFHelpers.cs index 6f46c09..1ce4622 100644 --- a/SharePointLogViewer/Controls/BaseWPFHelpers.cs +++ b/SharePointLogViewer/Controls/BaseWPFHelpers.cs @@ -67,8 +67,8 @@ bool StopAfterFirst /// public class FinderMatchType : IFinderMatchVisualHelper { - private Type _ty = null; - private bool _stopafterfirst = false; + private Type _ty; + private bool _stopafterfirst; public FinderMatchType(Type ty) { @@ -88,14 +88,8 @@ public bool DoesMatch(DependencyObject item) public bool StopAfterFirst { - get - { - return _stopafterfirst; - } - set - { - _stopafterfirst = value; - } + get => _stopafterfirst; + set => _stopafterfirst = value; } } @@ -104,9 +98,9 @@ public bool StopAfterFirst /// public class FinderMatchName : IFinderMatchVisualHelper { - private String _name = ""; + private string _name = ""; - public FinderMatchName(String name) + public FinderMatchName(string name) { _name = name; } @@ -128,10 +122,7 @@ public bool DoesMatch(DependencyObject item) /// public bool StopAfterFirst { - get - { - return true; - } + get => true; set { } @@ -160,10 +151,7 @@ public bool DoesMatch(DependencyObject item) /// public bool StopAfterFirst { - get - { - return true; - } + get => true; set { } @@ -193,10 +181,7 @@ public bool DoesMatch(DependencyObject item) /// public bool StopAfterFirst { - get - { - return true; - } + get => true; set { } @@ -339,11 +324,9 @@ public static void FindUpInTree(List lst, Visual parent, Visua else { // Ok, now try to get a new parent... - FrameworkElement feCast = parent as FrameworkElement; - if (feCast != null) + if (parent is FrameworkElement feCast) { - FrameworkElement feNewParent = feCast.Parent as FrameworkElement; - if (feNewParent == null || feNewParent == feCast) + if (!(feCast.Parent is FrameworkElement feNewParent) || feNewParent == feCast) { // Try to get the templated parent feNewParent = feCast.TemplatedParent as FrameworkElement; @@ -403,9 +386,7 @@ public static void TurnOffMediaElements(Visual parent) foreach (FrameworkElement me in lst) { - MediaElement meCast = me as MediaElement; - - if (meCast != null) + if (me is MediaElement meCast) { if (meCast.CanPause) { @@ -432,9 +413,7 @@ public static void TurnOnMediaElements(Visual parent) foreach (FrameworkElement me in lst) { - MediaElement meCast = me as MediaElement; - - if (meCast != null) + if (me is MediaElement meCast) { try { @@ -474,7 +453,7 @@ public static FrameworkElement FindItemsHost(Visual parent) /// /// /// - public static FrameworkElement FindVisualElement(Visual parent, String ElementName) + public static FrameworkElement FindVisualElement(Visual parent, string ElementName) { return SingleFindDownInTree(parent, new FinderMatchName(ElementName)); } @@ -485,7 +464,7 @@ public static FrameworkElement FindVisualElement(Visual parent, String ElementNa /// /// /// - public static FrameworkElement FindVisualElementUp(Visual parent, String ElementName) + public static FrameworkElement FindVisualElementUp(Visual parent, string ElementName) { return SingleFindInTree(parent, new FinderMatchName(ElementName)); } diff --git a/SharePointLogViewer/Controls/FilterableListView.cs b/SharePointLogViewer/Controls/FilterableListView.cs index d60f730..99f462f 100644 --- a/SharePointLogViewer/Controls/FilterableListView.cs +++ b/SharePointLogViewer/Controls/FilterableListView.cs @@ -25,8 +25,8 @@ public abstract class FilterableListView : SortableListView /// public Style FilterButtonActiveStyle { - get { return (Style)GetValue(FilterButtonActiveStyleProperty); } - set { SetValue(FilterButtonActiveStyleProperty, value); } + get => (Style)GetValue(FilterButtonActiveStyleProperty); + set => SetValue(FilterButtonActiveStyleProperty, value); } public static readonly DependencyProperty FilterButtonActiveStyleProperty = @@ -37,8 +37,8 @@ public Style FilterButtonActiveStyle /// public Style FilterButtonInactiveStyle { - get { return (Style)GetValue(FilterButtonInactiveStyleProperty); } - set { SetValue(FilterButtonInactiveStyleProperty, value); } + get => (Style)GetValue(FilterButtonInactiveStyleProperty); + set => SetValue(FilterButtonInactiveStyleProperty, value); } public static readonly DependencyProperty FilterButtonInactiveStyleProperty = @@ -88,20 +88,20 @@ class FilterItem : IComparable public string Item { - get { return item; } - set { item = value; } + get => item; + set => item = value; } /// /// The item viewed in the filter drop down list. Typically this is the same as the item /// property, however if item is null, this has the value of "[empty]" /// - private Object itemView; + private object itemView; - public Object ItemView + public object ItemView { - get { return itemView; } - set { itemView = value; } + get => itemView; + set => itemView = value; } public FilterItem(IComparable item) @@ -128,9 +128,8 @@ public override bool Equals(object obj) { if (obj == null) return false; - - FilterItem otherItem = obj as FilterItem; - if (otherItem != null) + + if (obj is FilterItem otherItem) return item == otherItem.item; return base.Equals(obj); @@ -154,7 +153,7 @@ public int CompareTo(object obj) Predicate extraFilter; public Predicate ExtraFilter { - get { return extraFilter; } + get => extraFilter; set { extraFilter = value; @@ -164,14 +163,14 @@ public Predicate ExtraFilter Dictionary currentFilters = new Dictionary(); - private void AddFilter(String property, FilterItem value, Button button) + private void AddFilter(string property, FilterItem value, Button button) { var descriptor = TypeDescriptor.GetProperties(ListItemType)[property]; var filter = new FilterStruct(descriptor, button, value); currentFilters[property] = filter; } - protected bool IsPropertyFiltered(String property) + protected bool IsPropertyFiltered(string property) { return currentFilters.ContainsKey(property); } @@ -189,14 +188,12 @@ protected override void OnInitialized(EventArgs e) dictionary = Application.LoadComponent(uri) as ResourceDictionary; // cast the ListView's View to a GridView - GridView gridView = View as GridView; - if (gridView != null) + if (View is GridView gridView) { // apply the data template, that includes the popup, button etc ... to each column foreach (GridViewColumn gridViewColumn in gridView.Columns) { - SortableGridViewColumn sc = gridViewColumn as SortableGridViewColumn; - if (sc != null && sc.CanBeFiltered) + if (gridViewColumn is SortableGridViewColumn sc && sc.CanBeFiltered) gridViewColumn.HeaderTemplate = (DataTemplate)dictionary["FilterGridHeaderTemplate"]; else gridViewColumn.HeaderTemplate = (DataTemplate)dictionary["SortableGridHeaderTemplate"]; @@ -233,9 +230,7 @@ public override void OnApplyTemplate() /// private void ShowFilterCommand(object sender, ExecutedRoutedEventArgs e) { - Button button = e.OriginalSource as Button; - - if (button != null) + if (e.OriginalSource is Button button) { // navigate up to the header GridViewColumnHeader header = (GridViewColumnHeader)Helpers.FindElementOfTypeUp(button, typeof(GridViewColumnHeader)); @@ -246,7 +241,7 @@ private void ShowFilterCommand(object sender, ExecutedRoutedEventArgs e) if (popup != null) { SortableGridViewColumn column = (SortableGridViewColumn)header.Column; - String propertyName = column.SortPropertyName; + string propertyName = column.SortPropertyName; var filterList = new List(); @@ -259,7 +254,7 @@ private void ShowFilterCommand(object sender, ExecutedRoutedEventArgs e) bool containsNull = false; PropertyDescriptor filterPropDesc = TypeDescriptor.GetProperties(ListItemType)[propertyName]; - foreach (Object item in Items) + foreach (object item in Items) { object value = filterPropDesc.GetValue(item); if (value != null) @@ -324,7 +319,7 @@ protected void SelectionChangedHandler(object sender, SelectionChangedEventArgs GridViewColumnHeader header = (GridViewColumnHeader)Helpers.FindElementOfTypeUp(filterListView, typeof(GridViewColumnHeader)); SortableGridViewColumn column = (SortableGridViewColumn)header.Column; - String currentFilterProperty = column.SortPropertyName; + string currentFilterProperty = column.SortPropertyName; if (!column.CanBeFiltered) { diff --git a/SharePointLogViewer/Controls/LoadingAnimation.xaml.cs b/SharePointLogViewer/Controls/LoadingAnimation.xaml.cs index 34f9d05..79ac85e 100644 --- a/SharePointLogViewer/Controls/LoadingAnimation.xaml.cs +++ b/SharePointLogViewer/Controls/LoadingAnimation.xaml.cs @@ -9,12 +9,12 @@ namespace SharePointLogViewer.Controls /// public partial class LoadingAnimation : UserControl { - public static readonly DependencyProperty MessageProperty = DependencyProperty.Register("Message", typeof(String), typeof(LoadingAnimation), new PropertyMetadata("Loading...")); + public static readonly DependencyProperty MessageProperty = DependencyProperty.Register("Message", typeof(string), typeof(LoadingAnimation), new PropertyMetadata("Loading...")); public string Message { - get { return (string)GetValue(MessageProperty); } - set { SetValue(MessageProperty, value); } + get => (string)GetValue(MessageProperty); + set => SetValue(MessageProperty, value); } public LoadingAnimation() diff --git a/SharePointLogViewer/Controls/SortableGridViewColumn.cs b/SharePointLogViewer/Controls/SortableGridViewColumn.cs index fe8f125..dc58f3d 100644 --- a/SharePointLogViewer/Controls/SortableGridViewColumn.cs +++ b/SharePointLogViewer/Controls/SortableGridViewColumn.cs @@ -13,8 +13,8 @@ public class SortableGridViewColumn : GridViewColumn public string SortPropertyName { - get { return (string)GetValue(SortPropertyNameProperty); } - set { SetValue(SortPropertyNameProperty, value); } + get => (string)GetValue(SortPropertyNameProperty); + set => SetValue(SortPropertyNameProperty, value); } // Using a DependencyProperty as the backing store for SortPropertyName. This enables animation, styling, binding, etc... @@ -23,8 +23,8 @@ public string SortPropertyName public bool IsDefaultSortColumn { - get { return (bool)GetValue(IsDefaultSortColumnProperty); } - set { SetValue(IsDefaultSortColumnProperty, value); } + get => (bool)GetValue(IsDefaultSortColumnProperty); + set => SetValue(IsDefaultSortColumnProperty, value); } public static readonly DependencyProperty IsDefaultSortColumnProperty = @@ -32,8 +32,8 @@ public bool IsDefaultSortColumn public bool CanBeFiltered { - get { return (bool)GetValue(CanBeFilteredColumnProperty); } - set { SetValue(CanBeFilteredColumnProperty, value); } + get => (bool)GetValue(CanBeFilteredColumnProperty); + set => SetValue(CanBeFilteredColumnProperty, value); } public static readonly DependencyProperty CanBeFilteredColumnProperty = @@ -41,7 +41,7 @@ public bool CanBeFiltered public bool Visible { - get { return (bool)GetValue(VisibleProperty); } + get => (bool)GetValue(VisibleProperty); set { if (Visible ^ value) diff --git a/SharePointLogViewer/Controls/SortableListView.cs b/SharePointLogViewer/Controls/SortableListView.cs index fa89356..aac8f12 100644 --- a/SharePointLogViewer/Controls/SortableListView.cs +++ b/SharePointLogViewer/Controls/SortableListView.cs @@ -1,11 +1,11 @@ -using System; -using System.Windows.Controls; -using System.Windows; -using System.ComponentModel; -using System.Windows.Data; +using SharePointLogViewer.Searching; +using System; using System.Collections; +using System.ComponentModel; +using System.Windows; +using System.Windows.Controls; using System.Windows.Controls.Primitives; -using SharePointLogViewer.Searching; +using System.Windows.Data; // SortableListView, from the following blog post: // @@ -18,8 +18,8 @@ namespace SharePointLogViewer.Controls /// public class SortableListView : ListView { - SortableGridViewColumn lastSortedOnColumn = null; - GridViewColumnHeader lastSortedOnColumnHeader = null; + SortableGridViewColumn lastSortedOnColumn; + GridViewColumnHeader lastSortedOnColumnHeader; ListSortDirection? lastDirection = ListSortDirection.Ascending; protected ResourceDictionary dictionary; @@ -29,8 +29,8 @@ public class SortableListView : ListView public string ColumnHeaderSortedAscendingTemplate { - get { return (string)GetValue(ColumnHeaderSortedAscendingTemplateProperty); } - set { SetValue(ColumnHeaderSortedAscendingTemplateProperty, value); } + get => (string)GetValue(ColumnHeaderSortedAscendingTemplateProperty); + set => SetValue(ColumnHeaderSortedAscendingTemplateProperty, value); } // Using a DependencyProperty as the backing store for ColumnHeaderSortedAscendingTemplate. This enables animation, styling, binding, etc... @@ -40,8 +40,8 @@ public string ColumnHeaderSortedAscendingTemplate public string ColumnHeaderSortedDescendingTemplate { - get { return (string)GetValue(ColumnHeaderSortedDescendingTemplateProperty); } - set { SetValue(ColumnHeaderSortedDescendingTemplateProperty, value); } + get => (string)GetValue(ColumnHeaderSortedDescendingTemplateProperty); + set => SetValue(ColumnHeaderSortedDescendingTemplateProperty, value); } @@ -52,8 +52,8 @@ public string ColumnHeaderSortedDescendingTemplate public string ColumnHeaderNotSortedTemplate { - get { return (string)GetValue(ColumnHeaderNotSortedTemplateProperty); } - set { SetValue(ColumnHeaderNotSortedTemplateProperty, value); } + get => (string)GetValue(ColumnHeaderNotSortedTemplateProperty); + set => SetValue(ColumnHeaderNotSortedTemplateProperty, value); } @@ -77,8 +77,7 @@ protected override void OnInitialized(EventArgs e) AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(GridViewColumnHeaderClickedHandler)); // cast the ListView's View to a GridView - GridView gridView = View as GridView; - if (gridView != null) + if (View is GridView gridView) { // determine which column is marked as IsDefaultSortColumn. Stops on the first column marked this way. SortableGridViewColumn sortableGridViewColumn = null; @@ -87,14 +86,17 @@ protected override void OnInitialized(EventArgs e) gridViewColumn.HeaderTemplate = (DataTemplate)dictionary["SortableGridHeaderTemplate"]; sortableGridViewColumn = gridViewColumn as SortableGridViewColumn; - + if (sortableGridViewColumn != null) { if (sortableGridViewColumn.IsDefaultSortColumn) + { break; + } + sortableGridViewColumn = null; } - + } // if the default sort column is defined, sort the data and then update the templates as necessary. @@ -103,8 +105,10 @@ protected override void OnInitialized(EventArgs e) lastSortedOnColumn = sortableGridViewColumn; Sort(sortableGridViewColumn.SortPropertyName, ListSortDirection.Ascending); - if (!String.IsNullOrEmpty(ColumnHeaderSortedAscendingTemplate)) + if (!string.IsNullOrEmpty(ColumnHeaderSortedAscendingTemplate)) + { sortableGridViewColumn.HeaderTemplate = TryFindResource(ColumnHeaderSortedAscendingTemplate) as DataTemplate; + } SelectedIndex = 0; } @@ -123,36 +127,39 @@ private void GridViewColumnHeaderClickedHandler(object sender, RoutedEventArgs e { Uri uri = new Uri("/Controls/FiterListViewDictionary.xaml", UriKind.Relative); ResourceDictionary dictionary = Application.LoadComponent(uri) as ResourceDictionary; - - GridViewColumnHeader headerClicked = e.OriginalSource as GridViewColumnHeader; // ensure that we clicked on the column header and not the padding that's added to fill the space. - if (headerClicked != null && headerClicked.Role != GridViewColumnHeaderRole.Padding) + if (e.OriginalSource is GridViewColumnHeader headerClicked && headerClicked.Role != GridViewColumnHeaderRole.Padding) { // attempt to cast to the sortableGridViewColumn object. - SortableGridViewColumn sortableGridViewColumn = (headerClicked.Column) as SortableGridViewColumn; // ensure that the column header is the correct type and a sort property has been set. - if (sortableGridViewColumn != null && !String.IsNullOrEmpty(sortableGridViewColumn.SortPropertyName)) + if ((headerClicked.Column) is SortableGridViewColumn sortableGridViewColumn && !string.IsNullOrEmpty(sortableGridViewColumn.SortPropertyName)) { ListSortDirection? direction; // determine if this is a new sort, or a switch in sort direction. if (lastSortedOnColumn == null - || String.IsNullOrEmpty(lastSortedOnColumn.SortPropertyName) - || !String.Equals(sortableGridViewColumn.SortPropertyName, lastSortedOnColumn.SortPropertyName, StringComparison.InvariantCultureIgnoreCase)) + || string.IsNullOrEmpty(lastSortedOnColumn.SortPropertyName) + || !string.Equals(sortableGridViewColumn.SortPropertyName, lastSortedOnColumn.SortPropertyName, StringComparison.InvariantCultureIgnoreCase)) { direction = ListSortDirection.Ascending; } else { if (lastDirection == ListSortDirection.Ascending) + { direction = ListSortDirection.Descending; + } else if (lastDirection == ListSortDirection.Descending) - direction = null; + { + direction = null; + } else + { direction = ListSortDirection.Ascending; + } } @@ -161,27 +168,39 @@ private void GridViewColumnHeaderClickedHandler(object sender, RoutedEventArgs e // Sort the data. if (direction == null) + { RemoveSort(); + } else - Sort(sortPropertyName, direction.Value); + { + Sort(sortPropertyName, direction.Value); + } Label sortIndicator = (Label)Helpers.SingleFindDownInTree(headerClicked, new Helpers.FinderMatchName("sortIndicator")); - - if (direction == null) - sortIndicator.Style = (Style)dictionary["HeaderTemplateTransparent"]; - if (direction == ListSortDirection.Ascending) - sortIndicator.Style = (Style)dictionary["HeaderTemplateArrowUp"]; - else if(direction == ListSortDirection.Descending) - sortIndicator.Style = (Style)dictionary["HeaderTemplateArrowDown"]; - + if (dictionary != null) + { + if (direction == null) + { + sortIndicator.Style = (Style)dictionary["HeaderTemplateTransparent"]; + } + + if (direction == ListSortDirection.Ascending) + { + sortIndicator.Style = (Style)dictionary["HeaderTemplateArrowUp"]; + } + else if (direction == ListSortDirection.Descending) + { + sortIndicator.Style = (Style)dictionary["HeaderTemplateArrowDown"]; + } + } // Remove arrow from previously sorted header - if (lastSortedOnColumnHeader != null && lastSortedOnColumnHeader!=headerClicked) + if (lastSortedOnColumnHeader != null && lastSortedOnColumnHeader != headerClicked) { sortIndicator = (Label)Helpers.SingleFindDownInTree(lastSortedOnColumnHeader, new Helpers.FinderMatchName("sortIndicator")); - sortIndicator.Style = (Style)dictionary["HeaderTemplateTransparent"]; + if (dictionary != null) sortIndicator.Style = (Style) dictionary["HeaderTemplateTransparent"]; } if (direction == null) @@ -207,9 +226,8 @@ private void GridViewColumnHeaderClickedHandler(object sender, RoutedEventArgs e private void Sort(string sortBy, ListSortDirection direction) { lastDirection = direction; - ListCollectionView dataView = CollectionViewSource.GetDefaultView(ItemsSource) as ListCollectionView; - if (dataView != null) + if (CollectionViewSource.GetDefaultView(ItemsSource) is ListCollectionView dataView) { dataView.CustomSort = new ListSorter(sortBy, direction); dataView.Refresh(); @@ -217,21 +235,19 @@ private void Sort(string sortBy, ListSortDirection direction) } private void RemoveSort() - { - ListCollectionView dataView = CollectionViewSource.GetDefaultView(ItemsSource) as ListCollectionView; - - if (dataView != null) + { + if (CollectionViewSource.GetDefaultView(ItemsSource) is ListCollectionView dataView) { dataView.CustomSort = null; dataView.Refresh(); } } - class ListSorter: IComparer + class ListSorter : IComparer { FastMethodInvoker fastInvoker; - string sortBy; - ListSortDirection direction; + readonly string sortBy; + readonly ListSortDirection direction; public ListSorter(string sortBy, ListSortDirection direction) { @@ -245,20 +261,34 @@ public int Compare(object x, object y) { if (fastInvoker == null) { - var propInfo = x.GetType().GetProperty(sortBy); - fastInvoker = FastInvoke.GetMethodInvoker(propInfo.GetGetMethod()); + if (x != null) + { + var propInfo = x.GetType().GetProperty(sortBy); + fastInvoker = FastInvoke.GetMethodInvoker(propInfo.GetGetMethod()); + } } - var x1 = fastInvoker.Invoke(x, null) as IComparable; - var y1 = fastInvoker.Invoke(y, null) as IComparable; - if (x1 == null || y1 == null) - return 0; - else + + if (fastInvoker != null) { - var result = x1.CompareTo(y1); - if (direction == ListSortDirection.Descending) - result = -result; - return result; + var x1 = fastInvoker.Invoke(x, null) as IComparable; + var y1 = fastInvoker.Invoke(y, null) as IComparable; + if (x1 == null || y1 == null) + { + return 0; + } + else + { + var result = x1.CompareTo(y1); + if (direction == ListSortDirection.Descending) + { + result = -result; + } + + return result; + } } + + return 0; } #endregion diff --git a/SharePointLogViewer/LogEntryViewModel.cs b/SharePointLogViewer/LogEntryViewModel.cs index 54cb393..d8ba36d 100644 --- a/SharePointLogViewer/LogEntryViewModel.cs +++ b/SharePointLogViewer/LogEntryViewModel.cs @@ -21,7 +21,7 @@ public LogEntryViewModel(LogEntry entry) public bool Bookmarked { - get { return bookmarked; } + get => bookmarked; set { bookmarked = value; @@ -29,18 +29,20 @@ public bool Bookmarked } } +/* public string Timestamp { - get { return entry.Timestamp; } + get => entry.Timestamp; set { entry.Timestamp = value; OnPropertyChanged("Timestamp"); } } +*/ public string Process { - get { return entry.Process; } + get => entry.Process; set { entry.Process = value; @@ -71,7 +73,7 @@ public string Area */ public string Category { - get { return entry.Category; } + get => entry.Category; set { entry.Category = value; @@ -91,7 +93,7 @@ public string EventID */ public string Level { - get { return entry.Level; } + get => entry.Level; set { entry.Level = value; @@ -100,7 +102,7 @@ public string Level } public string Message { - get { return entry.Message; } + get => entry.Message; set { entry.Message = value; @@ -108,15 +110,17 @@ public string Message } } +/* public string Correlation { - get { return entry.Correlation; } + get => entry.Correlation; set { entry.Correlation = value; OnPropertyChanged("Correlation"); } } +*/ void OnPropertyChanged(string propertyName) { diff --git a/SharePointLogViewer/MainWindow.xaml.cs b/SharePointLogViewer/MainWindow.xaml.cs index 5cdc459..8dec66c 100644 --- a/SharePointLogViewer/MainWindow.xaml.cs +++ b/SharePointLogViewer/MainWindow.xaml.cs @@ -26,7 +26,7 @@ public partial class MainWindow : Window OverflowCollection logEntries = new OverflowCollection(le=>!le.Bookmarked); LogsLoader logsLoader = new LogsLoader(); - ILogMonitor logMonitor = null; + ILogMonitor logMonitor; DynamicFilter filter; bool liveMode; OpenFileDialog openDialog; @@ -59,12 +59,12 @@ public MainWindow() WindowState = WindowState.Maximized; lastWindowState = WindowState; - logsLoader.LoadCompleted += new EventHandler(logsLoader_LoadCompleted); + logsLoader.LoadCompleted += logsLoader_LoadCompleted; - Loaded += new RoutedEventHandler(MainWindow_Loaded); - Closing += new CancelEventHandler(MainWindow_Closing); + Loaded += MainWindow_Loaded; + Closing += MainWindow_Closing; trayNotifier = new SystemTrayNotifier(); - trayNotifier.Click += new EventHandler(trayIcon_Click); + trayNotifier.Click += trayIcon_Click; bookmarkNavigator = new BookmarkNavigator(lstLog, ()=>GetCollectionViewSource().View); @@ -85,7 +85,7 @@ public MainWindow() else { showMinimizeToolTip = true; - if (!String.IsNullOrEmpty(App.FileToOpen)) + if (!string.IsNullOrEmpty(App.FileToOpen)) { files = new string[] { App.FileToOpen }; LoadFiles(); @@ -102,9 +102,9 @@ void MainWindow_Closing(object sender, CancelEventArgs e) void LoadSettings() { - if (Properties.Settings.Default.EnableEmailNotifications && !(String.IsNullOrEmpty(Properties.Settings.Default.EmailSenders) || - String.IsNullOrEmpty(Properties.Settings.Default.EmailRecepients) || - String.IsNullOrEmpty(Properties.Settings.Default.EmailSmtpServer))) + if (Properties.Settings.Default.EnableEmailNotifications && !(string.IsNullOrEmpty(Properties.Settings.Default.EmailSenders) || + string.IsNullOrEmpty(Properties.Settings.Default.EmailRecepients) || + string.IsNullOrEmpty(Properties.Settings.Default.EmailSmtpServer))) { INotifier notifier = new EmailNotifier(Properties.Settings.Default.EmailSenders, Properties.Settings.Default.EmailRecepients, @@ -158,7 +158,7 @@ void MainWindow_Loaded(object sender, RoutedEventArgs e) if (SPUtility.IsWSSInstalled) { - if (String.IsNullOrEmpty(Properties.Settings.Default.LastDirectory)) + if (string.IsNullOrEmpty(Properties.Settings.Default.LastDirectory)) lastDirectory = SPUtility.GetLogsLocation(); else lastDirectory = Properties.Settings.Default.LastDirectory; @@ -166,7 +166,7 @@ void MainWindow_Loaded(object sender, RoutedEventArgs e) else lastDirectory = Properties.Settings.Default.LastDirectory; - if (!String.IsNullOrEmpty(lastDirectory) && Directory.Exists(lastDirectory)) + if (!string.IsNullOrEmpty(lastDirectory) && Directory.Exists(lastDirectory)) Environment.CurrentDirectory = lastDirectory; } @@ -311,7 +311,7 @@ void StartLiveMonitoring() else logMonitor = new LogMonitor(folderPath); - logMonitor.LogEntryDiscovered += new EventHandler(watcher_LogEntryDiscovered); + logMonitor.LogEntryDiscovered += watcher_LogEntryDiscovered; if (files.Length > 0) Reset(); @@ -397,8 +397,7 @@ private void Window_Closing(object sender, CancelEventArgs e) private void lvCopyCommand_Executed(object sender, ExecutedRoutedEventArgs e) { - var logEntry = lstLog.SelectedItem as LogEntryViewModel; - if (logEntry != null) + if (lstLog.SelectedItem is LogEntryViewModel logEntry) Clipboard.SetText(LogExporter.Format(logEntry)); } @@ -443,8 +442,7 @@ private void img_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) private void ToggleLogEntryBookmark() { - LogEntryViewModel selected = lstLog.SelectedItem as LogEntryViewModel; - if (selected != null) + if (lstLog.SelectedItem is LogEntryViewModel selected) selected.Bookmarked = !selected.Bookmarked; } diff --git a/SharePointLogViewer/Monitoring/FileTail.cs b/SharePointLogViewer/Monitoring/FileTail.cs index c206ba3..4c17ac7 100644 --- a/SharePointLogViewer/Monitoring/FileTail.cs +++ b/SharePointLogViewer/Monitoring/FileTail.cs @@ -25,10 +25,7 @@ public FileTail() stopSync = new ManualResetEvent(true); } - public bool IsBusy - { - get { return worker.IsBusy; } - } + public bool IsBusy => worker.IsBusy; public void Start(string path) { @@ -37,8 +34,8 @@ public void Start(string path) worker = new BackgroundWorker(); worker.WorkerReportsProgress = true; worker.WorkerSupportsCancellation = true; - worker.DoWork += new DoWorkEventHandler(worker_DoWork); - worker.ProgressChanged += new ProgressChangedEventHandler(worker_ProgressChanged); + worker.DoWork += worker_DoWork; + worker.ProgressChanged += worker_ProgressChanged; worker.RunWorkerAsync(); } @@ -57,7 +54,7 @@ void worker_DoWork(object sender, DoWorkEventArgs e) using (StreamReader reader = new StreamReader(stream)) { reader.ReadToEnd(); - string data = String.Empty; + string data = string.Empty; while (!worker.CancellationPending) { Thread.Sleep(1000); @@ -65,8 +62,8 @@ void worker_DoWork(object sender, DoWorkEventArgs e) continue; data += reader.ReadToEnd(); string[] lines = data.Split(seperators, StringSplitOptions.RemoveEmptyEntries); - data = data.EndsWith("\n") ? String.Empty : lines.Last(); - int validLines = data == String.Empty ? lines.Length : lines.Length - 1; + data = data.EndsWith("\n") ? string.Empty : lines.Last(); + int validLines = data == string.Empty ? lines.Length : lines.Length - 1; foreach (string line in lines.Take(validLines)) worker.ReportProgress(0, line); } @@ -76,7 +73,7 @@ void worker_DoWork(object sender, DoWorkEventArgs e) void worker_ProgressChanged(object sender, ProgressChangedEventArgs e) { - LineDiscovered(this, new LineDiscoveredEventArgs() { Line = (String)e.UserState }); + LineDiscovered(this, new LineDiscoveredEventArgs() { Line = (string)e.UserState }); } #region IDisposable Members diff --git a/SharePointLogViewer/Monitoring/LogDirectoryWatcher.cs b/SharePointLogViewer/Monitoring/LogDirectoryWatcher.cs index 9647cc5..be32aa9 100644 --- a/SharePointLogViewer/Monitoring/LogDirectoryWatcher.cs +++ b/SharePointLogViewer/Monitoring/LogDirectoryWatcher.cs @@ -22,7 +22,7 @@ public LogDirectoryWatcher(string folderPath) watcher.Path = folderPath; watcher.Filter = Filter; watcher.NotifyFilter = NotifyFilters.FileName; - watcher.Created += new FileSystemEventHandler(watcher_Created); + watcher.Created += watcher_Created; } public void Start() diff --git a/SharePointLogViewer/Monitoring/LogMonitor.cs b/SharePointLogViewer/Monitoring/LogMonitor.cs index d63cab1..b04c2e0 100644 --- a/SharePointLogViewer/Monitoring/LogMonitor.cs +++ b/SharePointLogViewer/Monitoring/LogMonitor.cs @@ -18,9 +18,9 @@ public LogMonitor(string folderPath) throw new ArgumentException("Directory does not exist.", folderPath); this.folderPath = folderPath; fileTail = new FileTail(); - fileTail.LineDiscovered += new EventHandler(fileTail_LineDiscovered); + fileTail.LineDiscovered += fileTail_LineDiscovered; watcher = new LogDirectoryWatcher(folderPath); - watcher.FileCreated += new EventHandler(watcher_FileCreated); + watcher.FileCreated += watcher_FileCreated; } public void Start() @@ -46,7 +46,7 @@ void watcher_FileCreated(object sender, FileCreatedEventArgs e) void fileTail_LineDiscovered(object sender, LineDiscoveredEventArgs e) { - if (!String.IsNullOrEmpty(e.Line.Trim()) && !firstLine) + if (!string.IsNullOrEmpty(e.Line.Trim()) && !firstLine) { var entry = LogEntry.Parse(e.Line); if (entry != null) diff --git a/SharePointLogViewer/Monitoring/LogsLoader.cs b/SharePointLogViewer/Monitoring/LogsLoader.cs index 8baddfa..a102c1c 100644 --- a/SharePointLogViewer/Monitoring/LogsLoader.cs +++ b/SharePointLogViewer/Monitoring/LogsLoader.cs @@ -18,8 +18,8 @@ class LogsLoader public LogsLoader() { worker = new BackgroundWorker(); - worker.DoWork += new DoWorkEventHandler(worker_DoWork); - worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted); + worker.DoWork += worker_DoWork; + worker.RunWorkerCompleted += worker_RunWorkerCompleted; } void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) @@ -30,9 +30,9 @@ void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) void worker_DoWork(object sender, DoWorkEventArgs e) { logEntries.Clear(); - string[] files = e.Argument as string[]; - foreach (string file in files) - logEntries.AddRange(LogParser.PraseLog(file)); + if (e.Argument is string[] files) + foreach (string file in files) + logEntries.AddRange(LogParser.PraseLog(file)); } public void Start(string[] files) diff --git a/SharePointLogViewer/Monitoring/MultiLogMonitor.cs b/SharePointLogViewer/Monitoring/MultiLogMonitor.cs index 81c78ff..bb5abd3 100644 --- a/SharePointLogViewer/Monitoring/MultiLogMonitor.cs +++ b/SharePointLogViewer/Monitoring/MultiLogMonitor.cs @@ -19,7 +19,7 @@ public void Start() logMonitors.ForEach(monitor => { monitor.Start(); - monitor.LogEntryDiscovered += new EventHandler(monitor_LogEntryDiscovered); + monitor.LogEntryDiscovered += monitor_LogEntryDiscovered; }); } @@ -28,7 +28,7 @@ public void Stop() logMonitors.ForEach(monitor => { monitor.Stop(); - monitor.LogEntryDiscovered -= new EventHandler(monitor_LogEntryDiscovered); + monitor.LogEntryDiscovered -= monitor_LogEntryDiscovered; }); } diff --git a/SharePointLogViewer/Notifiers/EmailNotifier.cs b/SharePointLogViewer/Notifiers/EmailNotifier.cs index 1d27b12..db5a57d 100644 --- a/SharePointLogViewer/Notifiers/EmailNotifier.cs +++ b/SharePointLogViewer/Notifiers/EmailNotifier.cs @@ -12,11 +12,11 @@ class EmailNotifier: INotifier public EmailNotifier(string sender, string recepients, string smtpServer) { - if (String.IsNullOrEmpty(sender)) + if (string.IsNullOrEmpty(sender)) throw new ArgumentNullException("sender"); - if (String.IsNullOrEmpty(recepients)) + if (string.IsNullOrEmpty(recepients)) throw new ArgumentNullException("recepients"); - if (String.IsNullOrEmpty(smtpServer)) + if (string.IsNullOrEmpty(smtpServer)) throw new ArgumentNullException("smtpServer"); this.sender = sender; diff --git a/SharePointLogViewer/Notifiers/SystemTrayNotifier.cs b/SharePointLogViewer/Notifiers/SystemTrayNotifier.cs index 68ead1e..e18f828 100644 --- a/SharePointLogViewer/Notifiers/SystemTrayNotifier.cs +++ b/SharePointLogViewer/Notifiers/SystemTrayNotifier.cs @@ -14,8 +14,8 @@ public SystemTrayNotifier() notifier = new System.Windows.Forms.NotifyIcon(); using (Stream iconStream = System.Windows.Application.GetResourceStream(new Uri("pack://application:,,/Images/SPLV.ico")).Stream) notifier.Icon = new System.Drawing.Icon(iconStream); - notifier.Click += new EventHandler(notifyIcon_Click); - notifier.BalloonTipClicked += new EventHandler(notifyIcon_Click); + notifier.Click += notifyIcon_Click; + notifier.BalloonTipClicked += notifyIcon_Click; } public void Notify(LogEntryViewModel logEntry) diff --git a/SharePointLogViewer/SPUtility.cs b/SharePointLogViewer/SPUtility.cs index 78e0369..a642b7c 100644 --- a/SharePointLogViewer/SPUtility.cs +++ b/SharePointLogViewer/SPUtility.cs @@ -65,12 +65,9 @@ public static bool IsWSSInstalled try { RegistryKey key = GetWSSRegistryKey(); - if (key != null) - { - object val = key.GetValue("SharePoint"); - if (val != null && val.Equals("Installed")) - return true; - } + object val = key?.GetValue("SharePoint"); + if (val != null && val.Equals("Installed")) + return true; } catch (SecurityException) { } return false; @@ -117,7 +114,7 @@ public static string WSSInstallPath { get { - string installPath = String.Empty; + string installPath = string.Empty; try { using (RegistryKey key = GetWSSRegistryKey()) @@ -129,13 +126,7 @@ public static string WSSInstallPath } } - public static ICollection TraceSeverities - { - get - { - return new ReadOnlyCollection(severities); - } - } + public static ICollection TraceSeverities => new ReadOnlyCollection(severities); public static string GetLogsLocation() { @@ -144,9 +135,9 @@ public static string GetLogsLocation() if (IsWSSInstalled) { logLocation = GetSPDiagnosticsLogLocation(); - if (String.IsNullOrEmpty(logLocation)) + if (string.IsNullOrEmpty(logLocation)) logLocation = GetCustomLogLocation(); - if (String.IsNullOrEmpty(logLocation)) + if (string.IsNullOrEmpty(logLocation)) logLocation = GetStandardLogLocation(); } @@ -195,14 +186,23 @@ public static IEnumerable GetServerNames() if (farmType != null) { PropertyInfo propLocalFarm = farmType.GetProperty("Local", BindingFlags.Public | BindingFlags.Static); - object localFarm = propLocalFarm.GetValue(null, null); - PropertyInfo propServers = localFarm.GetType().GetProperty("Servers", BindingFlags.Public | BindingFlags.Instance); - IEnumerable servers = (IEnumerable)propServers.GetValue(localFarm, null); - foreach (object server in servers) + if (propLocalFarm != null) { - PropertyInfo propServerName = server.GetType().GetProperty("Name", BindingFlags.Public | BindingFlags.Instance); - string serverName = (string)propServerName.GetValue(server, null); - yield return serverName; + object localFarm = propLocalFarm.GetValue(null, null); + PropertyInfo propServers = localFarm.GetType().GetProperty("Servers", BindingFlags.Public | BindingFlags.Instance); + if (propServers != null) + { + IEnumerable servers = (IEnumerable)propServers.GetValue(localFarm, null); + foreach (object server in servers) + { + PropertyInfo propServerName = server.GetType().GetProperty("Name", BindingFlags.Public | BindingFlags.Instance); + if (propServerName != null) + { + string serverName = (string)propServerName.GetValue(server, null); + yield return serverName; + } + } + } } } } @@ -230,7 +230,7 @@ static RegistryKey GetWSSRegistryKey() private static string GetStandardLogLocation() { string logLocation = WSSInstallPath; - if (logLocation != String.Empty) + if (logLocation != string.Empty) logLocation = Path.Combine(logLocation, "logs"); return logLocation; @@ -238,7 +238,7 @@ private static string GetStandardLogLocation() static string GetCustomLogLocation() { - string logLocation = String.Empty; + string logLocation = string.Empty; try { using (RegistryKey key = GetWSSRegistryKey()) @@ -253,7 +253,7 @@ static string GetCustomLogLocation() private static string GetSPDiagnosticsLogLocation() { - string logLocation = String.Empty; + string logLocation = string.Empty; Type diagSvcType = null; if (SPVersion == SPVersion.SP2007) diagSvcType = Type.GetType("Microsoft.SharePoint.Administration.SPDiagnosticsService, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"); @@ -265,9 +265,12 @@ private static string GetSPDiagnosticsLogLocation() if (diagSvcType != null) { PropertyInfo propLocalDiagSvc = diagSvcType.GetProperty("Local", BindingFlags.Public | BindingFlags.Static); - object localDiagSvc = propLocalDiagSvc.GetValue(null, null); - PropertyInfo property = localDiagSvc.GetType().GetProperty("LogLocation"); - logLocation = (string)property.GetValue(localDiagSvc, null); + if (propLocalDiagSvc != null) + { + object localDiagSvc = propLocalDiagSvc.GetValue(null, null); + PropertyInfo property = localDiagSvc.GetType().GetProperty("LogLocation"); + if (property != null) logLocation = (string) property.GetValue(localDiagSvc, null); + } } return logLocation; diff --git a/SharePointLogViewer/Searching/BookmarkNavigator.cs b/SharePointLogViewer/Searching/BookmarkNavigator.cs index 92f40f4..ea24769 100644 --- a/SharePointLogViewer/Searching/BookmarkNavigator.cs +++ b/SharePointLogViewer/Searching/BookmarkNavigator.cs @@ -33,10 +33,7 @@ IEnumerable LogEntries object SelectedItem { - get - { - return lstLog.SelectedItem; - } + get => lstLog.SelectedItem; set { lstLog.SelectedItem = value; diff --git a/SharePointLogViewer/Searching/DynamicFilter.cs b/SharePointLogViewer/Searching/DynamicFilter.cs index d79c83f..e278791 100644 --- a/SharePointLogViewer/Searching/DynamicFilter.cs +++ b/SharePointLogViewer/Searching/DynamicFilter.cs @@ -22,10 +22,10 @@ public static DynamicFilter Create(string criterea, string searchText) static Predicate CreatePredicate(string propertyName, string searchText) { if (searchText == null) - searchText = String.Empty; + searchText = string.Empty; Predicate predicate; - if (searchText == String.Empty) + if (searchText == string.Empty) predicate = _ => true; else { @@ -51,7 +51,7 @@ public bool IsMatch(object item) static Predicate CreatePredicate(PropertyInfo property, params string[] keywords) { var comparer = new PropertyValueComparer(property, keywords); - return new Predicate(comparer.IsMatch); + return comparer.IsMatch; } #region Predicate diff --git a/SharePointLogViewer/Searching/FastInvoke.cs b/SharePointLogViewer/Searching/FastInvoke.cs index 9753430..1f13d15 100644 --- a/SharePointLogViewer/Searching/FastInvoke.cs +++ b/SharePointLogViewer/Searching/FastInvoke.cs @@ -11,10 +11,10 @@ public class FastInvoke FastMethodInvoker MyDelegate; public MethodInfo MyMethodInfo; public ParameterInfo[] MyParameters; - Object HostObject; + object HostObject; public int NumberOfArguments; - public FastInvoke(Object MyObject, String MyName) + public FastInvoke(object MyObject, string MyName) { HostObject = MyObject; Type t2 = MyObject.GetType(); @@ -33,7 +33,7 @@ public object ExecuteDelegate(object[] FunctionParameters) } catch (Exception e) { - Object o = new Object(); + object o = new object(); o = e.Message; return (o); @@ -169,7 +169,7 @@ private static void EmitFastInt(ILGenerator il, int value) if (value > -129 && value < 128) { - il.Emit(OpCodes.Ldc_I4_S, (SByte)value); + il.Emit(OpCodes.Ldc_I4_S, (sbyte)value); } else { diff --git a/SharePointLogViewer/ValueConverter.cs b/SharePointLogViewer/ValueConverter.cs index d5fcff6..c633838 100644 --- a/SharePointLogViewer/ValueConverter.cs +++ b/SharePointLogViewer/ValueConverter.cs @@ -14,20 +14,23 @@ public object Convert(object value, Type targetType, object parameter, System.Gl { ListViewItem item = (ListViewItem)value; - ListView listView = ItemsControl.ItemsControlFromItemContainer(item) as ListView; // Get the index of a ListViewItem - int index = listView.ItemContainerGenerator.IndexFromContainer(item); - - if (index % 2 == 0) - { - return new SolidColorBrush(Colors.LightGray); - } - else + if (ItemsControl.ItemsControlFromItemContainer(item) is ListView listView) { - return new SolidColorBrush(Colors.White); + int index = listView.ItemContainerGenerator.IndexFromContainer(item ?? throw new InvalidOperationException()); + + if (index % 2 == 0) + { + return new SolidColorBrush(Colors.LightGray); + } + else + { + return new SolidColorBrush(Colors.White); + } } + return null; }