Ejemplo n.º 1
0
        public void Read_WithWifiDevices_Works()
        {
            var data    = (NSDictionary)PropertyListParser.Parse("Muxer/devicelist-wifi.xml");
            var message = DeviceListMessage.Read(data);

            Assert.Collection(
                message.DeviceList,
                device =>
            {
                Assert.Equal(MuxerMessageType.Attached, device.MessageType);
                Assert.Equal(2, device.DeviceID);

                Assert.Equal(0, device.Properties.ConnectionSpeed);
                Assert.Equal(MuxerConnectionType.Network, device.Properties.ConnectionType);
                Assert.Equal(2, device.Properties.DeviceID);
                Assert.Equal("aa:aa:aa:aa:aa:aa@aaaa::aaaa:aaa:aaaa:aaaa._apple-mobdev2._tcp.local.", device.Properties.EscapedFullServiceName);
                Assert.Equal(39, device.Properties.InterfaceIndex);
                Assert.Equal(IPAddress.Parse("192.168.10.239"), device.Properties.IPAddress);
                Assert.Equal(0, device.Properties.LocationID);
                Assert.NotNull(device.Properties.NetworkAddress);
                Assert.Equal(0, device.Properties.ProductID);
                Assert.Equal("cccccccccccccccccccccccccccccccccccccccc", device.Properties.SerialNumber);
                Assert.Null(device.Properties.UDID);
                Assert.Null(device.Properties.USBSerialNumber);
            });
        }
Ejemplo n.º 2
0
 static void WriteApplePlist(Stream stream, AppleConfig config)
 {
     using (stream)
     {
         var plist = new NSDictionary();
         plist.Add("CFBundleDevelopmentRegion", "German");
         plist.Add("CFBundleExecutable", "MonoAppLauncher");
         plist.Add("CFBundleHelpBookFolder", $"{config.BundleName} Help");
         plist.Add("CFBundleHelpBookName", $"{config.BundleName} Help");
         plist.Add("CFBundleGetInfoString", $"{config.BundleName} {config.BundleVersion}");
         plist.Add("CFBundleIconFile", "app.icns");
         plist.Add("CFBundleIdentifier", config.BundleId);
         plist.Add("CFBundleInfoDictionaryVersion", "6.0");
         plist.Add("CFBundleName", config.BundleName);
         plist.Add("CFBundleShortVersionString", config.BundleVersion);
         var purl = new NSDictionary();
         purl.Add("CFBundleURLName", $"{config.BundleName} URL");
         var parray = new NSArray(new NSString(config.UrlPrefix));
         purl.Add("CFBundleURLSchemes", parray);
         var purls = new NSArray(purl);
         plist.Add("CFBundleURLTypes", purls);
         plist.Add("CFBundleVersion", config.BundleVersion);
         plist.Add("LSApplicationCategoryType", "public.app-category.business");
         plist.Add("LSMinimumSystemVersion", "10.7");
         var pMinVer = new NSDictionary();
         pMinVer.Add("i386", "10.7.0");
         pMinVer.Add("x86_64", "10.7.0");
         plist.Add("LSMinimumSystemVersionByArchitecture", pMinVer);
         plist.Add("NSHumanReadableCopyright", config.Copyright);
         PropertyListParser.SaveAsXml(plist, stream);
     }
 }
Ejemplo n.º 3
0
        XCodeInfo GetXcodeInfo(string path, bool selected)
        {
            var versionPlist = Path.Combine(path, "Contents", "version.plist");

            if (File.Exists(versionPlist))
            {
                NSDictionary rootDict             = (NSDictionary)PropertyListParser.Parse(versionPlist);
                string       cfBundleVersion      = rootDict.ObjectForKey("CFBundleVersion")?.ToString();
                string       cfBundleShortVersion = rootDict.ObjectForKey("CFBundleShortVersionString")?.ToString();
                string       productBuildVersion  = rootDict.ObjectForKey("ProductBuildVersion")?.ToString();

                if (NuGetVersion.TryParse(cfBundleVersion, out var v))
                {
                    return(new XCodeInfo(v, cfBundleShortVersion, productBuildVersion, path, selected));
                }
            }
            else
            {
                var infoPlist = Path.Combine(path, "Contents", "Info.plist");

                if (File.Exists(infoPlist))
                {
                    NSDictionary rootDict             = (NSDictionary)PropertyListParser.Parse(infoPlist);
                    string       cfBundleVersion      = rootDict.ObjectForKey("CFBundleVersion")?.ToString();
                    string       cfBundleShortVersion = rootDict.ObjectForKey("CFBundleShortVersionString")?.ToString();
                    if (NuGetVersion.TryParse(cfBundleVersion, out var v))
                    {
                        return(new XCodeInfo(v, cfBundleShortVersion, string.Empty, path, selected));
                    }
                }
            }
            return(null);
        }
Ejemplo n.º 4
0
 private bool RemoveRemoteFiles(ListView.SelectedListViewItemCollection items)
 {
     try
     {
         var refresh = false;
         // connect
         var device = CurrentDevice;
         if (device == null)
         {
             return(false);
         }
         // start service
         LibiMobileDevice.Instance.Afc.afc_client_start_service(device, out AfcClientHandle client, PROGRAMNAME).ThrowOnError();
         var data = DownloadFile(client, RINGTONESPLIST);
         // download Ringtones.plist
         var plist = PropertyListParser.Parse(data);
         foreach (ListViewItem item in items)
         {
             // delete file
             DeleteFile(client, Combine(RINGTONESPATH, item.Name));
             // remove plist entry
             ((NSDictionary)((NSDictionary)plist)["Ringtones"]).Remove(item.Name);
             refresh = true;
         }
         if (refresh)
         {
             // upload new Ringtones.plist
             var stream = new MemoryStream();
             PropertyListParser.SaveAsBinary(plist, stream);
             UploadFile(client, RINGTONESPLIST, stream.ToArray());
         }
         return(refresh);
     }
     catch (Exception ex) { HandleException(ex); return(false); }
 }
Ejemplo n.º 5
0
        private List <Beat> InitBeats()
        {
            var beatArray  = (NSArray)PropertyListParser.Parse(Path.Combine(Metadata.SongPath, "beats.plist"));
            var ghostArray = (NSArray)PropertyListParser.Parse(Path.Combine(Metadata.SongPath, "ghost.plist"));

            return(Beat.FromNSArrays(beatArray, ghostArray));
        }
Ejemplo n.º 6
0
        public void Read_Works()
        {
            var message = DevicePairedMessage.Read((NSDictionary)PropertyListParser.Parse("Muxer/paired.xml"));

            Assert.Equal(3, message.DeviceID);
            Assert.Equal(MuxerMessageType.Paired, message.MessageType);
        }
        public void Start()
        {
            MomentDBUtil.LoadMomentSQLite(userHash);
            DirectoryInfo directoryInfo = new DirectoryInfo("Plist");

            foreach (FileInfo momentPlistFile in directoryInfo.GetFiles())
            {
                NSObject         plist      = PropertyListParser.Parse(momentPlistFile);
                MomentSerializer serializer = new MomentSerializer((NSDictionary)plist);
                MomentInfo       momentInfo = serializer.SerializMoment();

                if (momentInfo != null &&
                    (
                        !(skipSharedItem && momentInfo.momentType == Enum.MomentType.Shared) || (momentInfo.sharedItem != null && momentInfo.sharedItem.sharedFrom == "微视"))
                    )
                {
                    LogUtil.Log($"解析{momentInfo.momentId}");
                    DownloadFile(momentInfo);
                    bigOne.Add(momentInfo);
                    string momentJson = JsonConvert.SerializeObject(momentInfo);
                    File.WriteAllText($"Json\\{momentInfo.momentId}.json", momentJson, Encoding.UTF8);
                }
            }
            string bigOneJson = JsonConvert.SerializeObject(bigOne);

            bigOneJson = "var moment_data = " + bigOneJson;
            File.WriteAllText($"View\\static\\script\\data.js", bigOneJson, Encoding.UTF8);
        }
        public static NSDictionary login(string appleId, string password)
        {
            NSDictionary nSDictionary;

            try
            {
                HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("https://idmsa.apple.com/IDMSWebAuth/clientDAW.cgi");
                httpWebRequest.Method      = "POST";
                httpWebRequest.ContentType = "application/x-www-form-urlencoded";
                string str = string.Concat(new string[] { "format=plist&appIdKey=", AppleService.app_id_key, "&appleId=", HttpUtility.UrlEncode(appleId), "&password="******"&userLocale=en_US&protocolVersion=", AppleService.protocol_version_daw2 });
                httpWebRequest.UserAgent = "Xcode";
                httpWebRequest.Accept    = "text/x-xml-plist";
                httpWebRequest.Headers.Add("Accept-Language", "en-us");
                httpWebRequest.KeepAlive = true;
                httpWebRequest.GetRequestStream().Write(Encoding.UTF8.GetBytes(str), 0, Encoding.UTF8.GetBytes(str).Count <byte>());
                HttpWebResponse response = (HttpWebResponse)httpWebRequest.GetResponse();
                string          end      = (new StreamReader(response.GetResponseStream())).ReadToEnd();
                File.WriteAllText(string.Concat(AppConst.m_rootPath, "\\tmp\\data.plist"), end);
                FileInfo fileInfo = new FileInfo(string.Concat(AppConst.m_rootPath, "\\tmp\\data.plist"));
                httpWebRequest.GetRequestStream().Close();
                httpWebRequest.GetRequestStream().Dispose();
                response.Close();
                response.Dispose();
                nSDictionary = (NSDictionary)PropertyListParser.Parse(fileInfo);
            }
            catch (Exception exception)
            {
                ProjectData.SetProjectError(exception);
                Interaction.MsgBox(exception.Message, MsgBoxStyle.OkOnly, null);
                nSDictionary = null;
                ProjectData.ClearProjectError();
            }
            return(nSDictionary);
        }
Ejemplo n.º 9
0
        public static void TestXml()
        {
            // Parse an example plist file
            NSObject x = PropertyListParser.Parse(new FileInfo("test-files/test1.plist"));

            // check the data in it
            NSDictionary d = (NSDictionary)x;

            Assert.True(d.Count == 5);
            Assert.True(((NSString)d.ObjectForKey("keyA")).ToString().Equals("valueA"));
            Assert.True(((NSString)d.ObjectForKey("key&B")).ToString().Equals("value&B"));
            Assert.True(((NSDate)d.ObjectForKey("date")).Date.ToUniversalTime().Equals(new DateTime(2011, 11, 28, 10, 21, 30, DateTimeKind.Utc)) ||
                        ((NSDate)d.ObjectForKey("date")).Date.ToUniversalTime().Equals(new DateTime(2011, 11, 28, 9, 21, 30, DateTimeKind.Utc)));
            Assert.True(ArrayEquals(((NSData)d.ObjectForKey("data")).Bytes,
                                    new byte[] { 0x00, 0x00, 0x00, 0x04, 0x10, 0x41, 0x08, 0x20, (byte)0x82 }));
            NSArray a = (NSArray)d.ObjectForKey("array");

            Assert.True(a.Count == 4);
            Assert.True(a.ObjectAtIndex(0).Equals(new NSNumber(true)));
            Assert.True(a.ObjectAtIndex(1).Equals(new NSNumber(false)));
            Assert.True(a.ObjectAtIndex(2).Equals(new NSNumber(87)));
            Assert.True(a.ObjectAtIndex(3).Equals(new NSNumber(3.14159)));

            // read/write it, make sure we get the same thing
            PropertyListParser.SaveAsXml(x, new FileInfo("test-files/out-testXml.plist"));
            NSObject y = PropertyListParser.Parse(new FileInfo("test-files/out-testXml.plist"));

            Assert.True(x.Equals(y));
        }
Ejemplo n.º 10
0
        public static void TestIssue22()
        {
            NSDictionary x1 = (NSDictionary)PropertyListParser.Parse(new FileInfo("test-files/issue22-emoji.plist"));
            NSDictionary x2 =
                (NSDictionary)PropertyListParser.Parse(new FileInfo("test-files/issue22-emoji-xml.plist"));

            PropertyListParser.SaveAsBinary(x1, new FileInfo("test-files/out-testIssue22.plist"));
            NSDictionary y1 = (NSDictionary)PropertyListParser.Parse(new FileInfo("test-files/out-testIssue22.plist"));

            PropertyListParser.SaveAsXml(x2, new FileInfo("test-files/out-testIssue22-xml.plist"));
            NSDictionary y2 =
                (NSDictionary)PropertyListParser.Parse(new FileInfo("test-files/out-testIssue22-xml.plist"));

            Assert.True(x1.Equals(x2));
            Assert.True(x1.Equals(y1));
            Assert.True(x1.Equals(y2));
            Assert.True(x2.Equals(y1));
            Assert.True(x2.Equals(y2));

            string emojiString = "Test Test, \uD83D\uDE30\u2754\uD83D\uDC4D\uD83D\uDC4E\uD83D\uDD25";

            Assert.Equal(emojiString, x1.ObjectForKey("emojiString").ToString());
            Assert.Equal(emojiString, x2.ObjectForKey("emojiString").ToString());
            Assert.Equal(emojiString, y1.ObjectForKey("emojiString").ToString());
            Assert.Equal(emojiString, y2.ObjectForKey("emojiString").ToString());
        }
Ejemplo n.º 11
0
        public static void TestIssue38()
        {
            NSDictionary dict    = (NSDictionary)PropertyListParser.Parse(new FileInfo("test-files/issue33.pbxproj"));
            NSObject     fileRef = ((NSDictionary)((NSDictionary)dict.Get("objects")).Get("65541A9C16D13B8C00A968D5")).Get("fileRef");

            Assert.True(fileRef.Equals(new NSString("65541A9B16D13B8C00A968D5")));
        }
Ejemplo n.º 12
0
 static void ParseEmptyStreamTestDelegate()
 {
     using (MemoryStream stream = new MemoryStream())
     {
         PropertyListParser.Parse(stream);
     }
 }
Ejemplo n.º 13
0
        public void Read_Works()
        {
            var result = ResultMessage.Read(
                (NSDictionary)PropertyListParser.Parse("Muxer/result.xml"));

            Assert.Equal(MuxerMessageType.Result, result.MessageType);
            Assert.Equal(MuxerError.Success, result.Number);
        }
Ejemplo n.º 14
0
        public static void testAsciiUtf8CharactersInQuotedString()
        {
            NSObject     x = PropertyListParser.Parse(new FileInfo("test-files/test-ascii-utf8.plist"));
            NSDictionary d = (NSDictionary)x;

            Assert.Equal(2, d.Count);
            Assert.Equal("JÔÖú@2x.jpg", d.ObjectForKey("path").ToString());
            Assert.Equal("QÔÖú@2x 啕.jpg", d.ObjectForKey("Key QÔÖª@2x 䌡").ToString());
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 格式化plist为XML
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        private static string FormatPlist(string path)
        {
            var    old_one = new FileInfo(path);
            var    plist   = PropertyListParser.Parse(old_one);
            string xml     = plist.ToXmlPropertyList();

            File.WriteAllText(old_one.DirectoryName + "\\" + old_one.Name + ".xml", xml);
            return(xml);
        }
Ejemplo n.º 16
0
        public static void AddRequiredDeviceCapability(IIgorModule ModuleInst, string PlistPath, string NewRequiredDeviceCapability)
        {
            if (IgorAssert.EnsureTrue(ModuleInst, File.Exists(PlistPath), "Plist " + PlistPath + " doesn't exist!"))
            {
                FileInfo PlistFileInfo = new FileInfo(PlistPath);

                NSObject PlistRoot = PropertyListParser.Parse(PlistFileInfo);

                if (IgorAssert.EnsureTrue(ModuleInst, PlistRoot != null, "Plist " + PlistPath + " could not be parsed!"))
                {
                    if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSDictionary).IsAssignableFrom(PlistRoot.GetType()), "Plist " + PlistPath + " root object is not a dictionary."))
                    {
                        NSDictionary RootDictionary = (NSDictionary)PlistRoot;

                        if (IgorAssert.EnsureTrue(ModuleInst, RootDictionary != null, "Plist root is not a dictionary."))
                        {
                            if (IgorAssert.EnsureTrue(ModuleInst, RootDictionary.ContainsKey("UIRequiredDeviceCapabilities"), "Can't find UIRequiredDeviceCapabilities in plist."))
                            {
                                NSObject DeviceCapabilities = RootDictionary.Get("UIRequiredDeviceCapabilities");

                                if (IgorAssert.EnsureTrue(ModuleInst, DeviceCapabilities != null, "Plist does not contain UIRequiredDeviceCapabilities."))
                                {
                                    if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSArray).IsAssignableFrom(DeviceCapabilities.GetType()), "Plist UIRequiredDeviceCapabilities is not an array."))
                                    {
                                        NSArray CapabilitiesArray = (NSArray)DeviceCapabilities;

                                        if (IgorAssert.EnsureTrue(ModuleInst, CapabilitiesArray != null, "UIRequiredDeviceCapabilities is not an array."))
                                        {
                                            if (CapabilitiesArray.ContainsObject(new NSString(NewRequiredDeviceCapability)))
                                            {
                                                IgorDebug.Log(ModuleInst, "UIRequiredDeviceCapabilities already contains " + NewRequiredDeviceCapability);
                                            }
                                            else
                                            {
                                                NSSet NewCapabilitiesSet = new NSSet(CapabilitiesArray.GetArray());

                                                NewCapabilitiesSet.AddObject(new NSString(NewRequiredDeviceCapability));

                                                NSArray NewCapabilitiesArray = new NSArray(NewCapabilitiesSet.AllObjects());

                                                RootDictionary["UIRequiredDeviceCapabilities"] = NewCapabilitiesArray;

                                                IgorRuntimeUtils.DeleteFile(PlistPath);

                                                PropertyListParser.SaveAsXml(RootDictionary, PlistFileInfo);

                                                IgorDebug.Log(ModuleInst, NewRequiredDeviceCapability + " added to UIRequiredDeviceCapabilities.");
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 17
0
 private List <Track> InitTracks()
 {
     using (var x = OpenZip())
         using (var s = x.GetEntry(_basePath + "/tracks.plist").Open())
         {
             var tracksArray = (NSArray)PropertyListParser.Parse(s);
             return(Track.FromNSArray(tracksArray, path => x.GetEntry($"{_basePath}/" + path) != null));
         }
 }
Ejemplo n.º 18
0
        public static void TestIssue18()
        {
            NSNumber x = new NSNumber(-999);

            PropertyListParser.SaveAsBinary(x, new FileInfo("test-files/out-testIssue18.plist"));
            NSObject y = PropertyListParser.Parse(new FileInfo("test-files/out-testIssue18.plist"));

            Assert.True(x.Equals(y));
        }
        public static T DeserializePlist <T>(this string input)
        {
            var plist = PropertyListParser.Parse(Encoding.UTF8.GetBytes(input));

            var obj = plist.ToObject();

            var json = JObject.FromObject(obj);

            return(json.ToObject <T>());
        }
Ejemplo n.º 20
0
        public static void TestBinary()
        {
            NSObject x = PropertyListParser.Parse(new FileInfo("test-files/test1.plist"));

            // save and load as binary
            PropertyListParser.SaveAsBinary(x, new FileInfo("test-files/out-testBinary.plist"));
            NSObject y = PropertyListParser.Parse(new FileInfo("test-files/out-testBinary.plist"));

            Assert.True(x.Equals(y));
        }
Ejemplo n.º 21
0
        public void LoadFullSongInfo(SongInfo song, string songPath)
        {
            var infoDict = PropertyListParser.Parse(Path.Combine(songPath, "info.plist")) as NSDictionary;

            song.Tempo       = infoDict.String("bpm");
            song.WrittenBy   = infoDict.String("writtenBy");
            song.PublishedBy = infoDict.String("publishedBy");
            song.CourtesyOf  = infoDict.String("courtesyOf");

            if (!File.Exists(Path.Combine(songPath, "tuning.plist")))
            {
                return;
            }

            var tuningDict = PropertyListParser.Parse(Path.Combine(songPath, "tuning.plist")) as NSDictionary;

            //TODO: Support Array tunnings.

            /*
             * <dict>
             * <key>notes</key>
             * <array>
             *        <integer>40</integer>
             *        <integer>45</integer>
             *        <integer>50</integer>
             *        <integer>55</integer>
             * </array>
             * <key>offset</key>
             * <real>0.0</real>
             * </dict>
             */
            if (!(tuningDict["notes"] is NSDictionary))
            {
                return;
            }

            var notesDict = tuningDict["notes"] as NSDictionary;

            song.Tunings = new List <string>();
            foreach (var instrumentKey in notesDict.Keys)
            {
                var instrumentDict = notesDict[instrumentKey] as NSDictionary;
                var tunings        = instrumentDict.Where((p) => p.Value is NSArray);

                foreach (var tuning in tunings)
                {
                    string songTuning = string.Empty;
                    foreach (var tuningEntry in tuning.Value as NSArray)
                    {
                        songTuning += tuningEntry.ToString() + " ";
                    }
                    song.Tunings.Add(songTuning);
                }
            }
        }
Ejemplo n.º 22
0
        public virtual void GenerateAndSavePlist(string PlistFileName, string IPAName, string IconName, string BundleIdentifier, string BundleVersion, string BundleDisplayName)
        {
            string HTTPRoot = GetParamOrConfigString(OTAHTTPRootFlag, "iOS OTA HTTP root path is not set.  Can't generate the OTA manifest.");

            if (!HTTPRoot.EndsWith("/"))
            {
                HTTPRoot += "/";
            }

            if (HTTPRoot.StartsWith("http:"))
            {
                HTTPRoot = HTTPRoot.Replace("http:", "https:");
            }

            if (!HTTPRoot.StartsWith("https://"))
            {
                HTTPRoot = "https://" + HTTPRoot;
            }

            NSDictionary SoftwarePackageDict = new NSDictionary();

            SoftwarePackageDict.Add("kind", new NSString("software-package"));
            SoftwarePackageDict.Add("url", new NSString(HTTPRoot + IPAName));

            NSDictionary DisplayImageDict = new NSDictionary();

            DisplayImageDict.Add("kind", new NSString("display-image"));
            DisplayImageDict.Add("needs-shine", new NSNumber(false));
            DisplayImageDict.Add("url", new NSString(HTTPRoot + IconName));

            NSArray AssetsArray = new NSArray(new NSObject[] { SoftwarePackageDict, DisplayImageDict });

            NSDictionary MetadataDict = new NSDictionary();

            MetadataDict.Add("bundle-identifier", new NSString(BundleIdentifier));
            MetadataDict.Add("bundle-version", new NSString(BundleVersion));
            MetadataDict.Add("kind", new NSString("software"));
            MetadataDict.Add("title", new NSString(BundleDisplayName));

            NSDictionary Item0Dict = new NSDictionary();

            Item0Dict.Add("assets", AssetsArray);
            Item0Dict.Add("metadata", MetadataDict);

            NSArray ItemsArray = new NSArray(new NSObject[] { Item0Dict });

            NSDictionary RootDictionary = new NSDictionary();

            RootDictionary.Add("items", ItemsArray);

            FileInfo NewPlist = new FileInfo(PlistFileName);

            PropertyListParser.SaveAsXml(RootDictionary, NewPlist);
        }
Ejemplo n.º 23
0
        public static void TestIssue7()
        {
            // also a test for issue 12
            // the issue4 test has a UTF-16-BE string in its binary representation
            NSObject x = PropertyListParser.Parse(new FileInfo("test-files/issue4.plist"));

            PropertyListParser.SaveAsBinary(x, new FileInfo("test-files/out-testIssue7.plist"));
            NSObject y = PropertyListParser.Parse(new FileInfo("test-files/out-testIssue7.plist"));

            Assert.True(x.Equals(y));
        }
Ejemplo n.º 24
0
        public static void TestGnuStepASCIIWriting()
        {
            FileInfo     inf  = new FileInfo("test-files/test1.plist");
            FileInfo     outf = new FileInfo("test-files/out-test1-ascii-gnustep.plist");
            NSDictionary x    = (NSDictionary)PropertyListParser.Parse(inf);

            PropertyListParser.SaveAsGnuStepASCII(x, outf);
            NSObject y = PropertyListParser.Parse(outf);

            Assert.True(x.Equals(y));
        }
Ejemplo n.º 25
0
        /// <summary>
        /// 将plist文件转换为xml文件
        /// </summary>
        /// <param name="path">plist文件位置</param>
        /// <param name="saveToFile">是否存储转换的xml文件</param>
        /// <returns></returns>
        public string Plist2XML(string path, bool saveToFile)
        {
            FileInfo plistFileInfo = new FileInfo(path);
            NSObject plist         = PropertyListParser.Parse(plistFileInfo);
            string   xml           = plist.ToXmlPropertyList();

            if (saveToFile)
            {
                File.WriteAllText(plistFileInfo.DirectoryName + "\\" + plistFileInfo.Name + ".xml", xml);
            }
            return(xml);
        }
Ejemplo n.º 26
0
        public ICollection <HistoryEntry> GetBrowserHistory(DateTime?startTime, DateTime?endTime)
        {
            List <HistoryEntry> entryList = new List <HistoryEntry>();

            if (string.IsNullOrEmpty(_safariFullPlistFilePath))
            {
                return(entryList);
            }

            var rootDict   = (NSDictionary)PropertyListParser.Parse(_safariFullPlistFilePath);
            var entryArray = ((NSArray)rootDict.ObjectForKey(PLIST_ARRAY_KEY_NAME));

            foreach (var nsEntry in entryArray)
            {
                Uri      uri;
                DateTime lastVisit;
                string   title;
                int?     visitCount;

                var entryAsDict = (NSDictionary)nsEntry;

                if (!DateUtils.TryParsePlistToLocal(entryAsDict.ObjectForKey("lastVisitedDate").ToString(), out lastVisit))
                {
                    continue;
                }
                if (!DateUtils.IsEntryInTimelimit(lastVisit, startTime, endTime))
                {
                    continue;
                }

                try
                {
                    uri = new Uri(entryAsDict.ObjectForKey(string.Empty).ToString());
                }
                catch (UriFormatException)
                {
                    continue;
                }

                title = entryAsDict.TryGetValue("title", out NSObject nsTitle)
                    ? nsTitle.ToString()
                    : null;

                visitCount = int.TryParse(entryAsDict.ObjectForKey("visitCount").ToString(), out int outVal)
                    ? (int?)outVal
                    : null;

                HistoryEntry entry = new HistoryEntry(uri, title, lastVisit, visitCount, Browser.Safari);
                entryList.Add(entry);
            }

            return(entryList);
        }
Ejemplo n.º 27
0
        public async Task Decode()
        {
            //https://github.com/claunia/plist-cil
            //https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/AboutInformationPropertyListFiles.html
            Console.WriteLine("DefaultIPADecoder.Decode() decode start.");

            dataModel = new PackageDataModel();

            Console.WriteLine("DefaultIPADecoder.Decode() Extract info.plist start.");

            using (ZipArchive zipObject = ZipFile.Open(targetFilePath.OriginalString, ZipArchiveMode.Read, Encoding.UTF8))
            {
                IEnumerable <ZipArchiveEntry> listEntry = zipObject.Entries.Where(x => x.Name.Equals("Info.plist"));
                Console.WriteLine("DefaultIPADecoder.Decode() all plist entries: ");
                foreach (ZipArchiveEntry zae in listEntry)
                {
                    Console.WriteLine(zae.FullName);
                }
                Console.WriteLine("DefaultIPADecoder.Decode() all plist ends here");
                ZipArchiveEntry targetEntry = null;
                foreach (ZipArchiveEntry zae in listEntry)
                {
                    if (Path.GetDirectoryName(zae.FullName).Trim('/').EndsWith(".app"))
                    {
                        targetEntry = zae;
                        Console.WriteLine("DefaultIPADecoder.Decode() selected entry: " + zae.FullName);
                        break;
                    }
                }

                if (targetEntry != null)
                {
                    NSDictionary rootDoc = null;
                    using (Stream sourceStream = targetEntry.Open())
                        using (MemoryStream byteStream = new MemoryStream())
                        {
                            await sourceStream.CopyToAsync(byteStream);

                            rootDoc = (NSDictionary)PropertyListParser.Parse(byteStream.ToArray());
                            dataModel.RawDumpBadging = rootDoc.ToXmlPropertyList();
                            Console.WriteLine("DefaultIPADecoder.Decode() raw: \r\n" + dataModel.RawDumpBadging);
                        }

                    if (rootDoc != null)
                    {
                        //Core Method, read data
                        PListCilUtil.ReadNSData(dataModel, rootDoc);
                    }
                }
            }

            decodeProgressCallbackEvent?.Invoke();
        }
Ejemplo n.º 28
0
        private List <Section> InitSections()
        {
            var sectionArray = (NSArray)PropertyListParser.Parse(Path.Combine(Metadata.SongPath, "sections.plist"));

            return(sectionArray.GetArray().OfType <NSDictionary>().Select(dict => new Section
            {
                BeatIdx = dict.Int("beat") ?? 0,
                Beat = Beats[dict.Int("beat") ?? 0],
                Number = dict.Int("number") ?? 0,
                Type = dict.Int("type") ?? 0
            }).ToList());
        }
Ejemplo n.º 29
0
        private MemoryStream GeneratePlist()
        {
            NSDictionary root                = new NSDictionary();
            NSArray      plCatalogs          = GetCatalogs();
            NSArray      plConditionals      = GetConditionals();
            NSArray      plIncludedManifests = GetIncludedManifests();
            NSArray      plManagedInstalls   = GetManagedInstalls();
            NSArray      plManagedUninstalls = GetManagedUninstalls();
            NSArray      plManagedUpdates    = GetManagedUpdates();
            NSArray      plOptionalInstalls  = GetOptionlInstalls();

            if (plCatalogs.Count > 0)
            {
                root.Add("catalogs", plCatalogs);
            }
            if (plConditionals.Count > 0)
            {
                root.Add("conditional_items", plConditionals);
            }
            if (plIncludedManifests.Count > 0)
            {
                root.Add("included_manifests", plIncludedManifests);
            }
            if (plManagedInstalls.Count > 0)
            {
                root.Add("managed_installs", plManagedInstalls);
            }
            if (plManagedUninstalls.Count > 0)
            {
                root.Add("managed_uninstalls", plManagedUninstalls);
            }
            if (plManagedUpdates.Count > 0)
            {
                root.Add("managed_updates", plManagedUpdates);
            }
            if (plOptionalInstalls.Count > 0)
            {
                root.Add("optional_installs", plOptionalInstalls);
            }

            var rdr = new MemoryStream();

            try
            {
                PropertyListParser.SaveAsXml(root, rdr);
            }
            catch (Exception ex)
            {
                Logger.Log(ex.Message);
            }

            return(rdr);
        }
Ejemplo n.º 30
0
        private void LoadSections(JcfMedia media, string songPath)
        {
            var sectionArray = PropertyListParser.Parse(Path.Combine(songPath, "sections.plist")) as NSArray;

            media.Sections = sectionArray.OfType <NSDictionary>().Select(dict => new Section
            {
                BeatIdx = dict.Int("beat") ?? int.Parse(dict.String("beat")),     // Key can sometimes be string instead of integer.
                Beat    = media.Beats[dict.Int("beat") ?? int.Parse(dict.String("beat"))],
                Number  = dict.Int("number") ?? int.Parse(dict.String("number")), // Key can sometimes be string instead of integer.
                Type    = dict.Int("type").Value
            }).ToList();
        }