Exemplo n.º 1
0
        public Func <RuntimeContext, JToken, JToken> Get(XjsltJson tree)
        {
            Func <RuntimeContext, JToken, JToken> fnc;

            if (tree != null)
            {
                var builder = new ConfigurationBuilder()
                {
                    Configuration = this._configuration,
                };
                fnc = builder.Compile(tree);
            }
            else // Template empty
            {
                var arg  = Expression.Parameter(typeof(RuntimeContext), "arg0");
                var arg1 = Expression.Parameter(typeof(JToken), "arg1");
                var lbd  = Expression.Lambda <Func <RuntimeContext, JToken, JToken> >(arg1, arg, arg1);

                if (lbd.CanReduce)
                {
                    lbd.ReduceAndCheck();
                }

                fnc = lbd.Compile();
            }

            return(fnc);
        }
Exemplo n.º 2
0
        private XjsltJson ConvertChildToType(XjsltJson node)
        {
            if (node is XjPath jp)
            {
                if (jp.Type != "jpath")
                {
                    var service = this._configuration.Services.GetService(jp.Type);
                    if (service == null)
                    {
                        throw new MissingServiceException(jp.Type);
                    }

                    return(new XjsltType(jp.TypeObject)
                    {
                        Type = jp.Type, ServiceProvider = service
                    });
                }

                if (jp.Child != null)
                {
                    jp.Child = ConvertChildToType(jp.Child);
                }
            }
            else if (node is XjsltType t)
            {
                var service = this._configuration.Services.GetService(t.Type);
                if (service == null)
                {
                    throw new MissingServiceException(t.Type);
                }
                t.ServiceProvider = service;
            }
            return(node);
        }
Exemplo n.º 3
0
        internal Func <RuntimeContext, JToken, JToken> Compile(XjsltJson tree)
        {
            Expression e;

            e = tree.Accept(this) as Expression;
            source.Add(e);

            var result = source.Compile <Func <RuntimeContext, JToken, JToken> >();

            return(result);
        }