本文整理匯總了C#中System.Environment.CreateChildEnvironment方法的典型用法代碼示例。如果您正苦於以下問題:C# Environment.CreateChildEnvironment方法的具體用法?C# Environment.CreateChildEnvironment怎麽用?C# Environment.CreateChildEnvironment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Environment
的用法示例。
在下文中一共展示了Environment.CreateChildEnvironment方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ApplyLambda
public object ApplyLambda(IList<object> arguments, Environment environment)
{
var parameterList = arguments.First() as IList<object>;
var body = arguments.Skip(1);
if (parameterList == null)
{
throw new ArgumentException("Missing parameter list in lambda!");
}
if (!parameterList.All(x => x is SymbolNode))
{
throw new ArgumentException("Parameters must be symbols!");
}
return new ProcedureNode(parameterList.Cast<SymbolNode>(), body, environment.CreateChildEnvironment());
}
示例2: ApplyLet
public object ApplyLet(IList<object> arguments, Environment environment)
{
/*
* (let ((var-a form-a) (var-b form-b)) (+ var-a var-b))
*/
var bindingList = (IList<object>) arguments.First();
var bodyforms = arguments.Skip(1).AsEnumerable();
var localEnv = environment.CreateChildEnvironment();
foreach (var binding in bindingList.OfType<IList<object>>())
{
var symbol = (SymbolNode)binding.First();
var form = binding.ElementAt(1);
var value = evaluator.Evaluate(form, localEnv);
localEnv.DefineSymbol(symbol, value);
}
return evaluator.Evaluate(bodyforms, localEnv);
}
示例3: 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;
}