public static MutableString /*!*/ Inspect(RubyStruct /*!*/ self) { RubyContext context = self.ImmediateClass.Context; using (IDisposable handle = RubyUtils.InfiniteInspectTracker.TrackObject(self)) { // #<struct Struct::Foo name=nil, val=nil> var result = MutableString.CreateMutable(RubyEncoding.Binary); result.Append("#<struct "); result.Append(context.Inspect(context.GetClassOf(self))); if (handle == null) { return(result.Append(":...>")); } result.Append(' '); object[] data = self.Values; var members = self.GetNames(); for (int i = 0; i < data.Length; i++) { if (i != 0) { result.Append(", "); } // TODO (encoding): result.Append(members[i]); result.Append('='); result.Append(context.Inspect(data[i])); } result.Append('>'); return(result); } }
public static MutableString /*!*/ Inspect(RubyContext /*!*/ context, Hash /*!*/ self) { using (IDisposable handle = RubyUtils.InfiniteInspectTracker.TrackObject(self)) { if (handle == null) { return(MutableString.CreateAscii("{...}")); } MutableString str = MutableString.CreateMutable(RubyEncoding.Binary); str.Append('{'); bool first = true; foreach (var entry in self) { if (first) { first = false; } else { str.Append(", "); } str.Append(context.Inspect(BaseSymbolDictionary.ObjToNull(entry.Key))); str.Append("=>"); str.Append(context.Inspect(entry.Value)); } str.Append('}'); return(str); } }
public MutableString /*!*/ Inspect(RubyContext /*!*/ context) { var result = MutableString.CreateMutable(RubyEncoding.Binary); result.Append(context.Inspect(_begin)); result.Append(Separator); result.Append(context.Inspect(_end)); return(result); }
public static MutableString /*!*/ Inspect(RubyContext /*!*/ context, YamlStream /*!*/ self) { MutableString result = MutableString.CreateMutable("#<YAML::Stream:", RubyEncoding.Binary); RubyUtils.AppendFormatHexObjectId(result, RubyUtils.GetObjectId(context, self)) .Append(" @documents=") .Append(context.Inspect(self._documents)) .Append(", options=") .Append(context.Inspect(self._options)) .Append('>'); return(result); }
internal static string /*!*/ FormatMethodMissingMessage(RubyContext /*!*/ context, object obj, string /*!*/ name, string /*!*/ message) { Assert.NotNull(name); string str; if (obj == null) { str = "nil:NilClass"; } else if (_disableMethodMissingMessageFormatting) { str = RubyUtils.ObjectToMutableString(context, obj).ToString(); } else { _disableMethodMissingMessageFormatting = true; try { str = context.Inspect(obj).ConvertToString(); if (!str.StartsWith("#", StringComparison.Ordinal)) { str += ":" + context.GetClassName(obj); } } catch (Exception) { // MRI: swallows all exceptions str = RubyUtils.ObjectToMutableString(context, obj).ToString(); } finally { _disableMethodMissingMessageFormatting = false; } } return(FormatMessage(message, name, str)); }
public static MutableString Inspect(RubyContext /*!*/ context, IDictionary <object, object> /*!*/ self) { using (IDisposable handle = RubyUtils.InfiniteInspectTracker.TrackObject(self)) { if (handle == null) { return(MutableString.CreateAscii("{...}")); } MutableString str = MutableString.CreateMutable(RubyEncoding.Binary); str.Append('{'); foreach (KeyValuePair <object, object> pair in self) { if (str.Length != 1) { str.Append(", "); } str.Append(context.Inspect(CustomStringDictionary.ObjToNull(pair.Key))); str.Append("=>"); str.Append(context.Inspect(pair.Value)); } str.Append('}'); return(str); } }
public static MutableString ToString(RubyContext /*!*/ context, Certificate /*!*/ self) { using (IDisposable handle = RubyUtils.InfiniteInspectTracker.TrackObject(self)) { // #<OpenSSL::X509::Certificate subject=, issuer=, serial=0, not_before=nil, not_after=nil> var result = MutableString.CreateEmpty(); result.Append("#<"); result.Append(context.Inspect(context.GetClassOf(self))); if (handle == null) { return(result.Append(":...>")); } bool empty = self.IsEmpty; result.AppendFormat(" subject={0}, issuer={1}, serial={2}, not_before=nil, not_after=nil>", empty ? "" : OpenSSLFormat(self._certificate.Subject), empty ? "" : OpenSSLFormat(self._certificate.Issuer), empty ? 0 : self.SerailNumber ); return(result); } }
internal static string/*!*/ FormatMethodMissingMessage(RubyContext/*!*/ context, object obj, string/*!*/ name, string/*!*/ message) { Assert.NotNull(name); string str; if (obj == null) { str = "nil:NilClass"; } else if (_disableMethodMissingMessageFormatting) { str = RubyUtils.ObjectToMutableString(context, obj).ToString(); } else { _disableMethodMissingMessageFormatting = true; try { str = context.Inspect(obj).ConvertToString(); if (!str.StartsWith("#", StringComparison.Ordinal)) { str += ":" + context.GetClassName(obj); } } catch (Exception) { // MRI: swallows all exceptions str = RubyUtils.ObjectToMutableString(context, obj).ToString(); } finally { _disableMethodMissingMessageFormatting = false; } } return FormatMessage(message, name, str); }
public static Exception/*!*/ InvalidValueForType(RubyContext/*!*/ context, object obj, string type) { return CreateArgumentError("invalid value for {0}: {1}", type, context.Inspect(obj)); }
public static MutableString/*!*/ Inspect(RubyContext/*!*/ context, IList/*!*/ self) { using (IDisposable handle = RubyUtils.InfiniteInspectTracker.TrackObject(self)) { if (handle == null) { return MutableString.Create("[...]"); } MutableString str = MutableString.CreateMutable(); str.Append('['); bool first = true; foreach (object obj in self) { if (first) { first = false; } else { str.Append(", "); } str.Append(context.Inspect(obj)); } str.Append(']'); return str; } }
/*!*/ public MutableString Inspect(RubyContext/*!*/ context) { var result = MutableString.CreateMutable(RubyEncoding.Binary); result.Append(context.Inspect(_begin)); result.Append(Separator); result.Append(context.Inspect(_end)); return result; }
public static MutableString/*!*/ Inspect(RubyContext/*!*/ context, FileSystemInfo/*!*/ self) { return MutableString.CreateAscii(String.Format(CultureInfo.InvariantCulture, "#<File::Stat dev={0}, ino={1}, mode={2}, nlink={3}, uid={4}, gid={5}, rdev={6}, size={7}, blksize={8}, blocks={9}, atime={10}, mtime={11}, ctime={12}", context.Inspect(DeviceId(self)), context.Inspect(Inode(self)), context.Inspect(Mode(self)), context.Inspect(NumberOfLinks(self)), context.Inspect(UserId(self)), context.Inspect(GroupId(self)), context.Inspect(DeviceId(self)), context.Inspect(Size(self)), context.Inspect(BlockSize(self)), context.Inspect(Blocks(self)), context.Inspect(AccessTime(self)), context.Inspect(ModifiedTime(self)), context.Inspect(CreateTime(self)) )); }
public static MutableString /*!*/ Inspect(RubyContext /*!*/ context, FileSystemInfo /*!*/ self) { return(MutableString.CreateAscii(String.Format(CultureInfo.InvariantCulture, "#<File::Stat dev={0}, ino={1}, mode={2}, nlink={3}, uid={4}, gid={5}, rdev={6}, size={7}, blksize={8}, blocks={9}, atime={10}, mtime={11}, ctime={12}", context.Inspect(DeviceId(self)), context.Inspect(Inode(self)), context.Inspect(Mode(self)), context.Inspect(NumberOfLinks(self)), context.Inspect(UserId(self)), context.Inspect(GroupId(self)), context.Inspect(DeviceId(self)), context.Inspect(Size(self)), context.Inspect(BlockSize(self)), context.Inspect(Blocks(self)), context.Inspect(AccessTime(self)), context.Inspect(ModifiedTime(self)), context.Inspect(CreateTime(self)) ))); }
public static Exception /*!*/ InvalidValueForType(RubyContext /*!*/ context, object obj, string type) { return(CreateArgumentError("invalid value for {0}: {1}", type, context.Inspect(obj))); }
public static MutableString Inspect(RubyContext/*!*/ context, YamlStream/*!*/ self) { MutableString result = MutableString.CreateMutable("#<YAML::Stream:", RubyEncoding.Binary); RubyUtils.AppendFormatHexObjectId(result, RubyUtils.GetObjectId(context, self)) .Append(" @documents=") .Append(context.Inspect(self._documents)) .Append(", options=") .Append(context.Inspect(self._options)) .Append('>'); return result; }
public static MutableString/*!*/ Inspect(UnaryOpStorage/*!*/ inspectStorage, ConversionStorage<MutableString>/*!*/ tosStorage, RubyContext/*!*/ context, Range/*!*/ self) { var result = MutableString.CreateMutable(); result.Append(context.Inspect(self.Begin)); result.Append(self.ExcludeEnd ? "..." : ".."); result.Append(context.Inspect(self.End)); return result; }
public static void Throw(RubyContext/*!*/ context, object self, object label, [DefaultParameterValue(null)]object returnValue) { if (_catchSymbols == null || !_catchSymbols.Contains(label, ReferenceEqualityComparer.Instance)) { throw RubyExceptions.CreateNameError("uncaught throw `{0}'", context.Inspect(label).ToAsciiString(false)); } throw new ThrowCatchUnwinder(label, returnValue); }
public static MutableString/*!*/ Inspect(RubyContext/*!*/ context, Hash/*!*/ self) { using (IDisposable handle = RubyUtils.InfiniteInspectTracker.TrackObject(self)) { if (handle == null) { return MutableString.CreateAscii("{...}"); } MutableString str = MutableString.CreateMutable(RubyEncoding.Binary); str.Append('{'); bool first = true; foreach (var entry in self) { if (first) { first = false; } else { str.Append(", "); } str.Append(context.Inspect(CustomStringDictionary.ObjToNull(entry.Key))); str.Append("=>"); str.Append(context.Inspect(entry.Value)); } str.Append('}'); return str; } }
public static MutableString Inspect(RubyContext/*!*/ context, IList/*!*/ self) { using (IDisposable handle = RubyUtils.InfiniteInspectTracker.TrackObject(self)) { if (handle == null) { return MutableString.CreateAscii("[...]"); } MutableString str = MutableString.CreateMutable(RubyEncoding.Binary); if (self.Count > 0) { // tainted empty arrays don't taint the inspect string if the array is empty str.TaintBy(self, context); } str.Append('['); bool first = true; foreach (object obj in self) { if (first) { first = false; } else { str.Append(", "); } var objInspected = context.Inspect(obj); str.Append(objInspected); str.TaintBy(objInspected); } str.Append(']'); return str; } }
public static MutableString ToString(RubyContext/*!*/ context, Certificate/*!*/ self) { using (IDisposable handle = RubyUtils.InfiniteInspectTracker.TrackObject(self)) { // #<OpenSSL::X509::Certificate subject=, issuer=, serial=0, not_before=nil, not_after=nil> var result = MutableString.CreateEmpty(); result.Append("#<"); result.Append(context.Inspect(context.GetClassOf(self))); if (handle == null) { return result.Append(":...>"); } bool empty = self._certificate.Handle == IntPtr.Zero; result.AppendFormat(" subject={0}, issuer={1}, serial={2}, not_before=nil, not_after=nil>", empty ? "" : OpenSSLFormat(self._certificate.Subject), empty ? "" : OpenSSLFormat(self._certificate.Issuer), empty ? 0 : self.SerailNumber ); return result; } }
public static MutableString ToString(RubyContext/*!*/ context, Certificate/*!*/ self) { using (IDisposable handle = RubyUtils.InfiniteInspectTracker.TrackObject(self)) { // #<OpenSSL::X509::Certificate subject=, issuer=, serial=0, not_before=nil, not_after=nil> var result = MutableString.CreateEmpty(); result.Append("#<"); result.Append(context.Inspect(context.GetClassOf(self))); if (handle == null) { return result.Append(":...>"); } result.Append(' '); if (self._certificate.Handle == IntPtr.Zero) { result.Append("subject=, issuer=, serial=0, not_before=nil, not_after=nil"); } else { result.Append(string.Format("subject={0}", OpenSSLFormat(self._certificate.Subject))); result.Append(string.Format(", issuer={0}", OpenSSLFormat(self._certificate.Issuer))); result.Append(string.Format(", serial={0}", self.SerailNumber)); result.Append(string.Concat(", not_before=", "nil")); result.Append(string.Concat(", not_after=", "nil")); } result.Append('>'); return result; } }