本文整理汇总了C#中RubyContext.Inspect方法的典型用法代码示例。如果您正苦于以下问题:C# RubyContext.Inspect方法的具体用法?C# RubyContext.Inspect怎么用?C# RubyContext.Inspect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RubyContext
的用法示例。
在下文中一共展示了RubyContext.Inspect方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToString
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;
}
}
示例2: FormatMethodMissingMessage
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);
}
示例3: Inspect
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;
}
示例4: Inspect
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;
}
}
示例5: InvalidValueForType
public static Exception/*!*/ InvalidValueForType(RubyContext/*!*/ context, object obj, string type) {
return CreateArgumentError("invalid value for {0}: {1}", type, context.Inspect(obj));
}
示例6: Inspect
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))
));
}
示例7: Inspect
/*!*/
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;
}
示例8: ToString
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;
}
}
示例9: Inspect
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;
}
示例10: Throw
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);
}
示例11: Inspect
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;
}
}
示例12: Inspect
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;
}
}