public void SetCell(ButtonCell cell, int index) { if (!cachedCellTexts.ContainsKey(index)) { string text; if (m_context == SearchContext.StaticClass) { text = SignatureHighlighter.Parse(currentResults[index] as Type, true); } else { text = ToStringUtility.ToStringWithType(currentResults[index], currentResults[index]?.GetActualType()); } cachedCellTexts.Add(index, text); } cell.Button.ButtonText.text = cachedCellTexts[index]; }
public void SetKey(object key) { this.DictKey = key; this.DisplayedKey = key.TryCast(); var type = DisplayedKey.GetType(); if (ParseUtility.CanParse(type)) { KeyInputWanted = true; KeyInputText = ParseUtility.ToStringForInput(DisplayedKey, type); KeyInputTypeText = SignatureHighlighter.Parse(type, false); } else { KeyInputWanted = false; InspectWanted = type != typeof(bool) && !type.IsEnum; KeyLabelText = ToStringUtility.ToStringWithType(DisplayedKey, type, true); } }
protected string GetValueLabel() { string label = ""; switch (State) { case ValueState.NotEvaluated: return($"<i>{NOT_YET_EVAL} ({SignatureHighlighter.Parse(FallbackType, true)})</i>"); case ValueState.Exception: return($"<i><color=red>{LastException.ReflectionExToString()}</color></i>"); // bool and number dont want the label for the value at all case ValueState.Boolean: case ValueState.Number: return(null); // and valuestruct also doesnt want it if we can parse it case ValueState.ValueStruct: if (ParseUtility.CanParse(LastValueType)) { return(null); } break; // string wants it trimmed to max 200 chars case ValueState.String: if (!LastValueWasNull) { return($"\"{ToStringUtility.PruneString(Value as string, 200, 5)}\""); } break; // try to prefix the count of the collection for lists and dicts case ValueState.Collection: if (!LastValueWasNull) { if (Value is IList iList) { label = $"[{iList.Count}] "; } else if (Value is ICollection iCol) { label = $"[{iCol.Count}] "; } else { label = "[?] "; } } break; case ValueState.Dictionary: if (!LastValueWasNull) { if (Value is IDictionary iDict) { label = $"[{iDict.Count}] "; } else { label = "[?] "; } } break; } // Cases which dont return will append to ToStringWithType return(label += ToStringUtility.ToStringWithType(Value, FallbackType, true)); }
private static void UpdateCurrentPasteInfo() { CurrentPasteLabel.text = ToStringUtility.ToStringWithType(Current, typeof(object), false); }