예제 #1
0
파일: dynWatch.cs 프로젝트: jimmplan/Dynamo
        /// <summary>
        /// Called during Evaluation, this method handles the
        /// conversion of an FScheme.Value object into a watchnode.
        /// This process uses the IWatchHandler registered on
        /// the controller to dynamically dispatch watch node
        /// processing based on the unboxed Value's object.
        /// </summary>
        /// <param name="value"></param>
        /// <param name="tag"></param>
        /// <param name="showRawData"></param>
        /// <returns></returns>
        public WatchItem Process(Value value, string tag, bool showRawData = true)
        {
            WatchItem node;

            if (value == null || value.IsDummy)
            {
                node = new WatchItem("null");
            }
            else if (value.IsFunction)
            {
                node = new WatchItem("<function>");
            }
            else if (value.IsList)
            {
                var list = ((Value.List)value).Item;
                node = new WatchItem(list.IsEmpty ? "Empty List" : string.Format("[{0}] List", tag));

                foreach (var e in list.Select((x, i) => new { Element = x, Index = i }))
                {
                    node.Children.Add(Process(e.Element, e.Index.ToString(CultureInfo.InvariantCulture), showRawData));
                }
            }
            else
            {
                node = dynSettings.Controller.WatchHandler.Process(value.ToDynamic(), tag, showRawData);
            }

            return(node ?? (new WatchItem("null")));
        }
예제 #2
0
파일: dynWatch.cs 프로젝트: jimmplan/Dynamo
        /// <summary>
        /// Called during Evaluation, this method handles the 
        /// conversion of an FScheme.Value object into a watchnode. 
        /// This process uses the IWatchHandler registered on
        /// the controller to dynamically dispatch watch node 
        /// processing based on the unboxed Value's object.
        /// </summary>
        /// <param name="value"></param>
        /// <param name="tag"></param>
        /// <param name="showRawData"></param>
        /// <returns></returns>
        public WatchItem Process(Value value, string tag, bool showRawData = true)
        {
            WatchItem node;

            if (value == null || value.IsDummy)
            {
                node = new WatchItem("null");
            }
            else if (value.IsFunction)
            {
                node = new WatchItem("<function>");
            }
            else if (value.IsList)
            {
                var list = ((Value.List) value).Item;
                node = new WatchItem(list.IsEmpty ? "Empty List" : string.Format("[{0}] List", tag));

                foreach (var e in list.Select((x, i) => new {Element = x, Index = i}))
                {
                    node.Children.Add(Process(e.Element, e.Index.ToString(CultureInfo.InvariantCulture), showRawData));
                }
            }
            else
            {
                node = dynSettings.Controller.WatchHandler.Process(value.ToDynamic(), tag, showRawData);
            }

            return node ?? (new WatchItem("null"));
        }