本文整理汇总了C#中IronRuby.Builtins.Proc.Create方法的典型用法代码示例。如果您正苦于以下问题:C# Proc.Create方法的具体用法?C# Proc.Create怎么用?C# Proc.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IronRuby.Builtins.Proc
的用法示例。
在下文中一共展示了Proc.Create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateNew
public static Proc/*!*/ CreateNew(CallSiteStorage<Func<CallSite, Proc, Proc, object>>/*!*/ storage,
RubyClass/*!*/ self, Proc/*!*/ proc) {
Assert.NotNull(storage, self, proc);
// an instance of Proc class, the identity is preserved:
if (self.GetUnderlyingSystemType() == typeof(Proc)) {
return proc;
}
// an instance of a Proc subclass:
var result = new Proc.Subclass(self, proc);
var initialize = storage.GetCallSite("initialize", new RubyCallSignature(0, RubyCallFlags.HasImplicitSelf | RubyCallFlags.HasBlock));
// a call to the initializer with a block:
object initResult = null;
do {
// a new proc is created each iteration (even if a subclass is passed in, the Proc class is created):
var argProc = proc.Create(proc);
try {
initResult = initialize.Target(initialize, proc, argProc);
} catch (EvalUnwinder u) {
initResult = u.ReturnValue;
}
Debug.Assert(proc != argProc, "retry doesn't propagate to the caller");
} while (RubyOps.IsRetrySingleton(initResult));
return result;
}
示例2: CreateNew
public static Proc/*!*/ CreateNew(RubyClass/*!*/ self, Proc/*!*/ proc) {
Assert.NotNull(self, proc);
// an instance of Proc class, the identity is preserved:
if (self.GetUnderlyingSystemType() == typeof(Proc)) {
return proc;
}
// an instance of a Proc subclass:
var result = new Proc.Subclass(self, proc);
// a call to the initializer with a block:
object initResult = null;
do {
// a new proc is created each iteration (even if a subclass is passed in, the Proc class is created):
var argProc = proc.Create(proc);
try {
initResult = _InitializeSite.Target(_InitializeSite, self.Context, proc, argProc);
} catch (EvalUnwinder u) {
initResult = u.ReturnValue;
}
Debug.Assert(proc != argProc, "retry doesn't propagate to the caller");
} while (RubyOps.IsRetrySingleton(initResult));
return result;
}