本文整理汇总了C#中RubyContext.SetCurrentException方法的典型用法代码示例。如果您正苦于以下问题:C# RubyContext.SetCurrentException方法的具体用法?C# RubyContext.SetCurrentException怎么用?C# RubyContext.SetCurrentException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RubyContext
的用法示例。
在下文中一共展示了RubyContext.SetCurrentException方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetValue
public override void SetValue(RubyContext/*!*/ context, RubyScope scope, string/*!*/ name, object value) {
switch (_id) {
// regex:
case GlobalVariableId.MatchData:
if (scope == null) {
throw ReadOnlyError(name);
}
scope.GetInnerMostClosureScope().CurrentMatch = (value != null) ? RequireType<MatchData>(value, name, "MatchData") : null;
return;
case GlobalVariableId.MatchLastGroup:
case GlobalVariableId.MatchPrefix:
case GlobalVariableId.MatchSuffix:
case GlobalVariableId.EntireMatch:
throw ReadOnlyError(name);
// exceptions:
case GlobalVariableId.CurrentException:
context.SetCurrentException(value);
return;
case GlobalVariableId.CurrentExceptionBacktrace:
context.SetCurrentExceptionBacktrace(value);
return;
// input:
case GlobalVariableId.LastInputLine:
if (scope == null) {
throw ReadOnlyError(name);
}
scope.GetInnerMostClosureScope().LastInputLine = value;
return;
case GlobalVariableId.LastInputLineNumber:
context.InputProvider.LastInputLineNumber = RequireType<int>(value, name, "Fixnum");
return;
case GlobalVariableId.CommandLineArguments:
case GlobalVariableId.InputFileName:
throw ReadOnlyError(name);
// output:
case GlobalVariableId.OutputStream:
context.StandardOutput = RequireWriteProtocol(context, value, name);
return;
case GlobalVariableId.ErrorOutputStream:
context.StandardErrorOutput = RequireWriteProtocol(context, value, name);
break;
case GlobalVariableId.InputStream:
context.StandardInput = value;
return;
// separators:
case GlobalVariableId.InputContent:
throw ReadOnlyError(name);
case GlobalVariableId.InputSeparator:
context.InputSeparator = (value != null) ? RequireType<MutableString>(value, name, "String") : null;
return;
case GlobalVariableId.OutputSeparator:
context.OutputSeparator = (value != null) ? RequireType<MutableString>(value, name, "String") : null;
return;
case GlobalVariableId.StringSeparator:
// type not enforced:
context.StringSeparator = value;
return;
case GlobalVariableId.ItemSeparator:
context.ItemSeparator = (value != null) ? RequireType<MutableString>(value, name, "String") : null;
return;
// loader:
case GlobalVariableId.LoadedFiles:
case GlobalVariableId.LoadPath:
throw ReadOnlyError(name);
// misc:
case GlobalVariableId.SafeLevel:
context.SetSafeLevel(RequireType<int>(value, name, "Fixnum"));
return;
case GlobalVariableId.Verbose:
context.Verbose = value;
return;
case GlobalVariableId.CommandLineProgramPath:
context.CommandLineProgramPath = (value != null) ? RequireType<MutableString>(value, name, "String") : null;
return;
case GlobalVariableId.KCode:
#if !SILVERLIGHT
//.........这里部分代码省略.........
示例2: SetValue
public override void SetValue(RubyContext/*!*/ context, RubyScope scope, string/*!*/ name, object value) {
switch (_id) {
// regex:
case GlobalVariableId.MatchData:
if (scope == null) {
throw ReadOnlyError(name);
}
scope.GetInnerMostClosureScope().CurrentMatch = (value != null) ? RequireType<MatchData>(value, name, "MatchData") : null;
return;
case GlobalVariableId.MatchLastGroup:
case GlobalVariableId.PreMatch:
case GlobalVariableId.PostMatch:
case GlobalVariableId.EntireMatch:
throw ReadOnlyError(name);
// exceptions:
case GlobalVariableId.CurrentException:
context.SetCurrentException(value);
return;
case GlobalVariableId.CurrentExceptionBacktrace:
context.SetCurrentExceptionBacktrace(value);
return;
// input:
case GlobalVariableId.LastInputLine:
if (scope == null) {
throw ReadOnlyError(name);
}
scope.GetInnerMostClosureScope().LastInputLine = value;
return;
case GlobalVariableId.LastInputLineNumber:
context.InputProvider.LastInputLineNumber = RequireType<int>(value, name, "Fixnum");
return;
case GlobalVariableId.CommandLineArguments:
case GlobalVariableId.InputFileName:
throw ReadOnlyError(name);
// output:
case GlobalVariableId.OutputStream:
context.StandardOutput = RequireWriteProtocol(context, value, name);
return;
case GlobalVariableId.ErrorOutputStream:
context.StandardErrorOutput = RequireWriteProtocol(context, value, name);
break;
case GlobalVariableId.InputStream:
context.StandardInput = value;
return;
// separators:
case GlobalVariableId.InputContent:
throw ReadOnlyError(name);
case GlobalVariableId.InputSeparator:
context.InputSeparator = (value != null) ? RequireType<MutableString>(value, name, "String") : null;
return;
case GlobalVariableId.OutputSeparator:
context.OutputSeparator = (value != null) ? RequireType<MutableString>(value, name, "String") : null;
return;
case GlobalVariableId.StringSeparator:
// type not enforced:
context.StringSeparator = value;
return;
case GlobalVariableId.ItemSeparator:
context.ItemSeparator = (value != null) ? RequireType<MutableString>(value, name, "String") : null;
return;
// loader:
case GlobalVariableId.LoadedFiles:
case GlobalVariableId.LoadPath:
throw ReadOnlyError(name);
// misc:
case GlobalVariableId.SafeLevel:
context.SetSafeLevel(RequireType<int>(value, name, "Fixnum"));
return;
case GlobalVariableId.Verbose:
context.Verbose = value;
return;
case GlobalVariableId.CommandLineProgramPath:
context.CommandLineProgramPath = (value != null) ? RequireType<MutableString>(value, name, "String") : null;
return;
case GlobalVariableId.KCode:
context.ReportWarning("variable $KCODE is no longer effective");
//.........这里部分代码省略.........