Beispiel #1
0
        internal PathResult Execute(string path, JavaScriptData javaScriptData)
        {
            if (path.StartsWith("/"))
            {
                path = path.Substring(1);
            }

            foreach (var binding in javaScriptData.Bindings.Values)
            {
                if (!typeHandler.TrySet(binding, serviceProvider))
                {
                    throw new InvalidOperationException($"Unable to assign value '{binding.RawData}' to property");
                }
            }

            if (typeHandler.TryExecute(path, serviceProvider, out var data))
            {
                return new PathResult
                       {
                           Data       = data,
                           Successful = true
                       }
            }
            ;
            else
            {
                return(false);
            }
        }
Beispiel #2
0
        //public void Compute(JavaScriptData data)
        //{
        //    foreach (var bind in data.Bindings.Values)
        //        bind.Compute(provider);
        //}

        public string Generate(JavaScriptData data, bool excludeCommon)
        {
            string js = excludeCommon ? "" : JsContent.allContent;

            if (data.Bindings.Count > 0)
            {
                js += $@"var stronglyData = {html.Raw(FormatObject(data))};";
            }
            return(js);
        }