GtkSharp/glib/TypeConverter.cs
Mike Kestner 7a518421ab 2004-05-25 Mike Kestner <mkestner@ximian.com>
* configure.in : don't expand the GAPI Makefile.
	* parser/Makefile.am : remove SUBDIRS.
	* parser/gapi2xml.pl : remove GAPI::Metadata usage.
	* parser/GAPI/* : kill. long live gapi-fixup.

svn path=/trunk/gtk-sharp/; revision=28085
2004-05-25 21:27:41 +00:00

48 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 GLibSharp {
using System;
using System.Collections;
using System.Reflection;
using GLib;
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 GType.None;
}
}
}