Example #1
0
        ActionBase IActionVisitor <ushort, ActionBase> .Visit(ActionPush action, ushort length)
        {
            var position = _reader.Position;

            while (_reader.Position - position < length)
            {
                var item = new ActionPushItem();
                var type = (ActionPushItemType)_reader.ReadByte();
                item.Type = type;
                switch (type)
                {
                case ActionPushItemType.String:
                    item.String = _reader.ReadString();
                    break;

                case ActionPushItemType.Float:
                    item.Float = _reader.ReadSingle();
                    break;

                case ActionPushItemType.Null:
                    break;

                case ActionPushItemType.Undefined:
                    break;

                case ActionPushItemType.Register:
                    item.Register = _reader.ReadByte();
                    break;

                case ActionPushItemType.Boolean:
                    item.Boolean = _reader.ReadByte();
                    break;

                case ActionPushItemType.Double:
                    item.Double = _reader.ReadDouble();
                    break;

                case ActionPushItemType.Integer:
                    item.Integer = _reader.ReadInt32();
                    break;

                case ActionPushItemType.Constant8:
                    item.Constant8 = _reader.ReadByte();
                    break;

                case ActionPushItemType.Constant16:
                    item.Constant16 = _reader.ReadUInt16();
                    break;

                default:
                    throw new NotSupportedException("Unknown PushData type " + type);
                }
                action.Items.Add(item);
            }
            return(action);
        }
Example #2
0
        object IActionVisitor <ISwfStreamWriter, object> .Visit(ActionPush action, ISwfStreamWriter writer)
        {
            foreach (var item in action.Items)
            {
                writer.WriteByte((byte)item.Type);
                switch (item.Type)
                {
                case ActionPushItemType.String:
                    writer.WriteString(item.String);
                    break;

                case ActionPushItemType.Float:
                    writer.WriteSingle(item.Float);
                    break;

                case ActionPushItemType.Null:
                    break;

                case ActionPushItemType.Undefined:
                    break;

                case ActionPushItemType.Register:
                    writer.WriteByte(item.Register);
                    break;

                case ActionPushItemType.Boolean:
                    writer.WriteByte(item.Boolean);
                    break;

                case ActionPushItemType.Double:
                    writer.WriteDouble(item.Double);
                    break;

                case ActionPushItemType.Integer:
                    writer.WriteInt32(item.Integer);
                    break;

                case ActionPushItemType.Constant8:
                    writer.WriteByte(item.Constant8);
                    break;

                case ActionPushItemType.Constant16:
                    writer.WriteUInt16(item.Constant16);
                    break;

                default:
                    throw new NotSupportedException("Unknown PushData type " + item.Type);
                }
            }
            return(null);
        }