コード例 #1
0
            public static ANode Deserialize(System.IO.BinaryReader aReader)
            {
                BinaryTag type = (BinaryTag)aReader.ReadByte();

                switch (type)
                {
                case BinaryTag.Array:
                {
                    int   count = aReader.ReadInt32();
                    Array tmp   = new Array();
                    for (int i = 0; i < count; i++)
                    {
                        tmp.Add(Deserialize(aReader));
                    }
                    return(tmp);
                }

                case BinaryTag.Class:
                {
                    int   count = aReader.ReadInt32();
                    Class tmp   = new Class();
                    for (int i = 0; i < count; i++)
                    {
                        string key = aReader.ReadString();
                        var    val = Deserialize(aReader);
                        tmp.Add(key, val);
                    }
                    return(tmp);
                }

                case BinaryTag.Value:
                {
                    return(new Data(aReader.ReadString()));
                }

                case BinaryTag.IntValue:
                {
                    return(new Data(aReader.ReadInt32()));
                }

                case BinaryTag.DoubleValue:
                {
                    return(new Data(aReader.ReadDouble()));
                }

                case BinaryTag.BoolValue:
                {
                    return(new Data(aReader.ReadBoolean()));
                }

                case BinaryTag.FloatValue:
                {
                    return(new Data(aReader.ReadSingle()));
                }

                default:
                {
                    throw new Exception("Error deserializing  Unknown tag: " + type);
                }
                }
            }
コード例 #2
0
 private void InnerWrite(BinaryTag tag, byte[] buffer)
 {
     this.InnerWrite(tag);
     this.InnerWrite(buffer);
 }
コード例 #3
0
 /// <summary>Handles the base input for a tag.</summary>
 /// <param name="data">The tag data.</param>
 /// <returns>The correct object.</returns>
 public static BinaryTag HandleOne(TagData data)
 {
     return(BinaryTag.CreateFor(data.GetModifierObjectCurrent(), data));
 }
コード例 #4
0
 private void InnerWrite(BinaryTag tag)
 {
     this._Stream.WriteByte((byte)tag);
 }