Exemplo n.º 1
0
        public static IList <string> GetUrlListFromEventRef(IntPtr eventRef)
        {
            AEDesc list = GetEventParameter <AEDesc> (eventRef, CarbonEventParameterName.DirectObject, CarbonEventParameterType.AEList);

            try {
                return(AppleEvent.GetUtf8StringListFromAEDesc(ref list, true));
            } finally {
                Carbon.CheckReturn((int)AppleEvent.AEDisposeDesc(ref list));
            }
        }
Exemplo n.º 2
0
        public static T AEGetNthPtr <T> (ref AEDesc descList, int index, OSType desiredType) where T : struct
        {
            int    len       = Marshal.SizeOf(typeof(T));
            IntPtr bufferPtr = Marshal.AllocHGlobal(len);

            try {
                CheckReturn(AEGetNthPtr(ref descList, index, desiredType, 0, 0, bufferPtr, len, 0));
                T val = (T)Marshal.PtrToStructure(bufferPtr, typeof(T)) !;                   // NRT - Not sure
                return(val);
            } finally {
                Marshal.FreeHGlobal(bufferPtr);
            }
        }
Exemplo n.º 3
0
        public static T[] GetListFromAEDesc <T, TRef> (ref AEDesc list, AEDescValueSelector <TRef, T> sel, OSType type)
            where TRef : struct
        {
            long count = AppleEvent.AECountItems(ref list);

            T[] arr = new T[count];
            for (int i = 1; i <= count; i++)
            {
                TRef r = AppleEvent.AEGetNthPtr <TRef> (ref list, i, type);
                arr[i - 1] = sel(ref r);
            }
            return(arr);
        }
Exemplo n.º 4
0
        public static IList <string> GetUtf8StringListFromAEDesc(ref AEDesc list, bool skipEmpty)
        {
            long count = AppleEvent.AECountItems(ref list);
            var  items = new List <string> ();

            for (int i = 1; i <= count; i++)
            {
                string?str = AppleEvent.GetUtf8StringFromAEPtr(ref list, i);
                if (!string.IsNullOrEmpty(str))
                {
                    items.Add(str);
                }
            }
            return(items);
        }
Exemplo n.º 5
0
        public static string?GetStringFromAEDesc(ref AEDesc desc)
        {
            int size = AEGetDescDataSize(ref desc);

            if (size > 0)
            {
                IntPtr buffer = Marshal.AllocHGlobal(size);
                try {
                    if (AEGetDescData(ref desc, buffer, size) == AEDescStatus.Ok)
                    {
                        return(Marshal.PtrToStringAuto(buffer, size));
                    }
                } finally {
                    Marshal.FreeHGlobal(buffer);
                }
            }
            return(null);
        }
Exemplo n.º 6
0
        //FIXME: this might not work in some encodings. need to test more.
        static string?GetUtf8StringFromAEPtr(ref AEDesc descList, int index)
        {
            int size;
            var type = (OSType)(int)CarbonEventParameterType.UnicodeText;

            if (AESizeOfNthItem(ref descList, index, ref type, out size) == AEDescStatus.Ok)
            {
                IntPtr buffer = Marshal.AllocHGlobal(size);
                try {
                    if (AEGetNthPtr(ref descList, index, type, 0, 0, buffer, size, 0) == AEDescStatus.Ok)
                    {
                        return(Marshal.PtrToStringAuto(buffer, size));
                    }
                } finally {
                    Marshal.FreeHGlobal(buffer);
                }
            }
            return(null);
        }
Exemplo n.º 7
0
 static extern AEDescStatus AECoerceDesc(ref AEDesc theAEDesc, DescType toType, ref AEDesc result);
Exemplo n.º 8
0
 static extern int AEGetDescDataSize(ref AEDesc desc);
Exemplo n.º 9
0
 static extern AEDescStatus AEGetDescData(ref AEDesc desc, IntPtr ptr, int maximumSize);
Exemplo n.º 10
0
 public static extern AEDescStatus AESizeOfNthItem(ref AEDesc descList, int index, ref OSType type, out int size);
Exemplo n.º 11
0
 public static extern AEDescStatus AEDisposeDesc(ref AEDesc desc);
Exemplo n.º 12
0
 static extern AEDescStatus AEGetNthPtr(ref AEDesc descList, int index, OSType desiredType, uint keyword,
                                        uint zero, out IntPtr outPtr, int bufferSize, int zero2);
Exemplo n.º 13
0
 static extern AEDescStatus AEGetNthPtr(ref AEDesc descList, int index, OSType desiredType, uint keyword,
                                        out CarbonEventParameterType actualType, IntPtr buffer, int bufferSize, out int actualSize);
Exemplo n.º 14
0
 static extern AEDescStatus AECreateDesc(OSType typeCode, byte[] data, int dataSize, out AEDesc desc);
Exemplo n.º 15
0
 static extern AEDescStatus AECreateDesc(OSType typeCode, IntPtr dataPtr, int dataSize, out AEDesc desc);
Exemplo n.º 16
0
 public static void AECreateDesc(OSType typeCode, byte[] data, out AEDesc result)
 {
     CheckReturn(AECreateDesc(typeCode, data, data.Length, out result));
 }
Exemplo n.º 17
0
 public static void AECreateDescNull(out AEDesc desc)
 {
     CheckReturn(AECreateDesc((OSType)0, IntPtr.Zero, 0, out desc));
 }
Exemplo n.º 18
0
 static extern AEDescStatus AECountItems(ref AEDesc descList, out int count);          //return an OSErr