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


C# RubyContext.IsInstanceOf方法代码示例

本文整理汇总了C#中RubyContext.IsInstanceOf方法的典型用法代码示例。如果您正苦于以下问题:C# RubyContext.IsInstanceOf方法的具体用法?C# RubyContext.IsInstanceOf怎么用?C# RubyContext.IsInstanceOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RubyContext的用法示例。


在下文中一共展示了RubyContext.IsInstanceOf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Step

 public static object Step(RubyContext/*!*/ context, BlockParam block, Range/*!*/ self, object step) {
     // We attempt to cast step to Fixnum here even though if we were iterating over Floats, for instance, we use step as is.
     // This prevents cases such as (1.0..2.0).step(0x800000000000000) {|x| x } from working but that is what MRI does.
     int intStep = Protocols.CastToFixnum(context, step);
     if (self.Begin is int && self.End is int) {
         // self.begin is Fixnum; directly call item = item + 1 instead of succ
         return StepFixnum(context, block, self, (int)self.Begin, (int)self.End, intStep);
     } else if ( self.Begin is MutableString ) {
         // self.begin is String; use item.succ and item <=> self.end but make sure you check the length of the strings
         return StepString(context, block, self, (MutableString)self.Begin, (MutableString)self.End, intStep);
     } else if (context.IsInstanceOf(self.Begin, context.GetClass(typeof(Numeric)))) {
         // self.begin is Numeric; invoke item = item + 1 instead of succ and invoke < or <= for compare
         return StepNumeric(context, block, self, self.Begin, self.End, step);
     } else {
         // self.begin is not Numeric or String; just invoke item.succ and item <=> self.end
         CheckBegin(context, self.Begin);
         return StepObject(context, block, self, self.Begin, self.End, intStep);
     }
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:19,代码来源:RangeOps.cs

示例2: Step

        public static object Step(
            ConversionStorage<MutableString>/*!*/ stringCast, 
            ConversionStorage<int>/*!*/ fixnumCast, 
            RespondToStorage/*!*/ respondToStorage,
            BinaryOpStorage/*!*/ comparisonStorage,
            BinaryOpStorage/*!*/ lessThanStorage,
            BinaryOpStorage/*!*/ lessThanEqualsStorage,
            BinaryOpStorage/*!*/ greaterThanStorage,
            BinaryOpStorage/*!*/ equalsStorage,
            BinaryOpStorage/*!*/ addStorage,
            UnaryOpStorage/*!*/ succStorage,
            RubyContext/*!*/ context, BlockParam block, Range/*!*/ self, [Optional]object step) {

            if (step == Missing.Value) {
                step = ScriptingRuntimeHelpers.Int32ToObject(1);
            }
            
            // We attempt to cast step to Fixnum here even though if we were iterating over Floats, for instance, we use step as is.
            // This prevents cases such as (1.0..2.0).step(0x800000000000000) {|x| x } from working but that is what MRI does.
            if (self.Begin is int && self.End is int) {
                // self.begin is Fixnum; directly call item = item + 1 instead of succ
                int intStep = Protocols.CastToFixnum(fixnumCast, context, step);
                return StepFixnum(context, block, self, (int)self.Begin, (int)self.End, intStep);
            } else if (self.Begin is MutableString ) {
                // self.begin is String; use item.succ and item <=> self.end but make sure you check the length of the strings
                int intStep = Protocols.CastToFixnum(fixnumCast, context, step);
                return StepString(stringCast, comparisonStorage, lessThanStorage, greaterThanStorage, succStorage, context,
                    block, self, (MutableString)self.Begin, (MutableString)self.End, intStep
                );
            } else if (context.IsInstanceOf(self.Begin, context.GetClass(typeof(Numeric)))) {
                // self.begin is Numeric; invoke item = item + 1 instead of succ and invoke < or <= for compare
                return StepNumeric(lessThanStorage, lessThanEqualsStorage, equalsStorage, addStorage, context, 
                    block, self, self.Begin, self.End, step
                );
            } else {
                // self.begin is not Numeric or String; just invoke item.succ and item <=> self.end
                CheckBegin(respondToStorage, context, self.Begin);
                int intStep = Protocols.CastToFixnum(fixnumCast, context, step);
                return StepObject(comparisonStorage, lessThanStorage, greaterThanStorage, equalsStorage, succStorage, context,
                    block, self, self.Begin, self.End, intStep
                );
            }
        }
开发者ID:tnachen,项目名称:ironruby,代码行数:43,代码来源:RangeOps.cs


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