コード例 #1
0
ファイル: NSSet.cs プロジェクト: MaxWellHays/plist-cil
 /// <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
ファイル: UID.cs プロジェクト: MaxWellHays/plist-cil
 /// <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
ファイル: UID.cs プロジェクト: MaxWellHays/plist-cil
 /// <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
ファイル: UID.cs プロジェクト: MaxWellHays/plist-cil
 /// <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
ファイル: NSSet.cs プロジェクト: MaxWellHays/plist-cil
 /// <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
ファイル: NSSet.cs プロジェクト: MaxWellHays/plist-cil
 /// <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
ファイル: NSObject.cs プロジェクト: MaxWellHays/plist-cil
 protected NSObject(INsOrigin origin = null)
 {
     Origin = origin;
 }
コード例 #10
0
ファイル: NSArray.cs プロジェクト: MaxWellHays/plist-cil
 public NSArray(NSObject[] a, INsOrigin origin = null) : base(origin)
 {
     array = new List <NSObject>(a);
 }
コード例 #11
0
ファイル: NSArray.cs プロジェクト: MaxWellHays/plist-cil
 /// <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
ファイル: NSDate.cs プロジェクト: MaxWellHays/plist-cil
 /// <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
ファイル: NSDate.cs プロジェクト: MaxWellHays/plist-cil
 /// <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
ファイル: UID.cs プロジェクト: MaxWellHays/plist-cil
 /// <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>();
 }