XLibrary.XNodeIn.ReadString C# (CSharp) Method

ReadString() public static method

public static ReadString ( FileStream stream ) : string
stream System.IO.FileStream
return string
        public static string ReadString(FileStream stream)
        {
            int strlen = BitConverter.ToInt32(stream.Read(4), 0);

            if (strlen == 0)
                return "";

            return UTF8Encoding.UTF8.GetString(stream.Read(strlen));
        }

Usage Example

Beispiel #1
0
        internal bool LoadMsil()
        {
            if (MsilPos == 0 || MsilLines == 0)
            {
                return(false);
            }

            if (Msil != null)
            {
                return(true);
            }

            using (FileStream DatStream = new FileStream(XRay.DatPath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                DatStream.Position = MsilPos;

                Msil = new List <XInstruction>();
                var code = new StringBuilder();

                for (int i = 0; i < MsilLines; i++)
                {
                    var inst = new XInstruction();
                    inst.Offset = BitConverter.ToInt32(DatStream.Read(4), 0);
                    inst.OpCode = XNodeIn.ReadString(DatStream);
                    inst.Line   = XNodeIn.ReadString(DatStream);
                    inst.RefId  = BitConverter.ToInt32(DatStream.Read(4), 0);

                    if (inst.RefId != 0 && !inst.Line.StartsWith("goto "))
                    {
                        inst.Line = Utilities.GetMethodName(this, inst.RefId);
                    }

                    Msil.Add(inst);
                    code.Append(inst.Offset.ToString("X") + ": " + inst.OpCode + " " + inst.Line + "\r\n");
                }

                PlainMsil = code.ToString();
            }

            return(true);
        }