Example #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);
        }
Example #2
0
 public static Mono.Xml.SecurityParser LoadXmlFromBinaryFile(string InPath)
 {
     Mono.Xml.SecurityParser inParser = new Mono.Xml.SecurityParser();
     if (!LoadXmlFromBinaryFile(inParser, InPath))
     {
         return(null);
     }
     return(inParser);
 }
Example #3
0
 public static bool LoadXmlFromBinaryBuffer(Mono.Xml.SecurityParser InParser, byte[] InFileBytes, string InPath = "")
 {
     if ((InFileBytes != null) && (InFileBytes.Length >= 4))
     {
         using (MemoryStream stream = new MemoryStream(InFileBytes))
         {
             using (BinaryReader reader = new BinaryReader(stream))
             {
                 SecurityElement element      = LoadRootSecurityElement(reader);
                 object[]        inParameters = new object[] { InPath };
                 DebugHelper.Assert(element != null, "Failed load root Security Element in file: {0}", inParameters);
                 if (element != null)
                 {
                     InParser.root = element;
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Example #4
0
        public static System.Security.SecurityElement GetXmlNode(ParticleSystemSettings settings, string customNodeName = "")
        {
            Mono.Xml.SecurityParser parser = new Mono.Xml.SecurityParser();
            Mono.Xml.SmallXmlParser.AttrListImpl attrList = new Mono.Xml.SmallXmlParser.AttrListImpl();

            if (!string.IsNullOrEmpty(settings.particleName))
            {
                attrList.Add(M.Attri_ParticleName, settings.particleName);
            }

            if (!string.IsNullOrEmpty(settings.castKeyFrame))
            {
                attrList.Add(M.Attri_CastKeyFrame, settings.castKeyFrame);
            }

            if (settings.placementType != CreateObjectPlacementType.AtSource)
            {
                attrList.Add(M.Attri_PlacementType, settings.placementType.ToString());
            }

            if (settings.facingType != CreateObjectFacingType.ToTarget)
            {
                attrList.Add(M.Attri_FacingType, settings.facingType.ToString());
            }

            if (!string.IsNullOrEmpty(settings.placementBoneName))
            {
                attrList.Add(M.Attri_BoneName, settings.placementBoneName);
            }
            if (settings.attachmentZOffset != 0)
            {
                attrList.Add(M.Attri_AttachmentZOffset, settings.attachmentZOffset.ToString());
            }

            if (settings.placementLocalRelativePosition.IsEqual(Vector3.zero) == false)
            {
                attrList.Add(M.Attri_PlacementRelativePosition, settings.placementLocalRelativePosition.ToString());
            }

            if (settings.placementWorldRelativePosition.IsEqual(Vector3.zero) == false)
            {
                attrList.Add(M.Attri_PlacementWroldRelativePosition, settings.placementWorldRelativePosition.ToString());
            }

            if (settings.placementRelativeEuler.IsEqual(Vector3.zero) == false)
            {
                attrList.Add(M.Attri_PlacementRelativeEuler, settings.placementRelativeEuler.ToString());
            }

            if (settings.inheritHostModelScalingWhenAttached == false)
            {
                attrList.Add(M.Attri_InheritHostModelScalingWhenAttached, settings.inheritHostModelScalingWhenAttached.ToString());
            }

            if (settings.maintainPosition)
            {
                attrList.Add(M.Attri_MaintainPosition, settings.maintainPosition.ToString());
            }

            if (settings.maintainFacing)
            {
                attrList.Add(M.Attri_MaintainFacing, settings.maintainFacing.ToString());
            }

            if (settings.removeOnUnApply)
            {
                attrList.Add(M.Attri_RemoveOnUnApply, settings.removeOnUnApply.ToString());
            }

            if (settings.useLocalRelativePosition == false)
            {
                attrList.Add(M.Attri_UseLocalRelativePosition, settings.useLocalRelativePosition.ToString());
            }

            if (settings.isProjectileEffect)
            {
                attrList.Add(M.Attri_IsProjectile, settings.isProjectileEffect.ToString());
            }

            if (settings.projectileSpeed != 1)
            {
                attrList.Add(M.Attri_ProjectileSpeed, settings.projectileSpeed.ToString());
            }

            if (!string.IsNullOrEmpty(settings.projectileStartBoneName))
            {
                attrList.Add(M.Attri_ProjectileStartBoneName, settings.projectileStartBoneName);
            }

            if (!string.IsNullOrEmpty(settings.projectileTargetBoneName))
            {
                attrList.Add(M.Attri_ProjectileTargetBoneName, settings.projectileTargetBoneName);
            }

            if (!string.IsNullOrEmpty(settings.projectileParticleName))
            {
                attrList.Add(M.Attri_ProjectileParticleName, settings.projectileParticleName);
            }

            if (string.IsNullOrEmpty(customNodeName))
            {
                parser.OnStartElement(M.Node, attrList);
            }
            else
            {
                parser.OnStartElement(customNodeName, attrList);
            }


            parser.OnEndElement("");

            return(parser.ToXml());
        }
Example #5
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));
 }
Example #6
0
 public static bool LoadXmlFromBinaryFile(Mono.Xml.SecurityParser InParser, string InPath)
 {
     byte[] inFileBytes = File.ReadAllBytes(InPath);
     return(LoadXmlFromBinaryBuffer(InParser, inFileBytes, InPath));
 }