private void createObjectsRepresentation() { createObjectMapping(); foreach (var item in snapshot.Structure.Readonly.ObjectDescriptors) { ObjectValue objectValue = item.Key; IObjectDescriptor descriptor = item.Value; output.line(); output.variable(objectValue.ToString()); output.line(); output.hint("Object type: "); if (descriptor.Type != null) { output.info(descriptor.Type.QualifiedName.ToString()); } else { output.error("Object has no type"); } output.line(); output.hint("Parent indexes: "); List <MemoryIndex> indexes; if (objects.TryGetValue(objectValue, out indexes)) { foreach (MemoryIndex index in indexes) { output.variable(index.ToString()); output.info(", "); } } else { output.error("Object not referenced"); } output.Indent(); output.line(); createRepresentation(item.Value); output.Dedent(); output.line(); } }
/// <inheritdoc/> public override string ToString() { string result = ""; if (TargetNode != null) { result += "[HasNode] "; } else if (TargetGuid != Guid.Empty) { result += "[HasGuid] "; } result += TargetGuid + " " + (ObjectValue?.ToString() ?? "null"); return(result); }
public override string ToString() { StringBuilder resultBuilder = new StringBuilder(PublisherName); resultBuilder.Append(" -- "); if (ObjectValue != null) { resultBuilder.Append("obj=").Append(ObjectValue.ToString()); } if (StringValue != null) { resultBuilder.Append("str=").Append(StringValue.ToString()); } if (DoubleValue != null) { resultBuilder.Append("dbl=").Append(DoubleValue.ToString()); } if (MatrixValue != null) { resultBuilder.Append("mtx").Append(MatrixValue.ToString()); } if (_headers != null) { resultBuilder.Append("\t{"); foreach (KeyValuePair <string, object> header in _headers) { // TODO null-checks // TODO recursivly dive into headers ??? possibly change to string,string resultBuilder.Append(" {").Append(header.Key).Append(" ").Append(header.Value.ToString()).Append("}"); } resultBuilder.Append(" }"); } return(resultBuilder.ToString()); }
// ToJson public virtual string ToJson() { return(ObjectValue.ToString()); }
// ToString public override string ToString() { return(ObjectValue.ToString()); }
private void ExecuteButton_Click(object sender, RoutedEventArgs e) { Expression Exp; TextBlock ScriptBlock; try { Exp = new Expression(this.Input.Text); ScriptBlock = new TextBlock() { Text = this.Input.Text, FontFamily = new FontFamily("Courier New"), TextWrapping = TextWrapping.Wrap }; ScriptBlock.PreviewMouseDown += TextBlock_PreviewMouseDown; this.HistoryPanel.Children.Add(ScriptBlock); this.HistoryScrollViewer.ScrollToBottom(); this.Input.Text = string.Empty; this.Input.Focus(); } catch (Exception ex) { ex = Log.UnnestException(ex); MessageBox.Show(this, ex.Message, "Unable to parse script.", MessageBoxButton.OK, MessageBoxImage.Error); return; } Task.Run(() => { try { IElement Ans; try { Ans = Exp.Root.Evaluate(this.variables); } catch (ScriptReturnValueException ex) { Ans = ex.ReturnValue; } catch (Exception ex) { Ans = new ObjectValue(ex); } this.variables["Ans"] = Ans; this.Dispatcher.Invoke(() => { Graph G = Ans as Graph; SKImage Img; object Obj; if (G != null) { GraphSettings Settings = new GraphSettings(); Tuple <int, int> Size; double d; if ((Size = G.RecommendedBitmapSize) != null) { Settings.Width = Size.Item1; Settings.Height = Size.Item2; Settings.MarginLeft = (int)Math.Round(15.0 * Settings.Width / 640); Settings.MarginRight = Settings.MarginLeft; Settings.MarginTop = (int)Math.Round(15.0 * Settings.Height / 480); Settings.MarginBottom = Settings.MarginTop; Settings.LabelFontSize = 12.0 * Settings.Height / 480; } else { if (this.variables.TryGetVariable("GraphWidth", out Variable v) && (Obj = v.ValueObject) is double && (d = (double)Obj) >= 1) { Settings.Width = (int)Math.Round(d); Settings.MarginLeft = (int)Math.Round(15 * d / 640); Settings.MarginRight = Settings.MarginLeft; } else if (!this.variables.ContainsVariable("GraphWidth")) { this.variables["GraphWidth"] = (double)Settings.Width; } if (this.variables.TryGetVariable("GraphHeight", out v) && (Obj = v.ValueObject) is double && (d = (double)Obj) >= 1) { Settings.Height = (int)Math.Round(d); Settings.MarginTop = (int)Math.Round(15 * d / 480); Settings.MarginBottom = Settings.MarginTop; Settings.LabelFontSize = 12 * d / 480; } else if (!this.variables.ContainsVariable("GraphHeight")) { this.variables["GraphHeight"] = (double)Settings.Height; } } using (SKImage Bmp = G.CreateBitmap(Settings, out object[] States)) { this.AddImageBlock(ScriptBlock, Bmp); } } else if ((Img = Ans.AssociatedObjectValue as SKImage) != null) { this.AddImageBlock(ScriptBlock, Img); } else if (Ans.AssociatedObjectValue is Exception ex) { AggregateException ex2; ex = Log.UnnestException(ex); if ((ex2 = ex as AggregateException) != null) { foreach (Exception ex3 in ex2.InnerExceptions) { ScriptBlock = this.AddTextBlock(ScriptBlock, ex3.Message, Colors.Red); } } else { this.AddTextBlock(ScriptBlock, ex.Message, Colors.Red); } } else { this.AddTextBlock(ScriptBlock, Ans.ToString(), Colors.Red); } }); }
private void ExecuteButton_Click(object sender, RoutedEventArgs e) { Expression Exp; TextBlock ScriptBlock; try { string s = this.Input.Text.Trim(); if (string.IsNullOrEmpty(s)) { return; } Exp = new Expression(s); ScriptBlock = new TextBlock() { Text = this.Input.Text, FontFamily = new FontFamily("Courier New"), TextWrapping = TextWrapping.Wrap }; ScriptBlock.PreviewMouseDown += TextBlock_PreviewMouseDown; this.HistoryPanel.Children.Add(ScriptBlock); this.HistoryScrollViewer.ScrollToBottom(); this.Input.Text = string.Empty; this.Input.Focus(); } catch (Exception ex) { ex = Log.UnnestException(ex); MessageBox.Show(this, ex.Message, "Unable to parse script.", MessageBoxButton.OK, MessageBoxImage.Error); return; } Task.Run(() => { try { IElement Ans; try { Ans = Exp.Root.Evaluate(this.variables); } catch (ScriptReturnValueException ex) { Ans = ex.ReturnValue; } catch (Exception ex) { Ans = new ObjectValue(ex); } this.variables["Ans"] = Ans; this.Dispatcher.Invoke(() => { SKImage Img; if (Ans is Graph G) { using (SKImage Bmp = G.CreateBitmap(this.variables, out object[] States)) { this.AddImageBlock(ScriptBlock, Bmp, G, States); } } else if ((Img = Ans.AssociatedObjectValue as SKImage) != null) { this.AddImageBlock(ScriptBlock, Img, null, null); } else if (Ans.AssociatedObjectValue is Exception ex) { ex = Log.UnnestException(ex); if (ex is AggregateException ex2) { foreach (Exception ex3 in ex2.InnerExceptions) { ScriptBlock = this.AddTextBlock(ScriptBlock, ex3.Message, Colors.Red, FontWeights.Bold); } } else { this.AddTextBlock(ScriptBlock, ex.Message, Colors.Red, FontWeights.Bold); } } else { this.AddTextBlock(ScriptBlock, Ans.ToString(), Colors.Red, FontWeights.Normal); } }); }
public override string ToString() { return($"(Setting {Name}) {ObjectValue.ToString()}"); }