Ejemplo n.º 1
0
        private static void OutputChildControls(byte[] data, string indentation)
        {
            using (MemoryStream stream = new MemoryStream(data))
            {
                DelphiBinaryReader reader = new DelphiBinaryReader(stream);
                int count = reader.ReadInteger();

                for (int i = 0; i < count; i++)
                {
                    string name = (string) reader.ReadValue();
                    WriteLine("{0}{1}", indentation, name);
                    //TODO: figure out what this number means
                    Debug.Assert(reader.ReadByte() == 1);

                    while (reader.PeekChar() != 0)
                    {
                        OutputProperty(reader, indentation + "  ");
                    }

                    Debug.Assert(reader.ReadByte() == 0);
                }

                Debug.Assert(stream.Position == stream.Length);
            }
        }
Ejemplo n.º 2
0
        private static void OutputComponent(DelphiBinaryReader reader, string indentation)
        {
            string type = reader.ReadString();
            string name = reader.ReadString();
            WriteLine("{0}object {1}: {2}", indentation, name, type);

            while (reader.PeekChar() != 0)
            {
                OutputProperty(reader, indentation + "  ");
            }

            Debug.Assert(reader.ReadByte() == 0);

            while (reader.PeekChar() != 0)
            {
                OutputComponent(reader, indentation + "  ");
            }

            Debug.Assert(reader.ReadByte() == 0);
            WriteLine("{0}end", indentation);
        }
        private DelphiComponent ParseItems(DelphiBinaryReader binaryReader, bool isPrefixed)
        {
            DelphiComponent component = binaryReader.ReadComponent(isPrefixed);
            _componentSimplifier.Simplify(component);
            byte b = binaryReader.ReadByte();
            Debug.Assert(b == 1);

            while (binaryReader.PeekChar() != 0)
            {
                component.Components.Add(ParseItems(binaryReader, false));
            }

            binaryReader.ReadByte();
            return component;
        }
        private DelphiComponent ParseComponent(DelphiBinaryReader reader)
        {
            DelphiComponent component = new DelphiComponent();
            component.Type = reader.ReadString();
            component.Name = reader.ReadString();

            while (reader.PeekChar() != 0)
            {
                ParseProperty(reader, component.Properties);
            }

            byte b = reader.ReadByte();
            Debug.Assert(b == 0);

            while (reader.PeekChar() != 0)
            {
                component.Components.Add(ParseComponent(reader));
            }

            b = reader.ReadByte();
            Debug.Assert(b == 0);
            return component;
        }
        private ICollection<DelphiComponent> ParseChildControls(byte[] data)
        {
            using (DelphiBinaryReader binaryReader = new DelphiBinaryReader(new MemoryStream(data)))
            {
                int count = binaryReader.ReadInteger();
                ICollection<DelphiComponent> childControls = new List<DelphiComponent>();

                for (int i = 0; i < count; i++)
                {
                    DelphiComponent component = new DelphiComponent();
                    component.Name = (string) binaryReader.ReadValue();
                    //TODO: figure out what this number means
                    byte b = binaryReader.ReadByte();
                    Debug.Assert(b == 1);

                    while (binaryReader.PeekChar() != 0)
                    {
                        ParseProperty(binaryReader, component.Properties);
                    }

                    b = binaryReader.ReadByte();
                    Debug.Assert(b == 0);
                    childControls.Add(component);
                }

                Debug.Assert(binaryReader.BaseStream.Position == binaryReader.BaseStream.Length);
                return childControls;
            }
        }