当前位置: 首页>>代码示例>>C#>>正文


C# RubyContext.SetCurrentException方法代码示例

本文整理汇总了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
//.........这里部分代码省略.........
开发者ID:toddb,项目名称:ironruby,代码行数:101,代码来源:SpecialGlobalVariableInfo.cs

示例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");
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


注:本文中的RubyContext.SetCurrentException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。