Esempio n. 1
0
        public static Dictionary <string, int> GetFileListFromEventRef(IntPtr eventRef)
        {
            AEDesc list = GetEventParameter <AEDesc> (eventRef, CarbonEventParameterName.DirectObject, CarbonEventParameterType.AEList);

            try {
                int line = 0;
                try {
                    SelectionRange range = GetEventParameter <SelectionRange> (eventRef, CarbonEventParameterName.AEPosition, CarbonEventParameterType.Char);
                    line = range.lineNum + 1;
                } catch {
                }

                var arr = AppleEvent.GetListFromAEDesc <string, FSRef> (ref list, CoreFoundation.FSRefToString,
                                                                        (OSType)(int)CarbonEventParameterType.FSRef);
                var files = new Dictionary <string, int> ();
                foreach (var s in arr)
                {
                    if (!string.IsNullOrEmpty(s))
                    {
                        files[s] = line;
                    }
                }
                return(files);
            } finally {
                CheckReturn((int)AppleEvent.AEDisposeDesc(ref list));
            }
        }
Esempio n. 2
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));
            }
        }
Esempio 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);
        }
Esempio 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);
        }