Exemplo n.º 1
0
        internal static short?fetch_short(NSDictionary dict, NSString key)
        {
            var k = dict.ObjectForKey(key) as NSNumber;

            if (k == null)
            {
                return(null);
            }
            return(k.Int16Value);
        }
Exemplo n.º 2
0
        internal static nint?fetch_nint(NSDictionary dict, NSString key)
        {
            var k = dict.ObjectForKey(key) as NSNumber;

            if (k == null)
            {
                return(null);
            }
            return(k.LongValue);
        }
Exemplo n.º 3
0
        internal static long?fetch_long(NSDictionary dict, NSString key)
        {
            var k = dict.ObjectForKey(key) as NSNumber;

            if (k == null)
            {
                return(null);
            }
            return(k.Int64Value);
        }
Exemplo n.º 4
0
        internal static bool?fetch_bool(NSDictionary dict, NSString key)
        {
            var k = dict.ObjectForKey(key) as NSNumber;

            if (k == null)
            {
                return(null);
            }
            return(k.BoolValue);
        }
Exemplo n.º 5
0
        public static NSFileAttributes FromDictionary(NSDictionary dict)
        {
            if (dict == null)
            {
                return(null);
            }
            var ret = new NSFileAttributes();

            ret.AppendOnly = fetch_bool(dict, NSFileManager.AppendOnly);
            ret.Busy       = fetch_bool(dict, NSFileManager.Busy);
#if XAMCORE_2_0
            ret.ExtensionHidden = fetch_bool(dict, NSFileManager.ExtensionHidden);
#else
            ret.FileExtensionHidden = fetch_bool(dict, NSFileManager.ExtensionHidden);
#endif
            ret.CreationDate          = dict.ObjectForKey(NSFileManager.CreationDate) as NSDate;
            ret.OwnerAccountName      = dict.ObjectForKey(NSFileManager.OwnerAccountName) as NSString;
            ret.GroupOwnerAccountName = dict.ObjectForKey(NSFileManager.GroupOwnerAccountName) as NSString;
            ret.SystemNumber          = fetch_nint(dict, NSFileManager.SystemNumber);
            ret.DeviceIdentifier      = fetch_nuint(dict, NSFileManager.DeviceIdentifier);
#if XAMCORE_2_0
            ret.GroupOwnerAccountID = fetch_nuint(dict, NSFileManager.GroupOwnerAccountID);
#else
            ret.FileGroupOwnerAccountID = fetch_nuint(dict, NSFileManager.GroupOwnerAccountID);
#endif
            ret.Immutable        = fetch_bool(dict, NSFileManager.Immutable);
            ret.ModificationDate = dict.ObjectForKey(NSFileManager.ModificationDate) as NSDate;
#if XAMCORE_2_0
            ret.OwnerAccountID = fetch_nuint(dict, NSFileManager.OwnerAccountID);
#else
            ret.FileOwnerAccountID = fetch_nuint(dict, NSFileManager.OwnerAccountID);
#endif
            ret.HfsCreatorCode = fetch_nuint(dict, NSFileManager.HfsCreatorCode);
            ret.HfsTypeCode    = fetch_nuint(dict, NSFileManager.HfsTypeCode);
#if XAMCORE_2_0
            ret.PosixPermissions = fetch_short(dict, NSFileManager.PosixPermissions);
#else
            ret.PosixPermissions = (uint?)fetch_short(dict, NSFileManager.PosixPermissions);
#endif
#if XAMCORE_2_0
            ret.ReferenceCount   = fetch_nuint(dict, NSFileManager.ReferenceCount);
            ret.SystemFileNumber = fetch_nuint(dict, NSFileManager.SystemFileNumber);
            ret.Size             = fetch_ulong(dict, NSFileManager.Size);
#else
            ret.FileReferenceCount   = fetch_nuint(dict, NSFileManager.ReferenceCount);
            ret.FileSystemFileNumber = fetch_nuint(dict, NSFileManager.SystemFileNumber);
            ret.FileSize             = fetch_ulong(dict, NSFileManager.Size);
#endif

            NSString name;

            name = dict.ObjectForKey(NSFileManager.NSFileType) as NSString;
            if (name != null)
            {
                NSFileType?type = null;

                if (name == NSFileManager.TypeDirectory)
                {
                    type = NSFileType.Directory;
                }
                else if (name == NSFileManager.TypeRegular)
                {
                    type = NSFileType.Regular;
                }
                else if (name == NSFileManager.TypeSymbolicLink)
                {
                    type = NSFileType.SymbolicLink;
                }
                else if (name == NSFileManager.TypeSocket)
                {
                    type = NSFileType.Socket;
                }
                else if (name == NSFileManager.TypeCharacterSpecial)
                {
                    type = NSFileType.CharacterSpecial;
                }
                else if (name == NSFileManager.TypeBlockSpecial)
                {
                    type = NSFileType.BlockSpecial;
                }
                else if (name == NSFileManager.TypeUnknown)
                {
                    type = NSFileType.Unknown;
                }

#if XAMCORE_2_0
                ret.Type = type;
#else
                ret.FileType = type;
#endif
            }

#if !MONOMAC
            name = dict.ObjectForKey(NSFileManager.FileProtectionKey) as NSString;
            if (name != null)
            {
                NSFileProtection?protection = null;

                if (name == NSFileManager.FileProtectionNone)
                {
                    protection = NSFileProtection.None;
                }
                else if (name == NSFileManager.FileProtectionComplete)
                {
                    protection = NSFileProtection.Complete;
                }
                else if (name == NSFileManager.FileProtectionCompleteUnlessOpen)
                {
                    protection = NSFileProtection.CompleteUnlessOpen;
                }
                else if (name == NSFileManager.FileProtectionCompleteUntilFirstUserAuthentication)
                {
                    protection = NSFileProtection.CompleteUntilFirstUserAuthentication;
                }

                ret.ProtectionKey = protection;
            }
#endif
            return(ret);
        }