本文整理汇总了C#中System.Environment.DefineSymbol方法的典型用法代码示例。如果您正苦于以下问题:C# Environment.DefineSymbol方法的具体用法?C# Environment.DefineSymbol怎么用?C# Environment.DefineSymbol使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Environment
的用法示例。
在下文中一共展示了Environment.DefineSymbol方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyDefMacro
public object ApplyDefMacro(IList<object> arguments, Environment environment)
{
if (arguments.Count != 3)
{
throw new ArgumentException("Wrong number of arguments given to defmacro! Expected: " + 3);
}
var symbol = arguments.ElementAt(0) as SymbolNode;
if (symbol == null)
{
throw new ArgumentException("First argument to defmacro not a symbol!");
}
var parameterList = arguments.ElementAt(1) as IList<object>;
if (parameterList == null)
{
throw new ArgumentException("Second argument to defmacro not a parameterlist!");
}
var body = arguments.ElementAt(2);
var macro = new ProcedureNode(parameterList.Cast<SymbolNode>(), new[] { body }, environment.CreateChildEnvironment(), true);
environment.DefineSymbol(symbol, macro);
return symbol;
}
示例2: ApplyDef
public object ApplyDef(IList<object> arguments, Environment environment)
{
if (arguments.Count != 2)
{
throw new ArgumentException("Wrong number of arguments given to def! Expected: " + 2);
}
var symbol = arguments.ElementAt(0) as SymbolNode;
if (symbol == null)
{
throw new ArgumentException("First argument to def not a symbol!");
}
var valueForm = arguments.ElementAt(1);
var result = evaluator.Evaluate(valueForm, environment);
environment.DefineSymbol(symbol, result);
return symbol;
}