context: // This file was generated by the Gtk# code generator.
  // Any changes made will be lost if regenerated.
  
  namespace GLib {
  
  	using System;
  	using System.Collections;
  	using System.Collections.Generic;
  	using System.Runtime.InteropServices;
  
  #region Autogenerated code
  	public partial class SocketAddress : GLib.Object {
  
  		public SocketAddress (IntPtr raw) : base(raw) {}
  
  		[DllImport("libgio-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
  		static extern IntPtr g_socket_address_new_from_native(IntPtr native, UIntPtr len);
  
  		public SocketAddress (IntPtr native, ulong len) : base (IntPtr.Zero)
  		{
  			if (GetType () != typeof (SocketAddress)) {
  				throw new InvalidOperationException ("Can't override this constructor.");
  			}
  			Raw = g_socket_address_new_from_native(native, new UIntPtr (len));
  		}
  
  		[DllImport("libgio-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
  		static extern int g_socket_address_get_family(IntPtr raw);
  
  		[GLib.Property ("family")]
  		public GLib.SocketFamily Family {
  			get  {
  				int raw_ret = g_socket_address_get_family(Handle);
  				GLib.SocketFamily ret = (GLib.SocketFamily) raw_ret;
  				return ret;
  			}
  		}
  
  		static GetFamilyNativeDelegate GetFamily_cb_delegate;
  		static GetFamilyNativeDelegate GetFamilyVMCallback {
  			get {
  				if (GetFamily_cb_delegate == null)
  					GetFamily_cb_delegate = new GetFamilyNativeDelegate (GetFamily_cb);
  				return GetFamily_cb_delegate;
  			}
  		}
  
  		static void OverrideGetFamily (GLib.GType gtype)
  		{
  			OverrideGetFamily (gtype, GetFamilyVMCallback);
  		}
  
  		static void OverrideGetFamily (GLib.GType gtype, GetFamilyNativeDelegate callback)
  		{
  			GSocketAddressClass class_iface = GetClassStruct (gtype, false);
  			class_iface.GetFamily = callback;
  			OverrideClassStruct (gtype, class_iface);
  		}
  
  		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
  		delegate int GetFamilyNativeDelegate (IntPtr inst);
  
  		static int GetFamily_cb (IntPtr inst)
  		{
  			try {
  				SocketAddress __obj = GLib.Object.GetObject (inst, false) as SocketAddress;
  				GLib.SocketFamily __result;
  				__result = __obj.OnGetFamily ();
  				return (int) __result;
  			} catch (Exception e) {
  				GLib.ExceptionManager.RaiseUnhandledException (e, true);
  				// NOTREACHED: above call does not return.
  				throw e;
  			}
  		}
  
  		[GLib.DefaultSignalHandler(Type=typeof(GLib.SocketAddress), ConnectionMethod="OverrideGetFamily")]
  		protected virtual GLib.SocketFamily OnGetFamily ()
  		{
  			return InternalGetFamily ();
  		}
  
  		private GLib.SocketFamily InternalGetFamily ()
  		{
  			GetFamilyNativeDelegate unmanaged = GetClassStruct (this.LookupGType ().GetThresholdType (), true).GetFamily;
  			if (unmanaged == null) return (GLib.SocketFamily) 0;
  
  			int __result = unmanaged (this.Handle);
  			return (GLib.SocketFamily) __result;
  		}
  
  		static GetNativeSizeNativeDelegate GetNativeSize_cb_delegate;
  		static GetNativeSizeNativeDelegate GetNativeSizeVMCallback {
  			get {
  				if (GetNativeSize_cb_delegate == null)
  					GetNativeSize_cb_delegate = new GetNativeSizeNativeDelegate (GetNativeSize_cb);
  				return GetNativeSize_cb_delegate;
  			}
  		}
  
  		static void OverrideGetNativeSize (GLib.GType gtype)
  		{
  			OverrideGetNativeSize (gtype, GetNativeSizeVMCallback);
  		}
  
  		static void OverrideGetNativeSize (GLib.GType gtype, GetNativeSizeNativeDelegate callback)
  		{
  			GSocketAddressClass class_iface = GetClassStruct (gtype, false);
  			class_iface.GetNativeSize = callback;
  			OverrideClassStruct (gtype, class_iface);
  		}
  
  		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
  		delegate IntPtr GetNativeSizeNativeDelegate (IntPtr inst);
  
  		static IntPtr GetNativeSize_cb (IntPtr inst)
  		{
  			try {
  				SocketAddress __obj = GLib.Object.GetObject (inst, false) as SocketAddress;
  				long __result;
  				__result = __obj.OnGetNativeSize ();
  				return new IntPtr (__result);
  			} catch (Exception e) {
  				GLib.ExceptionManager.RaiseUnhandledException (e, true);
  				// NOTREACHED: above call does not return.
  				throw e;
  			}
  		}
  
  		[GLib.DefaultSignalHandler(Type=typeof(GLib.SocketAddress), ConnectionMethod="OverrideGetNativeSize")]
  		protected virtual long OnGetNativeSize ()
  		{
  			return InternalGetNativeSize ();
  		}
  
  		private long InternalGetNativeSize ()
  		{
  			GetNativeSizeNativeDelegate unmanaged = GetClassStruct (this.LookupGType ().GetThresholdType (), true).GetNativeSize;
  			if (unmanaged == null) return 0L;
  
  			IntPtr __result = unmanaged (this.Handle);
  			return (long) __result;
  		}
  
  		static ToNativeNativeDelegate ToNative_cb_delegate;
  		static ToNativeNativeDelegate ToNativeVMCallback {
  			get {
  				if (ToNative_cb_delegate == null)
  					ToNative_cb_delegate = new ToNativeNativeDelegate (ToNative_cb);
  				return ToNative_cb_delegate;
  			}
  		}
  
  		static void OverrideToNative (GLib.GType gtype)
  		{
  			OverrideToNative (gtype, ToNativeVMCallback);
  		}
  
  		static void OverrideToNative (GLib.GType gtype, ToNativeNativeDelegate callback)
  		{
  			GSocketAddressClass class_iface = GetClassStruct (gtype, false);
  			class_iface.ToNative = callback;
  			OverrideClassStruct (gtype, class_iface);
  		}
  
  		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
  		delegate bool ToNativeNativeDelegate (IntPtr inst, IntPtr dest, UIntPtr destlen, out IntPtr error);
  
  		static bool ToNative_cb (IntPtr inst, IntPtr dest, UIntPtr destlen, out IntPtr error)
  		{
  			error = IntPtr.Zero;
  
  			try {
  				SocketAddress __obj = GLib.Object.GetObject (inst, false) as SocketAddress;
  				bool __result;
  				__result = __obj.OnToNative (dest, (ulong) destlen);
  				return __result;
  			} catch (Exception e) {
  				GLib.ExceptionManager.RaiseUnhandledException (e, true);
  				// NOTREACHED: above call does not return.
  				throw e;
  			}
  		}
  
  		[GLib.DefaultSignalHandler(Type=typeof(GLib.SocketAddress), ConnectionMethod="OverrideToNative")]
  		protected virtual bool OnToNative (IntPtr dest, ulong destlen)
  		{
  			return InternalToNative (dest, destlen);
  		}
  
  		private bool InternalToNative (IntPtr dest, ulong destlen)
  		{
  			ToNativeNativeDelegate unmanaged = GetClassStruct (this.LookupGType ().GetThresholdType (), true).ToNative;
  			if (unmanaged == null) throw new InvalidOperationException ("No base method to invoke");
  
  			IntPtr error = IntPtr.Zero;
  			bool __result = unmanaged (this.Handle, dest, new UIntPtr (destlen), out error);
  			return __result;
  		}
  
  		[StructLayout (LayoutKind.Sequential)]
  		struct GSocketAddressClass {
  			public GetFamilyNativeDelegate GetFamily;
  			public GetNativeSizeNativeDelegate GetNativeSize;
  			public ToNativeNativeDelegate ToNative;
  		}
  
  		static uint class_offset = ((GLib.GType) typeof (GLib.Object)).GetClassSize ();
  		static Dictionary<GLib.GType, GSocketAddressClass> class_structs;
  
  		static GSocketAddressClass GetClassStruct (GLib.GType gtype, bool use_cache)
  		{
  			if (class_structs == null)
  				class_structs = new Dictionary<GLib.GType, GSocketAddressClass> ();
  
  			if (use_cache && class_structs.ContainsKey (gtype))
  
gt: 				return class_structs [gtype];