当前位置: 首页>>代码示例>>C#>>正文


C# Frame.FindBindingValue方法代码示例

本文整理汇总了C#中Frame.FindBindingValue方法的典型用法代码示例。如果您正苦于以下问题:C# Frame.FindBindingValue方法的具体用法?C# Frame.FindBindingValue怎么用?C# Frame.FindBindingValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Frame的用法示例。


在下文中一共展示了Frame.FindBindingValue方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Evaluate

 public override object Evaluate(Frame environment)
 {
     isDecimal = false;
     if (environment == null)
     {
         throw new ArgumentNullException("Environment can not be null.");
     }
     List<object> paramValues = new List<object>();
     foreach (String param in Parameters)
     {
         if (param == ".")
         {
             continue;
         }
         object binding = environment.FindBindingValue(param);
         if (binding == null)
         {
             throw new Exception("can't find binding");
         }
         paramValues.Add(GetNumber(binding));
     }
     object restText = environment.FindBindingValue(".");
     if (restText != null)
     {
         RestParameters rest = (RestParameters)restText;
         foreach (object number in rest.Values)
         {
             paramValues.Add(GetNumber(number));
         }
     }
     return EvaluateResult(paramValues);
 }
开发者ID:csaba-dery,项目名称:SInterpreter,代码行数:32,代码来源:MathProcedure.cs

示例2: Evaluate

        public override object Evaluate(Frame environment)
        {
            if (environment == null)
            {
                throw new ArgumentNullException("Environment can not be null.");
            }
            List<double> paramValues = new List<double>();
            foreach (String param in Parameters)
            {
                String binding = environment.FindBindingValue(param).ToString();
                if (binding == null)
                {
                    throw new Exception("can't find binding");
                }
                double number;
                if (double.TryParse(binding, out number))
                {
                    paramValues.Add(number);
                }
            }
            if (paramValues.Count < 2)
            {
                throw new Exception("Illegal number of arguments, need at least 2.");
            }

            return CompareValues(paramValues[0], paramValues[1]);
        }
开发者ID:csaba-dery,项目名称:SInterpreter,代码行数:27,代码来源:Comparison.cs

示例3: Evaluate

        public override object Evaluate(Frame environment)
        {
            if (environment == null)
            {
                throw new ArgumentNullException("Environment can not be null.");
            }
            string path = environment.FindBindingValue(Parameters[0]).ToString();
            if (!File.Exists(path))
            {
                throw new Exception("Could not find file: " + path);
            }

            using (StreamReader codeReader = new StreamReader(File.Open(path, FileMode.Open)))
            {
                Scanner scanner = new Scanner(codeReader);

                Expression expr = scanner.NextExpression;
                string evaluation = string.Empty;
                while (expr != null)
                {
                    evaluation = environment.Evaluate(expr).ToString();
                    expr = scanner.NextExpression;
                }

                return evaluation;
            }
        }
开发者ID:csaba-dery,项目名称:SInterpreter,代码行数:27,代码来源:Load.cs

示例4: Evaluate

 public override object Evaluate(Frame environment)
 {
     if (Parameters.Count <= 0)
     {
         throw new Exception("Invalid number of parameters.");
     }
     SList list = environment.FindBindingValue(Parameters[0]) as SList;
     return list.IsEmpty;    //TODO what if it's not a list, but a binding that can't be found.
 }
开发者ID:csaba-dery,项目名称:SInterpreter,代码行数:9,代码来源:NullCheck.cs

示例5: Evaluate

 public override object Evaluate(Frame environment)
 {
     if (Parameters.Count <= 0) //TODO WTF! How can this be 0??
     {
         throw new Exception("Invalid number of parameters.");
     }
     string message = environment.FindBindingValue(Parameters[0]).ToString();
     throw new InterpreterException(message);
 }
开发者ID:csaba-dery,项目名称:SInterpreter,代码行数:9,代码来源:Error.cs

示例6: Evaluate

 public override object Evaluate(Frame environment)
 {
     if (environment == null)
     {
         throw new ArgumentNullException("Environment can not be null.");
     }
     object value = environment.FindBindingValue(Parameters[0]);
     Console.Write(value);
     return string.Empty;
 }
开发者ID:csaba-dery,项目名称:SInterpreter,代码行数:10,代码来源:Display.cs

示例7: Evaluate

        public override object Evaluate(Frame environment)
        {
            if (environment == null)
            {
                throw new ArgumentNullException("cons: Environment can not be null.");
            }

            object firstBinding = environment.FindBindingValue(Parameters[0]);
            if (firstBinding == null)
            {
                throw new Exception("cons: Can't find binding for first argument.");
            }
            object restBinding = environment.FindBindingValue(Parameters[1]);
            if (restBinding == null)
            {
                throw new Exception("cons: Can't find binding for second argument.");
            }
            return ConsFactory.CreatePair(firstBinding, restBinding);
        }
开发者ID:csaba-dery,项目名称:SInterpreter,代码行数:19,代码来源:Cons.cs

示例8: Evaluate

 public override object Evaluate(Frame environment)
 {
     if (environment == null)
     {
         throw new ArgumentNullException("sin: Environment can not be null.");
     }
     double angle = 0;
     if (!double.TryParse(environment.FindBindingValue(Parameters[0]).ToString(), out angle))
     {
         throw new Exception("sin: Argument must be an number.");
     }
     return _function(angle);
 }
开发者ID:csaba-dery,项目名称:SInterpreter,代码行数:13,代码来源:Trigonometric.cs

示例9: Evaluate

 public override object Evaluate(Frame environment)
 {
     if (environment == null)
     {
         throw new ArgumentNullException("Environment can not be null.");
     }
     object predicate = environment.FindBindingValue(Parameters[0]);
     bool result = false;
     if (!bool.TryParse(predicate.ToString(), out result))
     {
         throw new Exception("not: parameter not a predicate.");
     }
     return !result;
 }
开发者ID:csaba-dery,项目名称:SInterpreter,代码行数:14,代码来源:Not.cs

示例10: Evaluate

        public override object Evaluate(Frame environment)
        {
            if (environment == null)
            {
                throw new ArgumentNullException("Environment can not be null.");
            }

            object pairObject = environment.FindBindingValue(Parameters[0]);
            if (pairObject == null || !(pairObject is IPair))
            {
                throw new Exception("Invalid argument: not a pair");
            }
            IPair pair = (IPair)pairObject;
            return GetPairPart(pair);
        }
开发者ID:csaba-dery,项目名称:SInterpreter,代码行数:15,代码来源:PairRetrieval.cs

示例11: Evaluate

 public override object Evaluate(Frame environment)
 {
     if (environment == null)
     {
         throw new ArgumentNullException("Environment can not be null.");
     }
     int limit;
     object bindingValue = environment.FindBindingValue(Parameters[0]);
     if (bindingValue is int)
     {
         limit = (int)bindingValue;
     }
     else if (!int.TryParse(bindingValue.ToString(), out limit))
     {
         throw new Exception("random: Argument must be an integer");
     }
     System.Random rand = new System.Random();
     int result = rand.Next(limit);
     return result;
 }
开发者ID:csaba-dery,项目名称:SInterpreter,代码行数:20,代码来源:Random.cs

示例12: Evaluate

 public override object Evaluate(Frame environment)
 {
     object first = environment.FindBindingValue(Parameters[0]); //TODO maybe FindBindingValue should throw an exception if a binding is not found.
     RestParameters rest = (RestParameters)environment.FindBindingValue(Parameters[1]);
     return new SList(first,rest.Values.Cast<object>());
 }
开发者ID:csaba-dery,项目名称:SInterpreter,代码行数:6,代码来源:ListCreate.cs


注:本文中的Frame.FindBindingValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。