public static string /*!*/ __repr__(object /*!*/ self) { return(String.Format("<{0} object at {1}>", self.ToString(), PythonOps.HexId(self) )); }
public static string /*!*/ __repr__(object /*!*/ self) { return(String.Format("<{0}({1}) object at {2}>", self.ToString(), TypeDescriptor.GetClassName(self), PythonOps.HexId(self) )); }
public static string __repr__(CodeContext /*!*/ context, [NotNull] Array /*!*/ self) { List <object> infinite = PythonOps.GetAndCheckInfinite(self); if (infinite == null) { return("..."); } int index = infinite.Count; infinite.Add(self); try { StringBuilder ret = new StringBuilder(); if (self.Rank == 1) { // single dimensional Array's have a valid display ret.Append("Array["); Type elemType = self.GetType().GetElementType(); ret.Append(DynamicHelpers.GetPythonTypeFromType(elemType).Name); ret.Append("]"); ret.Append("(("); for (int i = 0; i < self.Length; i++) { if (i > 0) { ret.Append(", "); } ret.Append(PythonOps.Repr(context, self.GetValue(i + self.GetLowerBound(0)))); } ret.Append("))"); } else { // multi dimensional arrays require multiple statements to construct so we just // give enough info to identify the object and its type. ret.Append("<"); ret.Append(self.Rank); ret.Append(" dimensional Array["); Type elemType = self.GetType().GetElementType(); ret.Append(DynamicHelpers.GetPythonTypeFromType(elemType).Name); ret.Append("] at "); ret.Append(PythonOps.HexId(self)); ret.Append(">"); } return(ret.ToString()); } finally { System.Diagnostics.Debug.Assert(index == infinite.Count - 1); infinite.RemoveAt(index); } }
/// <summary> /// Returns the code representation of the object. The default implementation returns /// a string which consists of the type and a unique numerical identifier. /// </summary> public static string __repr__(object self) { return(String.Format("<{0} object at {1}>", DynamicHelpers.GetPythonType(self).Name, PythonOps.HexId(self))); }
public static string FancyRepr(object self) { PythonType pt = (PythonType)DynamicHelpers.GetPythonType(self); // we can't call ToString on a UserType because we'll stack overflow, so // only do FancyRepr for reflected types. if (pt.IsSystemType) { string toStr = self.ToString(); if (toStr == null) { toStr = String.Empty; } // get the type name to display (CLI name or Python name) Type type = pt.UnderlyingSystemType; string typeName = type.FullName; // Get the underlying .ToString() representation. Truncate multiple // lines, and don't display it if it's object's default representation (type name) // skip initial empty lines: int i = 0; while (i < toStr.Length && (toStr[i] == '\r' || toStr[i] == '\n')) { i++; } // read the first non-empty line: int j = i; while (j < toStr.Length && toStr[j] != '\r' && toStr[j] != '\n') { j++; } // skip following empty lines: int k = j; while (k < toStr.Length && (toStr[k] == '\r' || toStr[k] == '\n')) { k++; } if (j > i) { string first_non_empty_line = toStr.Substring(i, j - i); bool has_multiple_non_empty_lines = k < toStr.Length; return(String.Format("<{0} object at {1} [{2}{3}]>", typeName, PythonOps.HexId(self), first_non_empty_line, has_multiple_non_empty_lines ? "..." : String.Empty)); } else { return(String.Format("<{0} object at {1}>", typeName, PythonOps.HexId(self))); } } return(SimpleRepr(self)); }
public static string SimpleRepr(object self) { return(String.Format("<{0} object at {1}>", PythonTypeOps.GetName(self), PythonOps.HexId(self))); }
public static string __repr__(object self) { return($"<{DynamicHelpers.GetPythonType(self).Name} object at {PythonOps.HexId(self)}>"); }
public static string __repr__(object self) { return($"<{PythonOps.GetPythonTypeName(self)} object at {PythonOps.HexId(self)}>"); }
public static string /*!*/ __repr__(object /*!*/ self) { return($"<{self.ToString()}({TypeDescriptor.GetClassName(self)}) object at {PythonOps.HexId(self)}>"); }