diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2017-08-26 15:03:27 +0200 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2017-08-26 15:03:27 +0200 |
| commit | 54166a48c39ef3557822ce1429eddb3370018ff3 (patch) | |
| tree | a902b8d9270c422277193e40cba29ee2e1b44af1 /src/CompilerServices | |
| parent | 4b39241bad2eb55a91305c4aa5197c1640e81c48 (diff) | |
allow enum value in xml and styling delegates
Diffstat (limited to 'src/CompilerServices')
| -rw-r--r-- | src/CompilerServices/CompilerServices.cs | 24 |
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 |