Ejemplo n.º 1
0
 private WatchViewModel ProcessThing(SIUnit unit, string tag, bool showRawData, WatchHandlerCallback callback)
 {
     return showRawData
         ? new WatchViewModel(
             visualizationManager,
             unit.Value.ToString(preferences.NumberFormat, CultureInfo.InvariantCulture),
             tag)
         : new WatchViewModel(visualizationManager, unit.ToString(), tag);
 }
Ejemplo n.º 2
0
 private WatchViewModel ProcessThing(MirrorData data, string tag, bool showRawData, WatchHandlerCallback callback)
 {
     try
     {
         return baseHandler.Process(data, tag, showRawData, callback);
     }
     catch (Exception)
     {
         return callback(data.Data, tag, showRawData);
     }
 }
Ejemplo n.º 3
0
        private WatchViewModel ProcessThing(Element element, string tag, bool showRawData, WatchHandlerCallback callback)
        {
            var id = element.Id;

            var node = new WatchViewModel(visualizationManager, 
                element.ToString(preferences.NumberFormat, CultureInfo.InvariantCulture), tag);

            node.Clicked += () =>
            {
                if (element.InternalElement.IsValidObject)
                    DocumentManager.Instance.CurrentUIDocument.ShowElements(element.InternalElement);
            };
            node.Link = id.ToString(CultureInfo.InvariantCulture);

            return node;
        }
Ejemplo n.º 4
0
        private WatchViewModel ProcessThing(object value, ProtoCore.RuntimeCore runtimeCore, string tag, bool showRawData, WatchHandlerCallback callback)
        {
            WatchViewModel node;

            if (value is IEnumerable)
            {
                var list = (value as IEnumerable).Cast<dynamic>().ToList();

                node = new WatchViewModel(list.Count == 0 ? "Empty List" : "List", tag, RequestSelectGeometry, true);
                foreach (var e in list.Select((element, idx) => new { element, idx }))
                {
                    node.Children.Add(callback(e.element, runtimeCore, tag + ":" + e.idx, showRawData));
                }
            }
            else if (runtimeCore != null && value is StackValue)
            {
                StackValue stackValue = (StackValue)value;
                string stringValue = string.Empty;

                if (stackValue.IsFunctionPointer)
                {
                    stringValue = StringUtils.GetStringValue(stackValue, runtimeCore);
                }
                else
                {
                    int typeId = runtimeCore.DSExecutable.TypeSystem.GetType(stackValue);
                    stringValue = runtimeCore.DSExecutable.classTable.ClassNodes[typeId].Name;
                }
                node = new WatchViewModel(stringValue, tag, RequestSelectGeometry);
            }
            else if (value is Enum)
            {
                return new WatchViewModel(((Enum)value).GetDescription(), tag, RequestSelectGeometry);
            }
            else
            {
                node = new WatchViewModel(ToString(value), tag, RequestSelectGeometry);
            }

            return node;
        }
Ejemplo n.º 5
0
        private WatchViewModel ProcessThing(object value, string tag, bool showRawData, WatchHandlerCallback callback)
        {
            WatchViewModel node;

            if (value is IEnumerable)
            {
                var list = (value as IEnumerable).Cast<dynamic>().ToList();

                node = new WatchViewModel(visualizationManager, list.Count == 0 ? "Empty List" : "List", tag, true);
                foreach (var e in list.Select((element, idx) => new { element, idx }))
                {
                    node.Children.Add(callback(e.element, tag + ":" + e.idx, showRawData));
                }
            }
            else
            {
                node = new WatchViewModel(visualizationManager, ToString(value), tag);
            }

            return node;
        }
Ejemplo n.º 6
0
 public WatchViewModel Process(dynamic value, string tag, bool showRawData, WatchHandlerCallback callback)
 {
     return Object.ReferenceEquals(value, null)
         ? new WatchViewModel(visualizationManager, NULL_STRING, tag)
         : ProcessThing(value, tag, showRawData, callback);
 }
Ejemplo n.º 7
0
        private WatchViewModel ProcessThing(object value, ProtoCore.Core core, string tag, bool showRawData, WatchHandlerCallback callback)
        {
            WatchViewModel node;

            if (value is IEnumerable)
            {
                var list = (value as IEnumerable).Cast <dynamic>().ToList();

                node = new WatchViewModel(visualizationManager, list.Count == 0 ? "Empty List" : "List", tag, true);
                foreach (var e in list.Select((element, idx) => new { element, idx }))
                {
                    node.Children.Add(callback(e.element, core, tag + ":" + e.idx, showRawData));
                }
            }
            else if (core != null && value is StackValue)
            {
                StackValue stackValue  = (StackValue)value;
                string     stringValue = string.Empty;

                if (stackValue.IsFunctionPointer)
                {
                    stringValue = StringUtils.GetStringValue(stackValue, core);
                }
                else
                {
                    int         typeId      = core.TypeSystem.GetType(stackValue);
                    ClassMirror classMirror = new ClassMirror(typeId, core);
                    stringValue = classMirror.ClassName;
                }
                node = new WatchViewModel(visualizationManager, stringValue, tag);
            }
            else
            {
                node = new WatchViewModel(visualizationManager, ToString(value), tag);
            }

            return(node);
        }
Ejemplo n.º 8
0
 private WatchViewModel ProcessThing(double value, ProtoCore.RuntimeCore runtimeCore, string tag, bool showRawData, WatchHandlerCallback callback)
 {
     return new WatchViewModel(value.ToString(preferences.NumberFormat, CultureInfo.InvariantCulture), tag);
 }
Ejemplo n.º 9
0
 private WatchViewModel ProcessThing(long value, ProtoCore.RuntimeCore runtimeCore, string tag, bool showRawData, WatchHandlerCallback callback)
 {
     return new WatchViewModel(visualizationManager, value.ToString(CultureInfo.InvariantCulture), tag);
 }
Ejemplo n.º 10
0
 private WatchViewModel ProcessThing(string value, ProtoCore.RuntimeCore runtimeCore, string tag, bool showRawData, WatchHandlerCallback callback)
 {
     return(new WatchViewModel(value, tag, RequestSelectGeometry));
 }
Ejemplo n.º 11
0
 //If no dispatch target is found, then invoke base watch handler.
 private WatchViewModel ProcessThing(object obj, string tag, bool showRawData, WatchHandlerCallback callback)
 {
     return baseHandler.Process(obj, tag, showRawData, callback);
 }
Ejemplo n.º 12
0
 private WatchViewModel ProcessThing(long value, ProtoCore.RuntimeCore runtimeCore, string tag, bool showRawData, WatchHandlerCallback callback)
 {
     return new WatchViewModel(value.ToString(CultureInfo.InvariantCulture), tag, RequestSelectGeometry);
 }
Ejemplo n.º 13
0
        private WatchViewModel ProcessThing(MirrorData data, ProtoCore.RuntimeCore runtimeCore, string tag, bool showRawData, WatchHandlerCallback callback)
        {
            if (data.IsCollection)
            {
                var list = data.GetElements();

                var node = new WatchViewModel(list.Count == 0 ? "Empty List" : "List", tag, RequestSelectGeometry, true);
                foreach (var e in list.Select((element, idx) => new { element, idx }))
                {
                    node.Children.Add(ProcessThing(e.element, runtimeCore, tag + ":" + e.idx, showRawData, callback));
                }

                return node;
            }
            if (data.Data is Enum)
            {
                return new WatchViewModel(((Enum)data.Data).GetDescription(), tag, RequestSelectGeometry);
            }

            if (data.Data == null)
            {
                // MAGN-3494: If "data.Data" is null, then return a "null" string 
                // representation instead of casting it as dynamic (that leads to 
                // a crash).
                if (data.IsNull)
                    return new WatchViewModel(NULL_STRING, tag, RequestSelectGeometry);
                
                //If the input data is an instance of a class, create a watch node
                //with the class name and let WatchHandler process the underlying CLR data
                var classMirror = data.Class;
                if (null != classMirror)
                {
                    //just show the class name.
                    return ProcessThing(classMirror.ClassName, runtimeCore, tag, showRawData, callback);
                }
            }

            //Finally for all else get the string representation of data as watch content.
            return callback(data.Data, runtimeCore, tag, showRawData);
        }
Ejemplo n.º 14
0
        private WatchViewModel ProcessThing(MirrorData data, List <string> preferredDictionaryOrdering, ProtoCore.RuntimeCore runtimeCore, string tag, bool showRawData, WatchHandlerCallback callback)
        {
            if (data.IsCollection)
            {
                var list = data.GetElements();

                var node = new WatchViewModel(!list.Any() ? WatchViewModel.EMPTY_LIST : WatchViewModel.LIST, tag, RequestSelectGeometry, true);
                foreach (var e in list.Select((element, idx) => new { element, idx }))
                {
                    node.Children.Add(ProcessThing(e.element, preferredDictionaryOrdering, runtimeCore, tag + ":" + e.idx, showRawData, callback));
                }

                return(node);
            }

            if (data.IsPointer && data.Data is DesignScript.Builtin.Dictionary)
            {
                var dict = data.Data as DesignScript.Builtin.Dictionary;

                var keys   = dict.Keys;
                var values = dict.Values;
                if (preferredDictionaryOrdering.Count > 1)
                {
                    keys   = preferredDictionaryOrdering;
                    values = keys.Select(k => dict.ValueAtKey(k));
                }

                var node = new WatchViewModel(keys.Any() ? WatchViewModel.DICTIONARY : WatchViewModel.EMPTY_DICTIONARY, tag, RequestSelectGeometry, true);

                foreach (var e in keys.Zip(values, (key, value) => new { key, value }))
                {
                    node.Children.Add(ProcessThing(e.value, preferredDictionaryOrdering, runtimeCore, tag + ":" + e.key.ToString(), showRawData, callback));
                }

                return(node);
            }

            if (data.Data is Enum)
            {
                return(new WatchViewModel(((Enum)data.Data).GetDescription(), tag, RequestSelectGeometry));
            }

            if (data.Data == null)
            {
                // MAGN-3494: If "data.Data" is null, then return a "null" string
                // representation instead of casting it as dynamic (that leads to
                // a crash).
                if (data.IsNull)
                {
                    return(new WatchViewModel(Resources.NullString, tag, RequestSelectGeometry));
                }

                //If the input data is an instance of a class, create a watch node
                //with the class name and let WatchHandler process the underlying CLR data
                var classMirror = data.Class;
                if (null != classMirror)
                {
                    //just show the class name.
                    return(ProcessThing(classMirror.ClassName, runtimeCore, tag, showRawData, callback));
                }
            }

            //Finally for all else get the string representation of data as watch content.
            return(callback(data.Data, preferredDictionaryOrdering, runtimeCore, tag, showRawData));
        }
Ejemplo n.º 15
0
 private WatchViewModel ProcessThing(string value, string tag, bool showRawData, WatchHandlerCallback callback)
 {
     return new WatchViewModel(visualizationManager, value, tag);
 }
Ejemplo n.º 16
0
 public WatchViewModel Process(dynamic value, ProtoCore.Core core, string tag, bool showRawData, WatchHandlerCallback callback)
 {
     return(Object.ReferenceEquals(value, null)
         ? new WatchViewModel(visualizationManager, NULL_STRING, tag)
         : ProcessThing(value, core, tag, showRawData, callback));
 }
Ejemplo n.º 17
0
        private WatchViewModel ProcessThing(MirrorData data, ProtoCore.Core core, string tag, bool showRawData, WatchHandlerCallback callback)
        {
            if (data.IsCollection)
            {
                var list = data.GetElements();

                var node = new WatchViewModel(visualizationManager, list.Count == 0 ? "Empty List" : "List", tag, true);
                foreach (var e in list.Select((element, idx) => new { element, idx }))
                {
                    node.Children.Add(ProcessThing(e.element, core, tag + ":" + e.idx, showRawData, callback));
                }

                return(node);
            }

            if (data.Data == null)
            {
                // MAGN-3494: If "data.Data" is null, then return a "null" string
                // representation instead of casting it as dynamic (that leads to
                // a crash).
                if (data.IsNull)
                {
                    return(new WatchViewModel(visualizationManager, NULL_STRING, tag));
                }

                //If the input data is an instance of a class, create a watch node
                //with the class name and let WatchHandler process the underlying CLR data
                var classMirror = data.Class;
                if (null != classMirror)
                {
                    //just show the class name.
                    return(ProcessThing(classMirror.ClassName, core, tag, showRawData, callback));
                }
            }

            //Finally for all else get the string representation of data as watch content.
            return(callback(data.Data, core, tag, showRawData));
        }
Ejemplo n.º 18
0
 private WatchViewModel ProcessThing(string value, ProtoCore.Core core, string tag, bool showRawData, WatchHandlerCallback callback)
 {
     return(new WatchViewModel(visualizationManager, value, tag));
 }
Ejemplo n.º 19
0
        private WatchViewModel ProcessThing(object value, List <string> preferredDictionaryOrdering, ProtoCore.RuntimeCore runtimeCore, string tag, bool showRawData, WatchHandlerCallback callback)
        {
            if (value is DesignScript.Builtin.Dictionary || value is IDictionary)
            {
                IEnumerable <string> keys;
                IEnumerable <object> values;
                if (value is DesignScript.Builtin.Dictionary)
                {
                    var dict = value as DesignScript.Builtin.Dictionary;
                    keys   = dict.Keys;
                    values = dict.Values;
                    if (preferredDictionaryOrdering.Count > 1)
                    {
                        keys   = preferredDictionaryOrdering;
                        values = keys.Select(k => dict.ValueAtKey(k));
                    }
                }
                else
                {
                    var dict = value as IDictionary;
                    keys   = dict.Keys.Cast <string>();
                    values = dict.Values.Cast <object>();
                }

                var node = new WatchViewModel(keys.Any() ? WatchViewModel.DICTIONARY : WatchViewModel.EMPTY_DICTIONARY, tag, RequestSelectGeometry, true);

                foreach (var e in keys.Zip(values, (key, val) => new { key, val }))
                {
                    node.Children.Add(ProcessThing(e.val, preferredDictionaryOrdering, runtimeCore, tag + ":" + e.key.ToString(), showRawData, callback));
                }

                return(node);
            }

            if (!(value is string) && value is IEnumerable)
            {
                var list = (value as IEnumerable).Cast <dynamic>().ToList();

                var node = new WatchViewModel(list.Count == 0 ? WatchViewModel.EMPTY_LIST : WatchViewModel.LIST, tag, RequestSelectGeometry, true);
                foreach (var e in list.Select((element, idx) => new { element, idx }))
                {
                    node.Children.Add(callback(e.element, preferredDictionaryOrdering, runtimeCore, tag + ":" + e.idx, showRawData));
                }

                return(node);
            }

            if (runtimeCore != null && value is StackValue)
            {
                StackValue stackValue  = (StackValue)value;
                string     stringValue = string.Empty;

                if (stackValue.IsFunctionPointer)
                {
                    stringValue = StringUtils.GetStringValue(stackValue, runtimeCore);
                }
                else
                {
                    int typeId = runtimeCore.DSExecutable.TypeSystem.GetType(stackValue);
                    stringValue = runtimeCore.DSExecutable.classTable.ClassNodes[typeId].Name;
                }
                return(new WatchViewModel(stringValue, tag, RequestSelectGeometry));
            }

            if (value is Enum)
            {
                return(new WatchViewModel(((Enum)value).GetDescription(), tag, RequestSelectGeometry));
            }

            return(new WatchViewModel(ToString(value), tag, RequestSelectGeometry));
        }
Ejemplo n.º 20
0
 public WatchViewModel Process(dynamic value, IEnumerable <string> preferredDictionaryOrdering, ProtoCore.RuntimeCore runtimeCore, string tag, bool showRawData, WatchHandlerCallback callback)
 {
     return(System.Object.ReferenceEquals(value, null)
         ? new WatchViewModel(Resources.NullString, tag, RequestSelectGeometry)
         : ProcessThing(value, preferredDictionaryOrdering.ToList(), runtimeCore, tag, showRawData, callback));
 }
Ejemplo n.º 21
0
 private WatchViewModel ProcessThing(double value, string tag, bool showRawData, WatchHandlerCallback callback)
 {
     return new WatchViewModel(visualizationManager, value.ToString(preferences.NumberFormat, CultureInfo.InvariantCulture), tag);
 }
Ejemplo n.º 22
0
 private WatchViewModel ProcessThing(double value, ProtoCore.Core core, string tag, bool showRawData, WatchHandlerCallback callback)
 {
     return(new WatchViewModel(visualizationManager, value.ToString(preferences.NumberFormat, CultureInfo.InvariantCulture), tag));
 }
Ejemplo n.º 23
0
 private WatchViewModel ProcessThing(DateTime value, ProtoCore.RuntimeCore runtimeCore, string tag, bool showRawData, WatchHandlerCallback callback)
 {
     return new WatchViewModel(value.ToString(PreferenceSettings.DefaultDateFormat, CultureInfo.InvariantCulture), tag, RequestSelectGeometry);
 }
Ejemplo n.º 24
0
 private WatchViewModel ProcessThing(SIUnit unit, ProtoCore.RuntimeCore runtimeCore, string tag, bool showRawData, WatchHandlerCallback callback)
 {
     return(showRawData
         ? new WatchViewModel(
                unit.Value.ToString(preferences.NumberFormat, CultureInfo.InvariantCulture),
                tag, RequestSelectGeometry)
         : new WatchViewModel(unit.ToString(), tag, RequestSelectGeometry));
 }
Ejemplo n.º 25
0
 private WatchViewModel ProcessThing(string value, ProtoCore.RuntimeCore runtimeCore, string tag, bool showRawData, WatchHandlerCallback callback)
 {
     return new WatchViewModel(value, tag, RequestSelectGeometry);
 }
Ejemplo n.º 26
0
 private WatchViewModel ProcessThing(double value, ProtoCore.RuntimeCore runtimeCore, string tag, bool showRawData, WatchHandlerCallback callback)
 {
     return(new WatchViewModel(value.ToString(numberFormat, CultureInfo.InvariantCulture), tag, RequestSelectGeometry));
 }
Ejemplo n.º 27
0
 public WatchViewModel Process(dynamic value, ProtoCore.RuntimeCore runtimeCore, string tag, bool showRawData, WatchHandlerCallback callback)
 {
     return Object.ReferenceEquals(value, null)
         ? new WatchViewModel(NULL_STRING, tag, RequestSelectGeometry)
         : ProcessThing(value, runtimeCore, tag, showRawData, callback);
 }
Ejemplo n.º 28
0
 private WatchViewModel ProcessThing(System.DateTime value, ProtoCore.RuntimeCore runtimeCore, string tag, bool showRawData, WatchHandlerCallback callback)
 {
     return(new WatchViewModel(value.ToString(PreferenceSettings.DefaultDateFormat, CultureInfo.InvariantCulture), tag, RequestSelectGeometry));
 }
Ejemplo n.º 29
0
 private WatchViewModel ProcessThing(SIUnit unit, ProtoCore.RuntimeCore runtimeCore, string tag, bool showRawData, WatchHandlerCallback callback)
 {
     return showRawData
         ? new WatchViewModel(
             unit.Value.ToString(preferences.NumberFormat, CultureInfo.InvariantCulture),
             tag, RequestSelectGeometry)
         : new WatchViewModel(unit.ToString(), tag, RequestSelectGeometry);
 }
Ejemplo n.º 30
0
 private WatchViewModel ProcessThing(DateTime value, ProtoCore.RuntimeCore runtimeCore, string tag, bool showRawData, WatchHandlerCallback callback)
 {
     return new WatchViewModel(visualizationManager, value.ToString(PreferenceSettings.DefaultDateFormat, CultureInfo.InvariantCulture), tag);
 }