Exemple #1
0
        void CreateCookie(string name, string value, string path, string domain, string comment, string commentUrl, bool?discard, DateTime?expires, int?maximumAge, string ports, bool?secure, int?version)
        {
            // mandatory checks or defaults
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            if (String.IsNullOrEmpty(path))
            {
                path = "/";                 // default in .net
            }
            if (String.IsNullOrEmpty(domain))
            {
                domain = "*";
            }

            using (var properties = new NSMutableDictionary()) {
                // mandatory to create the cookie
                properties.Add(NSHttpCookie.KeyName, new NSString(name));
                properties.Add(NSHttpCookie.KeyValue, new NSString(value));
                properties.Add(NSHttpCookie.KeyPath, new NSString(path));
                properties.Add(NSHttpCookie.KeyDomain, new NSString(domain));

                // optional to create the cookie
                if (!String.IsNullOrEmpty(comment))
                {
                    properties.Add(NSHttpCookie.KeyComment, new NSString(comment));
                }
                if (!String.IsNullOrEmpty(commentUrl))
                {
                    properties.Add(NSHttpCookie.KeyCommentURL, new NSString(commentUrl));
                }
                if (discard.HasValue)
                {
                    properties.Add(NSHttpCookie.KeyDiscard, new NSString(discard.Value ? "TRUE" : "FALSE"));
                }
                if (expires.HasValue && expires.Value != DateTime.MinValue)
                {
                    properties.Add(NSHttpCookie.KeyExpires, (NSDate)expires.Value);
                }
                if (maximumAge.HasValue)
                {
                    properties.Add(NSHttpCookie.KeyMaximumAge, new NSString(maximumAge.Value.ToString()));
                }
                if (!String.IsNullOrEmpty(ports))
                {
                    properties.Add(NSHttpCookie.KeyPort, new NSString(ports.Replace("\"", String.Empty)));
                }
                // any value means secure is true
                if (secure.HasValue && secure.Value)
                {
                    properties.Add(NSHttpCookie.KeySecure, new NSString("1"));
                }
                if (version.HasValue)
                {
                    properties.Add(NSHttpCookie.KeyVersion, new NSString(version.Value.ToString()));
                }

                if (IsDirectBinding)
                {
                    Handle = Messaging.IntPtr_objc_msgSend_IntPtr(this.Handle, Selector.GetHandle(selInitWithProperties_), properties.Handle);
                }
                else
                {
                    Handle = Messaging.IntPtr_objc_msgSendSuper_IntPtr(this.SuperHandle, Selector.GetHandle(selInitWithProperties_), properties.Handle);
                }
            }
        }
 public ShimEnumerator(NSMutableDictionary host)
 {
     e = host.GetEnumerator();
 }
Exemple #3
0
        //public bool? ProtectedFile { get; set; }

        internal NSDictionary ToDictionary()
        {
            var dict = new NSMutableDictionary();

            if (AppendOnly.HasValue)
            {
                dict.SetObject(NSNumber.FromBoolean(AppendOnly.Value), NSFileManager.AppendOnly);
            }
            if (Busy.HasValue)
            {
                dict.SetObject(NSNumber.FromBoolean(Busy.Value), NSFileManager.Busy);
            }
            if (CreationDate != null)
            {
                dict.SetObject(CreationDate, NSFileManager.CreationDate);
            }
            if (ModificationDate != null)
            {
                dict.SetObject(ModificationDate, NSFileManager.ModificationDate);
            }
            if (OwnerAccountName != null)
            {
                dict.SetObject(new NSString(OwnerAccountName), NSFileManager.OwnerAccountName);
            }
            if (DeviceIdentifier.HasValue)
            {
                dict.SetObject(NSNumber.FromUInt32(DeviceIdentifier.Value), NSFileManager.DeviceIdentifier);
            }
            if (FileExtensionHidden.HasValue)
            {
                dict.SetObject(NSNumber.FromBoolean(FileExtensionHidden.Value), NSFileManager.ExtensionHidden);
            }
            if (FileGroupOwnerAccountID.HasValue)
            {
                dict.SetObject(NSNumber.FromUInt32(FileGroupOwnerAccountID.Value), NSFileManager.GroupOwnerAccountID);
            }
            if (FileOwnerAccountID.HasValue)
            {
                dict.SetObject(NSNumber.FromUInt32(FileOwnerAccountID.Value), NSFileManager.OwnerAccountID);
            }
            if (HfsTypeCode.HasValue)
            {
                dict.SetObject(NSNumber.FromUInt32(HfsTypeCode.Value), NSFileManager.HfsTypeCode);
            }
            if (PosixPermissions.HasValue)
            {
                dict.SetObject(NSNumber.FromUInt32(PosixPermissions.Value), NSFileManager.PosixPermissions);
            }
            if (FileReferenceCount.HasValue)
            {
                dict.SetObject(NSNumber.FromUInt32(FileReferenceCount.Value), NSFileManager.ReferenceCount);
            }
            if (FileSystemFileNumber.HasValue)
            {
                dict.SetObject(NSNumber.FromUInt32(FileSystemFileNumber.Value), NSFileManager.SystemFileNumber);
            }
            if (FileSize.HasValue)
            {
                dict.SetObject(NSNumber.FromUInt64(FileSize.Value), NSFileManager.Size);
            }
            if (Immutable.HasValue)
            {
                dict.SetObject(NSNumber.FromBoolean(Immutable.Value), NSFileManager.Immutable);
            }
            //if (ProtectedFile.HasValue)
            //dict.SetObject (NSNumber.FromBoolean (ProtectedFile.Value), NSFileManager.ProtectedFile);
            if (FileType.HasValue)
            {
                NSString v = null;
                switch (FileType.Value)
                {
                case NSFileType.Directory:
                    v = NSFileManager.TypeDirectory; break;

                case NSFileType.Regular:
                    v = NSFileManager.TypeRegular; break;

                case NSFileType.SymbolicLink:
                    v = NSFileManager.TypeSymbolicLink; break;

                case NSFileType.Socket:
                    v = NSFileManager.TypeSocket; break;

                case NSFileType.CharacterSpecial:
                    v = NSFileManager.TypeCharacterSpecial; break;

                case NSFileType.BlockSpecial:
                    v = NSFileManager.TypeBlockSpecial; break;

                default:
                    v = NSFileManager.TypeUnknown; break;
                }
                dict.SetObject(v, NSFileManager.NSFileType);
            }
            return(dict);
        }
Exemple #4
0
 internal /*protected*/ DictionaryContainer()
 {
     Dictionary = new NSMutableDictionary();
 }