Example #1
0
        public double GetVar(string name)
        {
            double result = double.NaN;

            int num = fVars.Count;

            for (int i = 0; i < num; i++)
            {
                NamedVar nVar = fVars[i];

                if (string.Compare(nVar.Name, name, !fCaseSensitive) == 0)
                {
                    result = nVar.Value;
                    break;
                }
            }

            if (double.IsNaN(result))
            {
                GetVarEventHandler eventHandler = OnGetVar;
                if (eventHandler != null)
                {
                    var eventArgs = new VarRequestEventArgs(name);
                    if (eventHandler(this, eventArgs))
                    {
                        result = eventArgs.VarValue;
                    }
                }
            }

            return(result);
        }
        private static bool GetVarEventHandler(object sender, VarRequestEventArgs eventArgs)
        {
            if (eventArgs.VarName.Equals("alpha"))
            {
                eventArgs.VarValue = 15.0;
                return(true);
            }

            return(false);
        }