BaddyNet.PacketBase.unmarshal C# (CSharp) Метод

unmarshal() публичный Метод

public unmarshal ( Stream s ) : void
s Stream
Результат void
        public void unmarshal(Stream s)
        {
            BinaryReader reader = new BinaryReader(s);
            Type t = this.GetType();
            FieldInfo[] fields = t.GetFields();

            foreach (var fi in fields)
            {
                if (fi.FieldType == typeof(string)) fi.SetValue(this, reader.ReadString());
                else if (fi.FieldType == typeof(int)) fi.SetValue(this, reader.ReadInt32());
                else if (fi.FieldType == typeof(float)) fi.SetValue(this, reader.ReadSingle());
                else if (fi.FieldType == typeof(double)) fi.SetValue(this, reader.ReadDouble());
            }
        }