@@ -14,43 +14,56 @@ public IntPtr Execute(Operation operation, RemoteProcess process)
14
14
Contract . Requires ( operation != null ) ;
15
15
Contract . Requires ( process != null ) ;
16
16
17
- if ( operation is OffsetOperation )
17
+ var offsetOperation = operation as OffsetOperation ;
18
+ if ( offsetOperation != null )
18
19
{
19
- return ( ( OffsetOperation ) operation ) . Value ;
20
+ return offsetOperation . Value ;
20
21
}
21
- else if ( operation is ModuleOffsetOperation )
22
+
23
+ var moduleOffsetOperation = operation as ModuleOffsetOperation ;
24
+ if ( moduleOffsetOperation != null )
22
25
{
23
- var module = process . GetModuleByName ( ( ( ModuleOffsetOperation ) operation ) . Name ) ;
26
+ var module = process . GetModuleByName ( moduleOffsetOperation . Name ) ;
24
27
if ( module != null )
25
28
{
26
29
return module . Start ;
27
30
}
28
31
29
32
return IntPtr . Zero ;
30
33
}
31
- else if ( operation is AdditionOperation )
34
+
35
+ var additionOperation = operation as AdditionOperation ;
36
+ if ( additionOperation != null )
32
37
{
33
- var addition = ( AdditionOperation ) operation ;
38
+ var addition = additionOperation ;
34
39
return Execute ( addition . Argument1 , process ) . Add ( Execute ( addition . Argument2 , process ) ) ;
35
40
}
36
- else if ( operation is SubtractionOperation )
41
+
42
+ var subtractionOperation = operation as SubtractionOperation ;
43
+ if ( subtractionOperation != null )
37
44
{
38
- var addition = ( SubtractionOperation ) operation ;
45
+ var addition = subtractionOperation ;
39
46
return Execute ( addition . Argument1 , process ) . Sub ( Execute ( addition . Argument2 , process ) ) ;
40
47
}
41
- else if ( operation is MultiplicationOperation )
48
+
49
+ var multiplicationOperation = operation as MultiplicationOperation ;
50
+ if ( multiplicationOperation != null )
42
51
{
43
- var multiplication = ( MultiplicationOperation ) operation ;
52
+ var multiplication = multiplicationOperation ;
44
53
return Execute ( multiplication . Argument1 , process ) . Mul ( Execute ( multiplication . Argument2 , process ) ) ;
45
54
}
46
- else if ( operation is DivisionOperation )
55
+
56
+ var divisionOperation = operation as DivisionOperation ;
57
+ if ( divisionOperation != null )
47
58
{
48
- var division = ( DivisionOperation ) operation ;
59
+ var division = divisionOperation ;
49
60
return Execute ( division . Dividend , process ) . Div ( Execute ( division . Divisor , process ) ) ;
50
61
}
51
- else if ( operation is ReadPointerOperation )
62
+
63
+ var pointerOperation = operation as ReadPointerOperation ;
64
+ if ( pointerOperation != null )
52
65
{
53
- return process . ReadRemoteObject < IntPtr > ( Execute ( ( ( ReadPointerOperation ) operation ) . Argument , process ) ) ;
66
+ return process . ReadRemoteObject < IntPtr > ( Execute ( pointerOperation . Argument , process ) ) ;
54
67
}
55
68
56
69
throw new ArgumentException ( $ "Unsupported operation '{ operation . GetType ( ) . FullName } '.") ;
0 commit comments