f1e095a87b
* glib/Log.cs: Make LogLevelFlags CLS compliant. * glib/SignalCallback.cs: Set the constructor protection level to protected, since it can not be instantiate.d * glib/Marshaller.cs: Do not allow instances of this class as it only exposes static methods. * glib/Source.cs, glib/FileUtils.cs, glib/Timeout.cs, glib/Thread.cs, glib/Markup.cs, glib/TypeConverter.cs: Ditto. svn path=/trunk/gtk-sharp/; revision=20573
54 lines
1.4 KiB
C#
54 lines
1.4 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 {
|
|
|
|
private 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;
|
|
}
|
|
}
|
|
}
|
|
|