Skip to content

Commit 17f2878

Browse files
author
Sébastien Geiser
committed
Renaming refactor
1 parent 4d5209f commit 17f2878

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

CodingSeb.ExpressionEvaluator.Tests/ExpressionEvaluatorTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1593,7 +1593,7 @@ void VariableEval(object sender, VariableEvaluationEventArg e)
15931593
e.Value = e.EvaluateGenericTypes();
15941594
else if (e.Name.Equals("myvar2"))
15951595
e.Value = 50;
1596-
else if (e.This is ClassOrTypeName classOrTypeName && classOrTypeName.Type == typeof(ClassForTest1) && e.Name.Equals("OnTheFlyStaticVar"))
1596+
else if (e.This is ClassOrEnumType classOrTypeName && classOrTypeName.Type == typeof(ClassForTest1) && e.Name.Equals("OnTheFlyStaticVar"))
15971597
{
15981598
e.Value = 10;
15991599
}
@@ -1603,7 +1603,7 @@ void FunctionEval(object sender, FunctionEvaluationEventArg e)
16031603
{
16041604
if (e.Name.Equals("GetSpecifiedGenericTypesFunc"))
16051605
e.Value = e.EvaluateGenericTypes();
1606-
else if (e.This is ClassOrTypeName classOrTypeName && classOrTypeName.Type == typeof(ClassForTest1) && e.Name.Equals("OnTheFlyStaticFunc"))
1606+
else if (e.This is ClassOrEnumType classOrTypeName && classOrTypeName.Type == typeof(ClassForTest1) && e.Name.Equals("OnTheFlyStaticFunc"))
16071607
{
16081608
e.Value = 8;
16091609
}
@@ -1620,7 +1620,7 @@ void Evaluator_PreEvaluateFunction(object sender, FunctionPreEvaluationEventArg
16201620
// e.EvaluateGenericTypes() return a Type[]
16211621
e.Value = e.EvaluateGenericTypes()[0].Namespace;
16221622
}
1623-
else if (e.This is ClassOrTypeName classOrTypeName && classOrTypeName.Type == typeof(ClassForTest1) && e.Name.Equals("OnTheFlyStaticPreFunc"))
1623+
else if (e.This is ClassOrEnumType classOrTypeName && classOrTypeName.Type == typeof(ClassForTest1) && e.Name.Equals("OnTheFlyStaticPreFunc"))
16241624
{
16251625
e.Value = 15;
16261626
}
@@ -1637,7 +1637,7 @@ void Evaluator_PreEvaluateVariable(object sender, VariablePreEvaluationEventArg
16371637
// e.EvaluateGenericTypes() return a Type[]
16381638
e.Value = e.EvaluateGenericTypes()[0].Assembly.GetName().Name;
16391639
}
1640-
else if (e.This is ClassOrTypeName classOrTypeName && classOrTypeName.Type == typeof(ClassForTest1) && e.Name.Equals("OnTheFlyStaticPreVar"))
1640+
else if (e.This is ClassOrEnumType classOrTypeName && classOrTypeName.Type == typeof(ClassForTest1) && e.Name.Equals("OnTheFlyStaticPreVar"))
16411641
{
16421642
e.Value = 3;
16431643
}

CodingSeb.ExpressionEvaluator/ExpressionEvaluator.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ private enum TryBlockEvaluatedState
289289
{ExpressionOperator.Greater, (dynamic left, dynamic right) => left > right },
290290
{ExpressionOperator.LowerOrEqual, (dynamic left, dynamic right) => left <= right },
291291
{ExpressionOperator.GreaterOrEqual, (dynamic left, dynamic right) => left >= right },
292-
{ExpressionOperator.Is, (dynamic left, dynamic right) => left != null && (((ClassOrTypeName)right).Type).IsAssignableFrom(left.GetType()) },
292+
{ExpressionOperator.Is, (dynamic left, dynamic right) => left != null && (((ClassOrEnumType)right).Type).IsAssignableFrom(left.GetType()) },
293293
},
294294
new Dictionary<ExpressionOperator, Func<dynamic, dynamic, object>>()
295295
{
@@ -376,7 +376,7 @@ private enum TryBlockEvaluatedState
376376
{
377377
object argValue = self.Evaluate(args[0]);
378378

379-
if (argValue is ClassOrTypeName classOrTypeName)
379+
if (argValue is ClassOrEnumType classOrTypeName)
380380
return Activator.CreateInstance(classOrTypeName.Type);
381381
else
382382
return null;
@@ -406,7 +406,7 @@ private enum TryBlockEvaluatedState
406406
{ "new", (self, args) =>
407407
{
408408
List<object> cArgs = args.ConvertAll(arg => self.Evaluate(arg));
409-
return Activator.CreateInstance((cArgs[0] as ClassOrTypeName).Type, cArgs.Skip(1).ToArray());
409+
return Activator.CreateInstance((cArgs[0] as ClassOrEnumType).Type, cArgs.Skip(1).ToArray());
410410
}
411411
},
412412
{ "Round", (self, args) =>
@@ -434,7 +434,7 @@ private enum TryBlockEvaluatedState
434434
{ "Sign", (self, args) => Math.Sign(Convert.ToDouble(self.Evaluate(args[0]))) },
435435
{ "sizeof", (self, args) =>
436436
{
437-
Type type = ((ClassOrTypeName)self.Evaluate(args[0])).Type;
437+
Type type = ((ClassOrEnumType)self.Evaluate(args[0])).Type;
438438

439439
if(type == typeof(bool))
440440
return 1;
@@ -444,7 +444,7 @@ private enum TryBlockEvaluatedState
444444
return Marshal.SizeOf(type);
445445
}
446446
},
447-
{ "typeof", (self, args) => ((ClassOrTypeName)self.Evaluate(args[0])).Type },
447+
{ "typeof", (self, args) => ((ClassOrEnumType)self.Evaluate(args[0])).Type },
448448
};
449449

450450
#endregion
@@ -1065,7 +1065,7 @@ void ExecuteTryList()
10651065

10661066
if (exceptionVariable.Length >= 2)
10671067
{
1068-
if (!((ClassOrTypeName)Evaluate(exceptionVariable[0])).Type.IsAssignableFrom(exception.GetType()))
1068+
if (!((ClassOrEnumType)Evaluate(exceptionVariable[0])).Type.IsAssignableFrom(exception.GetType()))
10691069
continue;
10701070

10711071
exceptionName = exceptionVariable[1];
@@ -1770,7 +1770,7 @@ private bool EvaluateVarOrFunc(string expr, string restOfExpression, Stack<objec
17701770
throw new ExpressionEvaluatorSecurityException($"{obj.GetType().FullName} type is blocked");
17711771
else if (obj is Type staticType && TypesToBlock.Contains(staticType))
17721772
throw new ExpressionEvaluatorSecurityException($"{staticType.FullName} type is blocked");
1773-
else if (obj is ClassOrTypeName classOrType && TypesToBlock.Contains(classOrType.Type))
1773+
else if (obj is ClassOrEnumType classOrType && TypesToBlock.Contains(classOrType.Type))
17741774
throw new ExpressionEvaluatorSecurityException($"{classOrType.Type} type is blocked");
17751775

17761776
try
@@ -1937,7 +1937,7 @@ private bool EvaluateVarOrFunc(string expr, string restOfExpression, Stack<objec
19371937
throw new ExpressionEvaluatorSecurityException($"{obj.GetType().FullName} type is blocked");
19381938
else if (obj is Type staticType && TypesToBlock.Contains(staticType))
19391939
throw new ExpressionEvaluatorSecurityException($"{staticType.FullName} type is blocked");
1940-
else if (obj is ClassOrTypeName classOrType && TypesToBlock.Contains(classOrType.Type))
1940+
else if (obj is ClassOrEnumType classOrType && TypesToBlock.Contains(classOrType.Type))
19411941
throw new ExpressionEvaluatorSecurityException($"{classOrType.Type} type is blocked");
19421942

19431943
try
@@ -2224,7 +2224,7 @@ private bool EvaluateVarOrFunc(string expr, string restOfExpression, Stack<objec
22242224

22252225
if (staticType != null)
22262226
{
2227-
stack.Push(new ClassOrTypeName() { Type = staticType });
2227+
stack.Push(new ClassOrEnumType() { Type = staticType });
22282228
}
22292229
else
22302230
{
@@ -2894,7 +2894,7 @@ private BindingFlags DetermineInstanceOrStatic(ref Type objType, ref object obj,
28942894
obj = valueTypeNestingTrace.Value;
28952895
}
28962896

2897-
if (obj is ClassOrTypeName classOrTypeName)
2897+
if (obj is ClassOrEnumType classOrTypeName)
28982898
{
28992899
objType = classOrTypeName.Type;
29002900
obj = null;
@@ -3369,7 +3369,7 @@ public enum OptionOnNoReturnKeywordFoundInScriptAction
33693369

33703370
#region ExpressionEvaluator linked public classes (specific Exceptions and EventArgs)
33713371

3372-
public partial class ClassOrTypeName
3372+
public partial class ClassOrEnumType
33733373
{
33743374
public Type Type { get; set; }
33753375
}

0 commit comments

Comments
 (0)