Ryujinx-GtkSharp/glib/TypeConverter.cs
Rachel Hestilow f1a77c0e62 2003-05-19 Rachel Hestilow <rachel@nullenvoid.com>
* glib/ManagedValue.cs, TypeConverter.cs: Added.
	* glib/Value.cs: Make Value inherit from IDisposable, and
	move dtor to Dispose. Add generic object constructor
	with support for ManagedValue. Add a new Val property
	which will call the appropriate explicit cast.

	* glue/value.c: Add new glue function
	gtksharp_value_get_value_type.

	* gtk/TreeViewColumn.custom: Added.
	* gtk/ListStore.custom, TreeStore.custom: Add a number
	of SetValue overloads. Add convenience functtion
	AppendValues. Add new ctor that takes System.Type instead
	of GLib.TypeFundamentals. Add a GetValue convenience wrapper.
	* gtk/TreeView.custom: Add AppendColumn convenience
	functions.

	* sample/ManagedTreeViewDemo.cs: Added.
	* sample/Makefile.in: Update.
	* sample/TreeViewDemo.cs: Update to use new convenience
	APIs.

svn path=/trunk/gtk-sharp/; revision=14691
2003-05-19 07:18:52 +00:00

52 lines
1.3 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 GLib;
/// <summary>
/// Fundamental type converter
/// </summary>
///
/// <remarks>
/// Utilities for converting between TypeFundamentals and System.Type
/// </remarks>
public class TypeConverter {
public static TypeFundamentals LookupType (System.Type type)
{
if (type.Equals (typeof (string)))
return TypeFundamentals.TypeString;
if (!type.IsValueType) {
if (type.IsSubclassOf (typeof (GLib.Object)))
return TypeFundamentals.TypeObject;
else if (type.IsSubclassOf (typeof (GLib.Boxed)))
return TypeFundamentals.TypeBoxed;
else
return TypeFundamentals.TypeNone;
}
if (type.Equals (typeof (bool)))
return TypeFundamentals.TypeBoolean;
if (type.Equals (typeof (int)))
return TypeFundamentals.TypeInt;
if (type.Equals (typeof (double)))
return TypeFundamentals.TypeDouble;
if (type.Equals (typeof (float)))
return TypeFundamentals.TypeFloat;
if (type.Equals (typeof (char)))
return TypeFundamentals.TypeChar;
if (type.Equals (typeof (uint)))
return TypeFundamentals.TypeUInt;
return TypeFundamentals.TypeInvalid;
}
}
}