Exemplo n.º 1
0
        private void ValidateOffsetAndOffsetAddress(IEnumerable <FunctionArgument> arguments, ParsingContext context, object expectedOffsetResult, object expectedOffsetAddressResult, bool errorExpected = false)
        {
            Offset        offsetFunction        = new Offset();
            OffsetAddress offsetAddressFunction = new OffsetAddress();
            var           offsetResult          = offsetFunction.Execute(arguments, context);
            var           offsetAddressResult   = offsetAddressFunction.Execute(arguments, context);

            if (errorExpected)
            {
                Assert.AreEqual(expectedOffsetResult, ((ExcelErrorValue)offsetResult.Result).Type);
                Assert.AreEqual(expectedOffsetAddressResult, ((ExcelErrorValue)offsetAddressResult.Result).Type);
            }
            else
            {
                Assert.AreEqual(expectedOffsetResult, offsetResult);
                Assert.AreEqual(expectedOffsetAddressResult, offsetAddressResult);
            }
        }
Exemplo n.º 2
0
        private void Timer_Tick(object sender, EventArgs e)
        {
            int address;

            try
            {
                address = ExpressionEval.Parse(TBAddress.Text);
            }
            catch
            {
                CETableItem  = null;
                TBValue.Text = "0";
                return;
            }
            if (CBPointer.IsChecked == false)
            {
                OffsetAddress offsetAddress = new OffsetAddress(address);
                CETableItem             = new CETableItem(offsetAddress, (DataType)CBType.SelectedIndex);
                CETableItem.Description = TBDescription.Text;
                TBValue.Text            = CETableItem.DataValue.ToString();
            }
            else
            {
                try
                {
                    OffsetAddress offsetAddress = new OffsetAddress(address, GridOffset.Children.OfType <TextBox>().Select(tb => ExpressionEval.Parse(tb.Text)).ToArray());
                    CETableItem             = new CETableItem(offsetAddress, (DataType)CBType.SelectedIndex);
                    CETableItem.Description = TBDescription.Text;
                    TBValue.Text            = CETableItem.DataValue.ToString();
                }
                catch
                {
                    CETableItem  = null;
                    TBValue.Text = "0";
                    return;
                }
            }
        }