99using ReClassNET . UI ;
1010using ReClassNET . Util ;
1111
12- namespace ReClassNET . DataExchange
12+ namespace ReClassNET . DataExchange . ReClass
1313{
14- class ReClassFile : IReClassImport
14+ public class ReClassFile : IReClassImport
1515 {
1616 public const string FormatName = "ReClass File" ;
1717 public const string FileExtension = ".reclass" ;
@@ -35,28 +35,25 @@ public void Load(string filePath, ILogger logger)
3535
3636 Type [ ] typeMap = null ;
3737
38- var versionComment = document . Root . FirstNode as XComment ;
39- if ( versionComment != null )
38+ if ( document . Root . FirstNode is XComment versionComment )
4039 {
4140 switch ( versionComment . Value . Substring ( 0 , 12 ) . ToLower ( ) )
4241 {
4342 case "reclass 2011" :
4443 case "reclass 2013" :
45- typeMap = TypeMap2013 ;
44+ typeMap = typeMap2013 ;
4645 break ;
4746 case "reclass 2015" :
4847 case "reclass 2016" :
49- typeMap = TypeMap2016 ;
48+ typeMap = typeMap2016 ;
5049 break ;
51- }
52- }
53-
54- if ( typeMap == null )
55- {
56- logger . Log ( LogLevel . Warning , $ "Unknown file version: { versionComment ? . Value } ") ;
57- logger . Log ( LogLevel . Warning , "Defaulting to ReClass 2016." ) ;
50+ default :
51+ logger . Log ( LogLevel . Warning , $ "Unknown file version: { versionComment . Value } ") ;
52+ logger . Log ( LogLevel . Warning , "Defaulting to ReClass 2016." ) ;
5853
59- typeMap = TypeMap2016 ;
54+ typeMap = typeMap2016 ;
55+ break ;
56+ }
6057 }
6158
6259 var classes = new List < Tuple < XElement , ClassNode > > ( ) ;
@@ -92,19 +89,22 @@ public void Load(string filePath, ILogger logger)
9289 /// <summary>Parse ReClass address string and transform it into a ReClass.NET formula.</summary>
9390 /// <param name="address">The address string.</param>
9491 /// <returns>A string.</returns>
95- private string TransformAddressString ( string address )
92+ private static string TransformAddressString ( string address )
9693 {
9794 Contract . Requires ( address != null ) ;
9895
99- var parts = address . Split ( '+' ) . Select ( s => s . Trim ( ) . ToLower ( ) . Replace ( "\" " , string . Empty ) ) . Where ( s => s != string . Empty ) . ToArray ( ) ;
96+ var parts = address . Split ( '+' )
97+ . Select ( s => s . Trim ( ) . ToLower ( ) . Replace ( "\" " , string . Empty ) )
98+ . Where ( s => s != string . Empty )
99+ . ToArray ( ) ;
100100
101- for ( int i = 0 ; i < parts . Length ; ++ i )
101+ for ( var i = 0 ; i < parts . Length ; ++ i )
102102 {
103103 var part = parts [ i ] ;
104104
105- bool isModule = part . Contains ( ".exe" ) || part . Contains ( ".dll" ) ;
105+ var isModule = part . Contains ( ".exe" ) || part . Contains ( ".dll" ) ;
106106
107- bool isPointer = false ;
107+ var isPointer = false ;
108108 if ( part . StartsWith ( "*" ) )
109109 {
110110 isPointer = true ;
@@ -173,7 +173,7 @@ private IEnumerable<BaseNode> ReadNodeElements(IEnumerable<XElement> elements, C
173173 while ( size != 0 )
174174 {
175175 BaseNode paddingNode ;
176- #if WIN64
176+ #if RECLASSNET64
177177 if ( size >= 8 )
178178 {
179179 paddingNode = new Hex64Node ( ) ;
@@ -203,8 +203,7 @@ private IEnumerable<BaseNode> ReadNodeElements(IEnumerable<XElement> elements, C
203203 continue ;
204204 }
205205
206- var referenceNode = node as BaseReferenceNode ;
207- if ( referenceNode != null )
206+ if ( node is BaseReferenceNode referenceNode )
208207 {
209208 string reference ;
210209 if ( referenceNode is ClassInstanceArrayNode )
@@ -306,7 +305,7 @@ public override Size Draw(ViewInfo view, int x, int y)
306305
307306 #region ReClass 2011 / ReClass 2013
308307
309- private static readonly Type [ ] TypeMap2013 = new Type [ ]
308+ private static readonly Type [ ] typeMap2013 = new Type [ ]
310309 {
311310 null ,
312311 typeof ( ClassInstanceNode ) ,
@@ -345,7 +344,7 @@ public override Size Draw(ViewInfo view, int x, int y)
345344
346345 #region ReClass 2015 / ReClass 2016
347346
348- private static readonly Type [ ] TypeMap2016 = new Type [ ]
347+ private static readonly Type [ ] typeMap2016 = new Type [ ]
349348 {
350349 null ,
351350 typeof ( ClassInstanceNode ) ,
0 commit comments