コード例 #1
0
        /// <summary>
        /// 读取并解析plist 文件
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static IpaAppInfo ReadAndParsePlist(string path)
        {
            if (!Path.GetExtension(path).Contains("ipa"))
            {
                return(null);
            }
            var plistPath = GetDecodePlistPath(path);

            try
            {
                FileInfo     plist    = new FileInfo(plistPath);
                NSDictionary rootDict = (NSDictionary)PropertyListParser.Parse(plist);

                IpaAppInfo ipa = new IpaAppInfo();
                ipa.Path         = path;
                ipa.Size         = GetApkIpaSize(path);
                ipa.CFBundleName = rootDict.ObjectForKey("CFBundleName").ToString();
                ipa.CFBundleShortVersionString = rootDict.ObjectForKey("CFBundleShortVersionString").ToString();
                ipa.CFBundleVersion            = rootDict.ObjectForKey("CFBundleVersion").ToString();
                ipa.CFBundleIdentifier         = rootDict.ObjectForKey("CFBundleIdentifier").ToString();
                // 图标信息
                var icons = (NSDictionary)rootDict.ObjectForKey("CFBundleIcons");
                if (icons != null)
                {
                    NSDictionary iconsDict = (NSDictionary)icons.ObjectForKey("CFBundlePrimaryIcon");
                    if (iconsDict != null)
                    {
                        NSArray iconsFiels = (NSArray)iconsDict.ObjectForKey("CFBundleIconFiles");
                        ipa.CFBundleIconFiles = new List <string>();
                        foreach (var item in iconsFiels)
                        {
                            ipa.CFBundleIconFiles.Add(item.ToString());
                        }
                        ipa.CFBundleIconName     = iconsDict.ObjectForKey("CFBundleIconName").ToString();
                        ipa.CFBundleIconFullPath = GetDecodeIconPath(path, ipa.CFBundleIconFiles);
                    }
                }
                return(ipa);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(null);
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: duduodudu/Work
 private void Deocde_ios_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(_filePath) || !Path.GetExtension(_filePath).Contains("ipa"))
     {
         Choose_file_Click(null, null);
         return;
     }
     if (AppDeocder.ExtractZip(_filePath))
     {
         IpaAppInfo ipa = AppDeocder.ReadAndParsePlist(_filePath);
         if (ipa != null)
         {
             ios_CFBundleName.Text = ipa.CFBundleName;
             ios_CFBundleShortVersionString.Text = ipa.CFBundleShortVersionString;
             ios_CFBundleVersion.Text            = ipa.CFBundleVersion;
             if (!string.IsNullOrWhiteSpace(ipa.CFBundleIconFullPath))
             {
                 ios_CFBundleIconFiles.Image = Image.FromFile(ipa.CFBundleIconFullPath);
             }
         }
     }
 }