mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-24 12:05:34 +00:00
73632b2747
* generator/ObjectGen.cs : adjust to ObjectManager ns change. * glib/ManagedValue.cs : move to GLib and internalize. * glib/Object.cs : adjust to ObjectManager ns change. * glib/ObjectManager.cs : move to GLib. * glib/TypeConverter.cs : move to GLib. return ManagedValue.GType when we can't match a type instead of GType.None. * gtk/*.custom: adjust for new TypeConverter ns and behavior. 2004-05-28 Mike Kestner <mkestner@ximian.com> * en/* : run updater. fix a few *Sharp copy/pastisms. svn path=/trunk/gtk-sharp/; revision=28362
47 lines
1.2 KiB
C#
47 lines
1.2 KiB
C#
// GLib.TypeConverter.cs : Convert between fundamental and .NET types
|
|
//
|
|
// Author: Rachel Hestilow <hestilow@ximian.com>
|
|
//
|
|
// (c) 2002 Rachel Hestilow
|
|
|
|
namespace GLib {
|
|
using System;
|
|
using System.Collections;
|
|
using System.Reflection;
|
|
|
|
public class TypeConverter {
|
|
|
|
private TypeConverter () {}
|
|
|
|
public static GType LookupType (System.Type type)
|
|
{
|
|
if (type.Equals (typeof (string)))
|
|
return GType.String;
|
|
if (type.Equals (typeof (bool)))
|
|
return GType.Boolean;
|
|
if (type.Equals (typeof (int)))
|
|
return GType.Int;
|
|
if (type.Equals (typeof (double)))
|
|
return GType.Double;
|
|
if (type.Equals (typeof (float)))
|
|
return GType.Float;
|
|
if (type.Equals (typeof (char)))
|
|
return GType.Char;
|
|
if (type.Equals (typeof (uint)))
|
|
return GType.UInt;
|
|
if (type.IsSubclassOf (typeof (GLib.Object)))
|
|
return GType.Object;
|
|
PropertyInfo pi = type.GetProperty ("GType", BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy);
|
|
if (pi != null)
|
|
return (GType) pi.GetValue (null, null);
|
|
if (type.IsSubclassOf (typeof (GLib.Opaque)))
|
|
return GType.Pointer;
|
|
if (type.IsValueType)
|
|
return GType.Pointer;
|
|
|
|
return ManagedValue.GType;
|
|
}
|
|
}
|
|
}
|
|
|