aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/CompilerServices/CompilerServices.cs
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2015-06-21 15:39:58 +0200
committerjpbruyere <jp.bruyere@hotmail.com>2015-06-21 15:39:58 +0200
commitdc995bd1da98971009454f4efe043d6237d00729 (patch)
tree3af8d3a6745e9779edb71de29f3463898a3dedd0 /src/CompilerServices/CompilerServices.cs
parent746f5cfb60c9a798825e31c2e362cfc817e59d44 (diff)
* OpenTK:
* OpenTKGameWindow.cs: * Tests.csproj: * GOLIBTest_4.cs: * GOLIBTest_1.cs: * Window.goml: * Listbox.goml: * test4.goml: * GOLIBTest_Expandable.cs: * testExpandable.goml: debug and test * Colors.cs: debug argb->rgba * CompilerServices.cs: value type conversion * Border.cs: default border =1 * Checkbox.cs: * Expandable.cs: changes in update technic * Group.cs: Clipping debug (need rework) * Label.cs: debug text positionning * Slider.cs: debug * TextBox.cs: selectable=true by default
Diffstat (limited to 'src/CompilerServices/CompilerServices.cs')
-rw-r--r--src/CompilerServices/CompilerServices.cs33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/CompilerServices/CompilerServices.cs b/src/CompilerServices/CompilerServices.cs
index d7d19fa1..ae4b700a 100644
--- a/src/CompilerServices/CompilerServices.cs
+++ b/src/CompilerServices/CompilerServices.cs
@@ -270,8 +270,12 @@ namespace go
if (!srcValueType.IsValueType)
il.Emit(OpCodes.Castclass, srcValueType);
- if (piTarget.PropertyType == typeof(string))
- il.Emit(OpCodes.Callvirt, miToStr);
+ else
+ il.Emit( OpCodes.Callvirt, GetConvertMethod( piTarget.PropertyType ));
+ // if (piTarget.PropertyType == typeof(string))
+// else if ( srcValueType != piTarget.PropertyType)
+//
+
il.Emit(OpCodes.Callvirt, piTarget.GetSetMethod());
}
il.MarkLabel(labFailed);
@@ -284,6 +288,31 @@ namespace go
//Delegate del = dm.CreateDelegate(typeof(System.EventHandler));
addHandler.Invoke(_source, new object[] {del});
}
+
+ #region conversions
+
+ internal static MethodInfo GetConvertMethod( Type targetType )
+ {
+ string name;
+
+ if( targetType == typeof( bool ) )
+ name = "ToBoolean";
+ else if( targetType == typeof( byte ) )
+ name = "ToByte";
+ else if( targetType == typeof( short ) )
+ name = "ToInt16";
+ else if( targetType == typeof( int ) )
+ name = "ToInt32";
+ else if( targetType == typeof( long ) )
+ name = "ToInt64";
+ else if (targetType == typeof (string ) )
+ return typeof(object).GetMethod("ToString", Type.EmptyTypes);
+ else
+ throw new NotImplementedException( string.Format( "Conversion to {0} is not implemented.", targetType.Name ) );
+
+ return typeof( Convert ).GetMethod( name, BindingFlags.Static | BindingFlags.Public, null, new Type[] { typeof( object ) }, null );
+ }
+ #endregion
public static FieldInfo getEventHandlerField(Type type, string eventName)
{