/// <summary> /// Creates a set and fill it with the given objects. /// </summary> /// <param name="objects">The objects to populate the set.</param> /// <param name="ordered">Should the set be ordered on operations?</param> public NSSet(bool ordered, INsOrigin origin, params NSObject[] objects) : base(origin) { this.ordered = ordered; set = new List <NSObject>(objects); if (ordered) { set.Sort(); } }
/// <summary> /// Initializes a new instance of the <see cref="Claunia.PropertyList.UID"/> class. /// </summary> /// <param name="name">Name.</param> /// <param name="bytes">Bytes.</param> public UID(String name, byte[] bytes, INsOrigin origin) : base(origin) { if (bytes.Length != 1 && bytes.Length != 2 && bytes.Length != 4 && bytes.Length != 8) { throw new ArgumentException("Type argument is not valid."); } this.name = name; this.bytes = bytes; }
/// <summary> /// Initializes a new instance of the <see cref="Claunia.PropertyList.UID"/> class using an unsigned 16-bit number. /// </summary> /// <param name="name">Name.</param> /// <param name="number">Unsigned 16-bit number.</param> public UID(String name, ushort number, INsOrigin origin) : base(origin) { this.name = name; if (number <= byte.MaxValue) { this.bytes = new[] { (byte)number } } ; else { this.bytes = BitConverter.GetBytes(number).Reverse().ToArray(); } }
/// <summary> /// Initializes a new instance of the <see cref="Claunia.PropertyList.UID"/> class using a signed 32-bit number. /// </summary> /// <param name="name">Name.</param> /// <param name="number">Signed 32-bit number.</param> public UID(String name, int number, INsOrigin origin) : base(origin) { this.name = name; if (number >= sbyte.MinValue && number <= sbyte.MaxValue) { this.bytes = new[] { (byte)number } } ; if (number >= short.MinValue && number <= short.MaxValue) { this.bytes = BitConverter.GetBytes((short)number).Reverse().ToArray(); } else { this.bytes = BitConverter.GetBytes(number).Reverse().ToArray(); } }
/// <summary> /// Creates a set and fill it with the given objects. /// </summary> /// <param name="objects">The objects to populate the set.</param> public NSSet(INsOrigin origin, params NSObject[] objects) : base(origin) { set = new List <NSObject>(objects); }
/// <summary> /// Creates an empty set. /// </summary> /// <param name="ordered">Should the set be ordered on operations?</param> public NSSet(bool ordered, INsOrigin origin) : base(origin) { this.ordered = ordered; set = new List <NSObject>(); }
/// <summary> /// Creates a NSString from a string. /// </summary> /// <param name="text">The string that will be contained in the NSString.</param> public NSString(string text, INsOrigin origin = null) : base(origin) { content = text; }
/// <summary> /// Creates the NSData object from the binary representation of it. /// </summary> /// <param name="bytes">The raw data contained in the NSData object.</param> public NSData(byte[] bytes, INsOrigin origin = null) : base(origin) { this.bytes = bytes; }
protected NSObject(INsOrigin origin = null) { Origin = origin; }
public NSArray(NSObject[] a, INsOrigin origin = null) : base(origin) { array = new List <NSObject>(a); }
/// <summary> /// Creates an empty array of the given length. /// </summary> /// <param name="length">The number of elements this array will be able to hold.</param> public NSArray(int length, INsOrigin origin = null) : base(origin) { array = new List <NSObject>(length); }
/// <summary> /// Creates a date from its binary representation. /// </summary> /// <param name="bytes">bytes The date bytes</param> public NSDate(byte[] bytes, INsOrigin origin = null) : base(origin) { //dates are 8 byte big-endian double, seconds since the epoch date = EPOCH.AddSeconds(BinaryPropertyListParser.ParseDouble(bytes)); }
/// <summary> /// Parses a date from its textual representation. /// That representation has the following pattern: <code>yyyy-MM-dd'T'HH:mm:ss'Z'</code> /// </summary> /// <param name="textRepresentation">The textual representation of the date (ISO 8601 format)</param> /// <exception cref="FormatException">When the date could not be parsed, i.e. it does not match the expected pattern.</exception> public NSDate(String textRepresentation, INsOrigin origin = null) : base(origin) { date = ParseDateString(textRepresentation); }
/// <summary> /// Creates a NSData object from its textual representation, which is a Base64 encoded amount of bytes. /// </summary> /// <param name="base64">The Base64 encoded contents of the NSData object.</param> /// <exception cref="FormatException">When the given string is not a proper Base64 formatted string.</exception> public NSData(string base64, INsOrigin origin = null) : base(origin) { bytes = Convert.FromBase64String(base64); }
/// <summary> /// Initializes a new instance of the <see cref="Claunia.PropertyList.UID"/> class using a signed 8-bit number. /// </summary> /// <param name="name">Name.</param> /// <param name="number">Unsigned 8-bit number.</param> public UID(String name, sbyte number, INsOrigin origin) : base(origin) { this.name = name; this.bytes = new[] { (byte)number }; }
/// <summary> /// Creates a NSString from its binary representation. /// </summary> /// <param name="bytes">The binary representation.</param> /// <param name="encoding">The encoding of the binary representation, the name of a supported charset.</param> /// <exception cref="ArgumentException">The encoding charset is invalid or not supported by the underlying platform.</exception> public NSString(byte[] bytes, String encoding, INsOrigin origin = null) : base(origin) { Encoding enc = Encoding.GetEncoding(encoding); content = enc.GetString(bytes); }
/// <summary> /// Creates a new empty NSDictionary. /// </summary> public NSDictionary(INsOrigin nsOrigin = null) : base(nsOrigin) { dict = new Dictionary <string, NSObject>(); keys = new Dictionary <string, NSString>(); }