本文整理汇总了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);
}
示例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]);
}
示例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;
}
}
示例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.
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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>());
}