Skip to content

Commit 49922bb

Browse files
committed
Changed some ifs.
1 parent 38e5a97 commit 49922bb

File tree

4 files changed

+32
-18
lines changed

4 files changed

+32
-18
lines changed

AddressParser/Interpreter.cs

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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}'.");

DataExchange/ReClassFile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ private string TransformAddressString(string address)
106106
part = part.Substring(1);
107107
}
108108

109-
if (part.Contains(".exe") || part.Contains(".dll"))
109+
if (isModule)
110110
{
111111
part = $"<{part}>";
112112
}

UI/SettingsTextBox.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ private void ReadSetting()
2929
if (property != null && source != null)
3030
{
3131
var value = property.GetValue(source);
32-
if (value is string)
32+
var s = value as string;
33+
if (s != null)
3334
{
34-
Text = (string)value;
35+
Text = s;
3536
}
3637
}
3738
}

Util/Rtf/RtfBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ protected void AppendInternal(string value)
209209
using (new RtfFormatWrapper(this))
210210
{
211211
value = EscapeString(value);
212-
if (value.IndexOf(Environment.NewLine) >= 0)
212+
if (value.IndexOf(Environment.NewLine, StringComparison.Ordinal) >= 0)
213213
{
214214
var lines = value.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
215215

0 commit comments

Comments
 (0)