File tree Expand file tree Collapse file tree 1 file changed +23
-3
lines changed Expand file tree Collapse file tree 1 file changed +23
-3
lines changed Original file line number Diff line number Diff line change 33using Newtonsoft . Json ;
44using MigrationBase ;
55using System . Text ;
6+ using System . Text . RegularExpressions ;
67
78namespace FortiGateMigration
89{
@@ -19,16 +20,30 @@ public FortiGateParser()
1920 {
2021 _fgCommandsList = new List < FgCommand > ( ) ;
2122 }
22-
23+
2324 #region Override Methods
2425
2526 protected override void ParseVersion ( object versionProvider )
2627 {
2728 string versionLine = versionProvider . ToString ( ) ;
2829
29- int indVersionDash = versionLine . IndexOf ( "-" , "#config-version=" . Length ) + 1 ; //add 1 because we need to cut w/o colon
30+ Regex regex = new Regex ( @"[0-9][.][0-9]" ) ;
31+
32+ MatchCollection matches = regex . Matches ( versionLine ) ;
33+
34+ if ( matches . Count > 0 )
35+ {
36+ int indVersionDash = versionLine . IndexOf ( matches [ 0 ] . Value , "#config-version=" . Length ) ;
3037
31- VendorVersion = versionLine . Substring ( indVersionDash , versionLine . IndexOf ( ":" ) - indVersionDash ) ;
38+ VendorVersion = versionLine . Substring ( indVersionDash , versionLine . IndexOf ( ":" ) - indVersionDash ) ;
39+ }
40+ else
41+ {
42+
43+ int indVersionDash = versionLine . IndexOf ( "-" , "#config-version=" . Length ) + 1 ; //add 1 because we need to cut w/o colon
44+
45+ VendorVersion = versionLine . Substring ( indVersionDash , versionLine . IndexOf ( ":" ) - indVersionDash ) ;
46+ }
3247 }
3348
3449 public override void Parse ( string filename )
@@ -87,6 +102,11 @@ private void ParseCommands(string filename)
87102 commandName = line ;
88103 }
89104
105+ if ( commandName == "end\" " )
106+ {
107+ commandName = "end" ;
108+ } ;
109+
90110 FgCommandExt fgCommandExtT = null ;
91111
92112 switch ( commandName )
You can’t perform that action at this time.
0 commit comments