diff --git a/MvsSln/Core/ISlnContainer.cs b/MvsSln/Core/ISlnContainer.cs index 364f1bf..aca5ab4 100644 --- a/MvsSln/Core/ISlnContainer.cs +++ b/MvsSln/Core/ISlnContainer.cs @@ -41,6 +41,11 @@ public interface ISlnContainer /// IDictionary RawXmlProjects { get; set; } + /// + /// To reset and register all default handlers. + /// + void SetDefaultHandlers(); + /// /// Parse of selected .sln file. /// diff --git a/MvsSln/Core/SlnHandlers/LVisualStudioVersion.cs b/MvsSln/Core/SlnHandlers/LVisualStudioVersion.cs index e11de20..dc591aa 100644 --- a/MvsSln/Core/SlnHandlers/LVisualStudioVersion.cs +++ b/MvsSln/Core/SlnHandlers/LVisualStudioVersion.cs @@ -79,6 +79,8 @@ public override bool Positioned(ISvc svc, RawText line) return false; } + LSender.Send(this, $"Found version from header: '{lineType}' = '{version}'", Message.Level.Info); + var h = new SlnHeader(svc.Sln.Header); switch(lineType) { diff --git a/MvsSln/Core/SlnParser.cs b/MvsSln/Core/SlnParser.cs index 0be4c6a..16a4e83 100644 --- a/MvsSln/Core/SlnParser.cs +++ b/MvsSln/Core/SlnParser.cs @@ -70,6 +70,23 @@ public IDictionary RawXmlProjects set; } + /// + /// To reset and register all default handlers. + /// + public void SetDefaultHandlers() + { + SlnHandlers.Reset(); + + SlnHandlers.Register(new LVisualStudioVersion()); + SlnHandlers.Register(new LProject()); + SlnHandlers.Register(new LProjectDependencies()); + SlnHandlers.Register(new LProjectSolutionItems()); + SlnHandlers.Register(new LProjectConfigurationPlatforms()); + SlnHandlers.Register(new LSolutionConfigurationPlatforms()); + + // TODO: validate CoHandlers ref + } + /// /// Parse of selected .sln file. /// @@ -137,16 +154,12 @@ public ISlnResult Parse(StreamReader reader, SlnItems type) return data; } - public SlnParser() + /// To register and activate all handlers by default if true. + public SlnParser(bool defaultHandlers = true) { - SlnHandlers.Register(new LVisualStudioVersion()); - SlnHandlers.Register(new LProject()); - SlnHandlers.Register(new LProjectDependencies()); - SlnHandlers.Register(new LProjectSolutionItems()); - SlnHandlers.Register(new LProjectConfigurationPlatforms()); - SlnHandlers.Register(new LSolutionConfigurationPlatforms()); - - // TODO: validate CoHandlers ref + if(defaultHandlers) { + SetDefaultHandlers(); + } } protected void Process(ISvc svc) diff --git a/MvsSlnTest/SlnTest.cs b/MvsSlnTest/SlnTest.cs index bfe0c6f..6e7e810 100644 --- a/MvsSlnTest/SlnTest.cs +++ b/MvsSlnTest/SlnTest.cs @@ -261,7 +261,7 @@ public void MapTest1() var map = sln.Result.Map; Assert.AreEqual(38, map.Count); - Assert.AreEqual(null, map[0].Handler); + Assert.AreEqual(typeof(LVisualStudioVersion), map[0].Handler.GetType()); Assert.AreEqual(typeof(LProject), map[1].Handler.GetType()); Assert.AreEqual(typeof(LProjectDependencies), map[2].Handler.GetType());