Пример #1
0
        protected override IConvertible GetValue()
        {
            // if (!isGotValue)
            // {
            if (OnGetValue == null)
            {
                throw new InvalidOperationException("This variable is not bound to a formula, so it's value cannot be read.");
            }
            VariableReadEventArgs args = new VariableReadEventArgs(Name);

            args.Type = Type;
            OnGetValue(this, args);

            if (Type != typeof(IConvertible))
            {
                _Value = (IConvertible)Convert.ChangeType(args.Value, Type);
            }
            else
            {
                _Value = args.Value;
            }
            //  isGotValue = true;
            //   }
            return(_Value);
        }
Пример #2
0
        protected void Variable_OnGetValue(object sender, VariableReadEventArgs e)
        {
            IConvertible value;

            if (VariableValues.TryGetValue(e.Name, out value))
            {
                e.Value = VariableValues[e.Name];
            }
            else
            {
                throw new InvalidOperationException("The value for variable '" + e.Name + "' was not set.");
            }
        }
 protected void GetVariableValue(object sender, VariableReadEventArgs e)
 {
     e.Value = xVal;
 }
Пример #4
0
        protected override IConvertible GetValue()
        {
            // if (!isGotValue)
               // {
                if (OnGetValue == null)
                {
                    throw new InvalidOperationException("This variable is not bound to a formula, so it's value cannot be read.");
                }
                VariableReadEventArgs args = new VariableReadEventArgs(Name);
                args.Type = Type;
                OnGetValue(this, args);

                if (Type != typeof(IConvertible))
                {
                    _Value = (IConvertible)Convert.ChangeType(args.Value, Type);
                }
                else
                {
                    _Value = args.Value;
                }
              //  isGotValue = true;
             //   }
            return _Value;
        }