• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Runtime.BlockParam类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IronRuby.Runtime.BlockParam的典型用法代码示例。如果您正苦于以下问题:C# BlockParam类的具体用法?C# BlockParam怎么用?C# BlockParam使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BlockParam类属于IronRuby.Runtime命名空间,在下文中一共展示了BlockParam类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: EachObject

        public static object EachObject(BlockParam block, RubyModule/*!*/ self, [NotNull]RubyClass/*!*/ theClass) {
            Type classType = theClass.GetType();
            bool isClass = (classType == typeof(RubyClass));
            if (!isClass && classType != typeof(RubyModule)) {
                throw new NotSupportedException("each_object only supported for objects of type Class or Module");
            }
            if (block == null) {
                throw RubyExceptions.NoBlockGiven();
            }

            Dictionary<RubyModule, object> visited = new Dictionary<RubyModule, object>();
            Stack<RubyModule> modules = new Stack<RubyModule>();
            modules.Push(theClass.Context.ObjectClass);
            while (modules.Count > 0) {
                RubyModule next = modules.Pop();
                RubyClass asClass = next as RubyClass;

                if (!isClass || asClass != null) {
                    object result;
                    if (block.Yield(next, out result)) {
                        return result;
                    }
                }
                next.EnumerateConstants(delegate(RubyModule module, string name, object value) {
                    RubyModule constAsModule = (value as RubyModule);
                    if (constAsModule != null && !visited.ContainsKey(constAsModule)) {
                        modules.Push(constAsModule);
                        visited[module] = null;
                    }
                    return false;
                });
            }
            return visited.Count;
        }
开发者ID:joshholmes,项目名称:ironruby,代码行数:34,代码来源:ObjectSpace.cs


示例2: CreateHash

 public static Hash CreateHash(BlockParam block, RubyClass/*!*/ self, object defaultValue)
 {
     if (block != null) {
         throw RubyExceptions.CreateArgumentError("wrong number of arguments");
     }
     return new Hash(self.Context.EqualityComparer, null, defaultValue);
 }
开发者ID:TerabyteX,项目名称:main,代码行数:7,代码来源:HashOps.cs


示例3: Reinitialize

        public static object Reinitialize(BlockParam block, RubyModule/*!*/ self) {
            // no class can be reinitialized:
            if (self.IsClass) {
                throw RubyExceptions.CreateTypeError("already initialized class");
            }

            return (block != null) ? RubyUtils.EvaluateInModule(self, block, null) : null;
        }
开发者ID:atczyc,项目名称:ironruby,代码行数:8,代码来源:ModuleOps.cs


示例4: BlockRetry

 public static object BlockRetry(BlockParam/*!*/ blockFlowControl) {
     if (blockFlowControl.CallerKind == BlockCallerKind.Yield) {
         blockFlowControl.SetFlowControl(BlockReturnReason.Retry, null, blockFlowControl.Proc.Kind);
         return RetrySingleton;
     } else {
         throw new LocalJumpError("retry from proc-closure");
     }
 }
开发者ID:andreakn,项目名称:ironruby,代码行数:8,代码来源:RubyOps.FlowControl.cs


示例5: Initialize

 public static Hash/*!*/ Initialize(BlockParam block, Hash/*!*/ self, object defaultValue) {
     Assert.NotNull(self);
     if (block != null) {
         throw RubyExceptions.CreateArgumentError("wrong number of arguments");
     }
     self.DefaultProc = null;
     self.DefaultValue = defaultValue;
     return self;
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:9,代码来源:HashOps.cs


示例6: Create

        /// <summary>
        /// Struct#new
        /// Creates Struct classes with the specified name and members
        /// </summary>
        private static object Create(BlockParam block, RubyClass/*!*/ self, string className, string/*!*/[]/*!*/ attributeNames) {
            var result = RubyStruct.DefineStruct(self, className, attributeNames);

            if (block != null) {
                return RubyUtils.EvaluateInModule(result, block, null, result);
            }

            return result;
        }
开发者ID:jschementi,项目名称:iron,代码行数:13,代码来源:StructOps.cs


示例7: AtExit

        public static Proc AtExit(BlockParam/*!*/ block, object self)
        {
            if (block == null) {
                throw RubyExceptions.CreateArgumentError("called without a block");
            }

            block.RubyContext.RegisterShutdownHandler(block.Proc);
            return block.Proc;
        }
开发者ID:TerabyteX,项目名称:main,代码行数:9,代码来源:KernelOps.cs


示例8: Scan

 public static Object Scan(ConversionStorage<MutableString>/*!*/ toMutableStringStorage, RespondToStorage/*!*/ respondsTo, 
     BinaryOpStorage/*!*/ readIOStorage, BlockParam block, RubyModule/*!*/ self, Object/*!*/ source, Hash/*!*/ options)
 {
     Object elementContent;
     if (!self.TryGetConstant(null, "ElementContent", out elementContent) && !(elementContent is Hash)) {
         throw new Exception("Hpricot::ElementContent is missing or it is not an Hash");
     }
     var scanner = new HpricotScanner(toMutableStringStorage, readIOStorage, block);
     return scanner.Scan(source, options, elementContent as Hash);
 }
开发者ID:nrk,项目名称:ironruby-hpricot,代码行数:10,代码来源:Hpricot.cs


示例9: NewStruct

        public static object NewStruct(BlockParam block, RubyClass/*!*/ self, [DefaultProtocol]MutableString className,
            [DefaultProtocol, NotNullItems]params string/*!*/[]/*!*/ attributeNames) {

            if (className == null) {
                return Create(block, self, null, attributeNames);
            }

            string strName = className.ConvertToString();
            RubyUtils.CheckConstantName(strName);
            return Create(block, self, strName, attributeNames);
        }
开发者ID:jschementi,项目名称:iron,代码行数:11,代码来源:StructOps.cs


示例10: Synchronize

 public static object Synchronize(BlockParam criticalSection, RubyMutex/*!*/ self) {
     lock (self._mutex) {
         self._isLocked = true;
         try {
             object result;
             criticalSection.Yield(out result);
             return result;
         } finally {
             self._isLocked = false;
         }
     }
 }
开发者ID:jcteague,项目名称:ironruby,代码行数:12,代码来源:RubyMutex.cs


示例11: NewStruct

        public static object NewStruct(BlockParam block, RubyClass/*!*/ self, [DefaultProtocol, Optional]MutableString className,
            [NotNull]params object[]/*!*/ attributeNames) {

            string[] symbols = Protocols.CastToSymbols(self.Context, attributeNames);

            if (className == null) {
                return Create(block, self, null, symbols);
            }

            string strName = className.ConvertToString();
            RubyUtils.CheckConstantName(strName);
            return Create(block, self, strName, symbols);
        }
开发者ID:joshholmes,项目名称:ironruby,代码行数:13,代码来源:StructOps.cs


示例12: Map

 public static RubyArray Map(RubyContext/*!*/ context, BlockParam collector, object self) {
     RubyArray result = new RubyArray();
     Each(context, self, Proc.Create(context, delegate(BlockParam/*!*/ selfBlock, object item) {
         if (collector != null) {
             if (collector.Yield(item, out item)) {
                 return item;
             }
         }
         result.Add(item);
         return null;
     }));
     return result;
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:13,代码来源:Enumerable.cs


示例13: Each

        public static object Each(BlockParam block, IEnumerable/*!*/ self) {
            foreach (object obj in self) {
                object result;
                if (block == null) {
                    throw RubyExceptions.NoBlockGiven();
                }

                if (block.Yield(obj, out result)) {
                    return result;
                }
            }
            return self;
        }
开发者ID:rudimk,项目名称:dlr-dotnet,代码行数:13,代码来源:IEnumerableOps.cs


示例14: Map

 public static RubyArray Map(CallSiteStorage<EachSite>/*!*/ each, BlockParam collector, object self) {
     RubyArray result = new RubyArray();
     Each(each, self, Proc.Create(each.Context, delegate(BlockParam/*!*/ selfBlock, object _, object item) {
         if (collector != null) {
             if (collector.Yield(item, out item)) {
                 return item;
             }
         }
         result.Add(item);
         return null;
     }));
     return result;
 }
开发者ID:Hank923,项目名称:ironruby,代码行数:13,代码来源:Enumerable.cs


示例15: Count

        public static int Count(CallSiteStorage<EachSite>/*!*/ each, BinaryOpStorage/*!*/ equals, BlockParam comparer, object self, object value)
        {
            if (comparer != null) {
                each.Context.ReportWarning("given block not used");
            }

            int result = 0;
            Each(each, self, Proc.Create(each.Context, delegate(BlockParam/*!*/ selfBlock, object _, object item) {
                if (Protocols.IsEqual(equals, item, value)) {
                    result++;
                }
                return null;
            }));
            return result;
        }
开发者ID:TerabyteX,项目名称:main,代码行数:15,代码来源:Enumerable.cs


示例16: CreateArray

        public static object CreateArray(ConversionStorage<Union<IList, int>>/*!*/ toAryToInt,
            BlockParam block, RubyClass/*!*/ self, [NotNull]object/*!*/ arrayOrSize) {

            var site = toAryToInt.GetSite(CompositeConversionAction.Make(toAryToInt.Context, CompositeConversion.ToAryToInt));
            var union = site.Target(site, arrayOrSize);

            if (union.First != null) {
                // block ignored
                return CreateArray(union.First);
            } else if (block != null) {
                return CreateArray(block, union.Second);
            } else {
                return CreateArray(self, union.Second, null);
            }
        }
开发者ID:toddb,项目名称:ironruby,代码行数:15,代码来源:ArrayOps.cs


示例17: EachType

        public static object EachType(RubyContext/*!*/ context, BlockParam/*!*/ block, TypeGroup/*!*/ self) {
            if (block == null) {
                throw RubyExceptions.NoBlockGiven();
            }

            foreach (Type type in self.Types) {
                RubyModule module = context.GetModule(type);
                object result;
                if (block.Yield(module, out result)) {
                    return result;
                }
            }

            return self;
        }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:15,代码来源:TypeGroupOps.cs


示例18: Each

        public static object Each(BlockParam block, RubyStruct/*!*/ self)
        {
            if (block == null && self.ItemCount > 0) {
                throw RubyExceptions.NoBlockGiven();
            }

            foreach (var value in self.Values) {
                object result;
                if (block.Yield(value, out result)) {
                    return result;
                }
            }

            return self;
        }
开发者ID:TerabyteX,项目名称:main,代码行数:15,代码来源:StructOps.cs


示例19: BlockReturn

        public static object BlockReturn(BlockParam/*!*/ blockFlowControl, object returnValue)
        {
            Proc proc = blockFlowControl.Proc;
            if (blockFlowControl.CallerKind == BlockCallerKind.Call && proc.Kind == ProcKind.Lambda) {
                return returnValue;
            }

            RuntimeFlowControl owner = proc.LocalScope.FlowControlScope;
            if (owner.IsActiveMethod) {
                blockFlowControl.ReturnReason = BlockReturnReason.Return;
                return new BlockReturnResult(owner, returnValue);
            }

            throw new LocalJumpError("unexpected return");
        }
开发者ID:TerabyteX,项目名称:main,代码行数:15,代码来源:RubyOps.FlowControl.cs


示例20: Synchronize

 public static object Synchronize(BlockParam criticalSection, RubyMutex/*!*/ self) {
     bool lockTaken = false;
     try {
         MonitorUtils.Enter(self._mutex, ref lockTaken);
         self._isLocked = lockTaken;
         object result;
         criticalSection.Yield(out result);
         return result;
     } finally {
         if (lockTaken) {
             MonitorUtils.Exit(self._mutex, ref lockTaken);
             self._isLocked = lockTaken;
         }
     }
 }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:15,代码来源:RubyMutex.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Runtime.RubyGlobalScope类代码示例发布时间:2022-05-26
下一篇:
C# Ast.Walker类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap