aboutsummaryrefslogtreecommitdiffstatsci
path: root/src
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2017-08-26 15:03:27 +0200
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2017-08-26 15:03:27 +0200
commitbf290bb1f2f3db74b24fa7939c311b1cfcae4ee9 (patch)
treee857f55dbdb2771698973bf7c16e98df8ab81ee1 /src
parent65cf1452510c336fcd69f9922774389d6c3b1aee (diff)
allow enum value in xml and styling delegates
Diffstat (limited to 'src')
-rw-r--r--src/CompilerServices/CompilerServices.cs24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/CompilerServices/CompilerServices.cs b/src/CompilerServices/CompilerServices.cs
index 05dc3652..5884ee66 100644
--- a/src/CompilerServices/CompilerServices.cs
+++ b/src/CompilerServices/CompilerServices.cs
@@ -212,7 +212,7 @@ namespace Crow
il.Emit(OpCodes.Ldtoken, pi.PropertyType);
il.Emit(OpCodes.Call, CompilerServices.miGetTypeFromHandle);
//load enum value name
- il.Emit (OpCodes.Ldstr, Convert.ToString (val));//TODO:is this convert required?
+ il.Emit (OpCodes.Ldstr, Convert.ToString (val));//TODO:implement here string format?
//load false
il.Emit (OpCodes.Ldc_I4_0);
il.Emit (OpCodes.Callvirt, CompilerServices.miParseEnum);
@@ -751,15 +751,25 @@ namespace Crow
throw new NotSupportedException ();
}
- MethodInfo lopParseMi = lopPI.PropertyType.GetMethod ("Parse");
- if (lopParseMi == null)
- throw new Exception (string.Format
- ("IML: no static 'Parse' method found in: {0}", lopPI.PropertyType.Name));
+ MethodInfo lopParseMi = CompilerServices.miParseEnum;
+ if (lopPI.PropertyType.IsEnum){
+ //load type of enum
+ il.Emit(OpCodes.Ldtoken, lopPI.PropertyType);
+ il.Emit(OpCodes.Call, CompilerServices.miGetTypeFromHandle);
+ //load enum value name
+ il.Emit (OpCodes.Ldstr, operandes [1].Trim ());
+ //load false
+ il.Emit (OpCodes.Ldc_I4_0);
+ }else{
+ lopParseMi = lopPI.PropertyType.GetMethod ("Parse");
+ if (lopParseMi == null)
+ throw new Exception (string.Format
+ ("IML: no static 'Parse' method found in: {0}", lopPI.PropertyType.Name));
- il.Emit (OpCodes.Ldstr, operandes [1].Trim ());
+ il.Emit (OpCodes.Ldstr, operandes [1].Trim ());
+ }
il.Emit (OpCodes.Callvirt, lopParseMi);
il.Emit (OpCodes.Unbox_Any, lopPI.PropertyType);
-
//emit left operand assignment
il.Emit (OpCodes.Callvirt, lopPI.GetSetMethod());
} else {//tree parsing and propert gets