Пример #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);
        }
Пример #2
0
        public static void AreEqual(ActionPushItem expected, ActionPushItem actual, string message)
        {
            Assert.AreEqual(expected.Type, actual.Type, message + ".Type");

            Assert.AreEqual(expected.Boolean, actual.Boolean, message + ".Boolean");
            Assert.AreEqual(expected.Constant16, actual.Constant16, message + ".Constant16");
            Assert.AreEqual(expected.Constant8, actual.Constant8, message + ".Constant8");
            Assert.AreEqual(expected.Double, actual.Double, message + ".Double");
            Assert.AreEqual(expected.Float, actual.Float, message + ".Float");
            Assert.AreEqual(expected.Integer, actual.Integer, message + ".Integer");
            Assert.AreEqual(expected.Register, actual.Register, message + ".Register");
            Assert.AreEqual(expected.String, actual.String, message + ".String");
        }