Ejemplo n.º 1
0
        public static NamedCompound DecodeCompound(BinaryInput stream, List <Tuple <string, Type> > GenericChute)
        {
            NamedCompound result = new NamedCompound();

            result.Name = stream.ReadString();
            int             c  = stream.ReadInt32();
            NamedVariableIO io = new NamedVariableIO(stream);

            for (int i = 0; i < c; i++)
            {
                NamedVariable varag = io.Read();
                if (varag != null)
                {
                    result.Tokens.Add(varag);
                }
                else
                {
                    string n    = stream.ReadString();
                    Type   type = null;
                    foreach (Tuple <string, Type> t in GenericChute.Where(t => n == t.Item1))
                    {
                        type = t.Item2;
                    }
                    if (type != null)
                    {
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 2
0
        public void Encode(BinaryOutput stream)
        {
            stream.Write(Name);
            stream.Write(Tokens.Count);
            NamedVariableIO io = new NamedVariableIO(stream);

            foreach (IEncodable token in Tokens)
            {
                if (token is NamedVariable)
                {
                    io.Write(token as NamedVariable);
                }
                else
                {
                    stream.Write(-1);
                    stream.Write(token);
                }
            }
        }