예제 #1
0
 /// <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();
     }
 }
예제 #2
0
 /// <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;
 }
예제 #3
0
 /// <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();
     }
 }
예제 #4
0
 /// <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();
     }
 }
예제 #5
0
 /// <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);
 }
예제 #6
0
 /// <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>();
 }
예제 #7
0
 /// <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;
 }
예제 #8
0
 /// <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;
 }
예제 #9
0
 protected NSObject(INsOrigin origin = null)
 {
     Origin = origin;
 }
예제 #10
0
 public NSArray(NSObject[] a, INsOrigin origin = null) : base(origin)
 {
     array = new List <NSObject>(a);
 }
예제 #11
0
 /// <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);
 }
예제 #12
0
 /// <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));
 }
예제 #13
0
 /// <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);
 }
예제 #14
0
 /// <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);
 }
예제 #15
0
 /// <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 };
 }
예제 #16
0
        /// <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);
        }
예제 #17
0
 /// <summary>
 /// Creates a new empty NSDictionary.
 /// </summary>
 public NSDictionary(INsOrigin nsOrigin = null) : base(nsOrigin)
 {
     dict = new Dictionary <string, NSObject>();
     keys = new Dictionary <string, NSString>();
 }