@@ -14,43 +14,56 @@ public IntPtr Execute(Operation operation, RemoteProcess process)
1414 Contract . Requires ( operation != null ) ;
1515 Contract . Requires ( process != null ) ;
1616
17- if ( operation is OffsetOperation )
17+ var offsetOperation = operation as OffsetOperation ;
18+ if ( offsetOperation != null )
1819 {
19- return ( ( OffsetOperation ) operation ) . Value ;
20+ return offsetOperation . Value ;
2021 }
21- else if ( operation is ModuleOffsetOperation )
22+
23+ var moduleOffsetOperation = operation as ModuleOffsetOperation ;
24+ if ( moduleOffsetOperation != null )
2225 {
23- var module = process . GetModuleByName ( ( ( ModuleOffsetOperation ) operation ) . Name ) ;
26+ var module = process . GetModuleByName ( moduleOffsetOperation . Name ) ;
2427 if ( module != null )
2528 {
2629 return module . Start ;
2730 }
2831
2932 return IntPtr . Zero ;
3033 }
31- else if ( operation is AdditionOperation )
34+
35+ var additionOperation = operation as AdditionOperation ;
36+ if ( additionOperation != null )
3237 {
33- var addition = ( AdditionOperation ) operation ;
38+ var addition = additionOperation ;
3439 return Execute ( addition . Argument1 , process ) . Add ( Execute ( addition . Argument2 , process ) ) ;
3540 }
36- else if ( operation is SubtractionOperation )
41+
42+ var subtractionOperation = operation as SubtractionOperation ;
43+ if ( subtractionOperation != null )
3744 {
38- var addition = ( SubtractionOperation ) operation ;
45+ var addition = subtractionOperation ;
3946 return Execute ( addition . Argument1 , process ) . Sub ( Execute ( addition . Argument2 , process ) ) ;
4047 }
41- else if ( operation is MultiplicationOperation )
48+
49+ var multiplicationOperation = operation as MultiplicationOperation ;
50+ if ( multiplicationOperation != null )
4251 {
43- var multiplication = ( MultiplicationOperation ) operation ;
52+ var multiplication = multiplicationOperation ;
4453 return Execute ( multiplication . Argument1 , process ) . Mul ( Execute ( multiplication . Argument2 , process ) ) ;
4554 }
46- else if ( operation is DivisionOperation )
55+
56+ var divisionOperation = operation as DivisionOperation ;
57+ if ( divisionOperation != null )
4758 {
48- var division = ( DivisionOperation ) operation ;
59+ var division = divisionOperation ;
4960 return Execute ( division . Dividend , process ) . Div ( Execute ( division . Divisor , process ) ) ;
5061 }
51- else if ( operation is ReadPointerOperation )
62+
63+ var pointerOperation = operation as ReadPointerOperation ;
64+ if ( pointerOperation != null )
5265 {
53- return process . ReadRemoteObject < IntPtr > ( Execute ( ( ( ReadPointerOperation ) operation ) . Argument , process ) ) ;
66+ return process . ReadRemoteObject < IntPtr > ( Execute ( pointerOperation . Argument , process ) ) ;
5467 }
5568
5669 throw new ArgumentException ( $ "Unsupported operation '{ operation . GetType ( ) . FullName } '.") ;
0 commit comments