當前位置: 首頁>>代碼示例>>C#>>正文


C# Environment.CreateChildEnvironment方法代碼示例

本文整理匯總了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());
        }
開發者ID:TommyPersson,項目名稱:Yalla,代碼行數:17,代碼來源:Applier.cs

示例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);
        }
開發者ID:TommyPersson,項目名稱:Yalla,代碼行數:23,代碼來源:Applier.cs

示例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;
        }
開發者ID:TommyPersson,項目名稱:Yalla,代碼行數:27,代碼來源:Applier.cs


注:本文中的System.Environment.CreateChildEnvironment方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。