Esempio n. 1
0
        /// <summary>
        /// 转换文件列表内容为文件记录信息
        /// </summary>
        /// <param name="content"></param>
        /// <returns></returns>
        public static Dictionary <string, FileRecord> ConvertToFileRecords(string content)
        {
            Dictionary <string, FileRecord> fileRecords = new Dictionary <string, FileRecord>();

            Mono.Xml.SecurityParser sp = new Mono.Xml.SecurityParser();
            if (string.IsNullOrEmpty(content))
            {
                return(fileRecords);
            }
            sp.LoadXml(content);
            SecurityElement root = sp.ToXml();

            if (root.Children != null)
            {
                foreach (SecurityElement child in root.Children)
                {
                    SecurityElement fileName = child.SearchForChildByTag("NAME");
                    SecurityElement md5      = child.SearchForChildByTag("MD5");
                    SecurityElement size     = child.SearchForChildByTag("SIZE");

                    if (fileName == null || md5 == null || size == null)
                    {
                        Debug.LogError("'FileList.xml' has error!");
                        continue;
                    }

                    FileRecord record = new FileRecord();
                    record.FileName = fileName.Text;
                    record.MD5      = md5.Text;
                    record.Size     = long.Parse(size.Text);
                    fileRecords.Add(record.FileName, record);
                }
            }
            return(fileRecords);
        }
Esempio n. 2
0
 public static bool ConvertXmlTextToBinaryFile(string InXmlText, string InBinaryPath)
 {
     Mono.Xml.SecurityParser parser = new Mono.Xml.SecurityParser();
     parser.LoadXml(InXmlText);
     return(ConvertSecurityElementToBinaryFile(parser.root, InBinaryPath));
 }