예제 #1
0
        public bool LoadFromFile(string file, KeyFileFlags flags)
        {
            IntPtr error;
            IntPtr native_file = Marshaller.StringToFilenamePtr(file);
            bool   ret         = g_key_file_load_from_file(Handle, native_file, (int)flags, out error);

            Marshaller.Free(native_file);
            if (error != IntPtr.Zero)
            {
                throw new GException(error);
            }
            return(ret);
        }
예제 #2
0
 IntPtr AllocNativeElement(object element)
 {
     if (element_type == null)
     {
         if (element is IWrapper)
         {
             return((element as IWrapper).Handle);
         }
         else
         {
             return((IntPtr)GCHandle.Alloc(element));
         }
     }
     else
     {
         if (element_type == typeof(string))
         {
             return(Marshaller.StringToPtrGStrdup(element as string));
         }
         else if (element_type == typeof(FilenameString))
         {
             return(Marshaller.StringToFilenamePtr(element as string));
         }
         else if (element_type == typeof(IntPtr))
         {
             return((IntPtr)GCHandle.Alloc(element));
         }
         else if (typeof(IWrapper).IsAssignableFrom(element_type))
         {
             return((element as IWrapper).Handle);
         }
         else if (element_type == typeof(int))
         {
             return(new IntPtr((int)element));
         }
         else if (element_type.IsValueType)
         {
             return(Marshaller.StructureToPtrAlloc(element));
         }
     }
     return(IntPtr.Zero);
 }