Пример #1
0
        public static Closure Root(ITypedElement root, EvaluationContext ctx = null)
        {
            var newContext = new Closure()
            {
                EvaluationContext = ctx ?? EvaluationContext.CreateDefault()
            };

            var input = new[] { root };

            newContext.SetThis(input);
            newContext.SetThat(input);
            newContext.SetOriginalContext(input);
            if (ctx.Container != null)
            {
                newContext.SetResource(new[] { ctx.Container });
            }
            if (ctx.RootContainer != null)
            {
                newContext.SetRootResource(new[] { ctx.RootContainer });
            }

            return(newContext);
        }