示例#1
0
        protected void Run()
        {
            return;

            var resolution = "";// Visual.ResolveVisualWithJavascript();

            if (!string.IsNullOrWhiteSpace(ExamineText))
            {
                resolution += "." + ExamineText;
            }
            var    js = string.Format("FaydeInterop.StringifyEx({0})", resolution);
            string json;

            try
            {
                json = JsContext.Eval(js);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error examining: " + ex.Message, "Eval Error", MessageBoxButton.OK);
                return;
            }
            var serializer = new JavaScriptSerializer {
                MaxJsonLength = int.MaxValue
            };

            try
            {
                ObjectStructure = serializer.Deserialize <IDictionary <string, object> >(json);
            }
            catch (InvalidOperationException)
            {
                try
                {
                    ObjectStructure = serializer.Deserialize <object[]>(json)
                                      .Select((o, i) => new { Key = i, Value = o })
                                      .ToDictionary(a => a.Key.ToString(), a => a.Value);
                }
                catch (InvalidOperationException)
                {
                    if (json.StartsWith("\"") && json.EndsWith("\""))
                    {
                        ObjectStructure = new Dictionary <string, object>
                        {
                            { "Value", json }
                        };
                    }
                }
            }
        }
示例#2
0
        protected IEnumerable <TimelineGroup> GetTimelineGroups()
        {
            if (JsContext == null)
            {
                return(Enumerable.Empty <TimelineGroup>());
            }
            if (!JsContext.IsAlive)
            {
                return(Enumerable.Empty <TimelineGroup>());
            }
            var json = JsContext.Eval("JSON.stringify(TimelineProfile.Groups)");

            return(JsonConvert.DeserializeObject <List <TimelineGroup> >(json));
        }