Example #1
0
    public static object parseBinaryDate(int headerPosition)
    {
        byte[] buffer = objectTable.GetRange(headerPosition + 1, 8).ToArray();
        Array.Reverse(buffer);
        double   appleTime = BitConverter.ToDouble(buffer, 0);
        DateTime result    = PlistDateConverter.ConvertFromAppleTimeStamp(appleTime);

        return(result);
    }
Example #2
0
    public static byte[] writeBinaryDate(DateTime obj)
    {
        List <byte> buffer = new List <byte>(RegulateNullBytes(BitConverter.GetBytes(PlistDateConverter.ConvertToAppleTimeStamp(obj)), 8));

        buffer.Reverse();
        buffer.Insert(0, 0x33);
        objectTable.InsertRange(0, buffer);
        return(buffer.ToArray());
    }
Example #3
0
        private Dictionary <string, object> CreateDictionary()
        {
            const int largeCollectionSize = 18;

            Dictionary <string, object> dict      = new Dictionary <string, object>();
            Dictionary <string, object> largeDict = new Dictionary <string, object>();
            List <object> largeArray = new List <object>();

            for (int i = 0; i < largeCollectionSize; i++)
            {
                largeArray.Add(i);
                string key = i.ToString();
                if (i < 10)
                {
                    key = "0" + i.ToString();
                }
                largeDict.Add(key, i);
            }

            using (BinaryReader br = new BinaryReader(File.OpenRead(sourceImage)))
            {
                dict.Add("testImage", br.ReadBytes((int)br.BaseStream.Length));
            }
            dict.Add("testDate", PlistDateConverter.ConvertFromAppleTimeStamp(338610664L));
            dict.Add("testInt", -3455);
            dict.Add("testDouble", 1.34223d);
            dict.Add("testBoolTrue", true);
            dict.Add("testBoolFalse", false);
            dict.Add("testString", "hello there");
            dict.Add("testArray", new List <object> {
                34, "string item in array"
            });
            dict.Add("testArrayLarge", largeArray);
            dict.Add("testDict", new Dictionary <string, object> {
                { "test string", "inner dict item" }
            });
            dict.Add("testDictLarge", largeDict);

            return(dict);
        }