本文整理汇总了C#中IronRuby.Builtins.Proc类的典型用法代码示例。如果您正苦于以下问题:C# Proc类的具体用法?C# Proc怎么用?C# Proc使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Proc类属于IronRuby.Builtins命名空间,在下文中一共展示了Proc类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: RubyLambdaMethodInfo
internal RubyLambdaMethodInfo(Proc/*!*/ block, string/*!*/ definitionName, RubyMemberFlags flags, RubyModule/*!*/ declaringModule)
: base(flags, declaringModule) {
Assert.NotNull(block, definitionName, declaringModule);
_lambda = block.ToLambda(this);
_definitionName = definitionName;
_id = Interlocked.Increment(ref _Id);
}
开发者ID:Jaykul,项目名称:IronLangs,代码行数:7,代码来源:RubyLambdaMethodInfo.cs
示例2: RubyImportDefinition
public RubyImportDefinition(string contractName, Proc mutator)
: base(contractName, null, null, ImportCardinality.ZeroOrOne, false, true, System.ComponentModel.Composition.CreationPolicy.Any)
{
if (mutator == null)
throw new ArgumentNullException("mutator");
_mutator = mutator;
}
开发者ID:JogoShugh,项目名称:IronRubyMef,代码行数:7,代码来源:RubyImportDefinition.cs
示例3: Subclass
// called by Proc#new rule when creating a Ruby subclass of Proc:
public Subclass(RubyClass/*!*/ rubyClass, Proc/*!*/ proc)
: base(proc)
{
Assert.NotNull(rubyClass);
Debug.Assert(!rubyClass.IsSingletonClass);
ImmediateClass = rubyClass;
}
开发者ID:TerabyteX,项目名称:main,代码行数:8,代码来源:Proc.Subclass.cs
示例4: MethodRetry
public static object MethodRetry(RubyScope/*!*/ scope, Proc proc) {
if (proc != null) {
return RetrySingleton;
} else {
throw new LocalJumpError("retry used out of rescue", scope.FlowControlScope);
}
}
开发者ID:andreakn,项目名称:ironruby,代码行数:7,代码来源:RubyOps.FlowControl.cs
示例5: OverloadResolution_Block1
public void OverloadResolution_Block1() {
var scope = Context.EmptyScope;
var proc = new Proc(ProcKind.Proc, null, scope, new BlockDispatcher0(BlockSignatureAttributes.None, null, 0).
SetMethod(new BlockCallTarget0((x, y) => null)));
var arguments = new[] {
// 1.times
new CallArguments(Context, MO(scope), new[] { MO(1) }, RubyCallSignature.WithScope(0)),
// 1.times &nil
new CallArguments(Context, MO(scope), new[] { MO(1), MO(null) }, RubyCallSignature.WithScopeAndBlock(0)),
// 1.times &p
new CallArguments(Context, MO(1), new[] { MO(proc) }, RubyCallSignature.WithBlock(0)),
// obj.times &p
new CallArguments(Context, MO("foo"), new[] { MO(proc) }, RubyCallSignature.WithBlock(0)),
};
var results = new[] {
"Times2",
"Times1",
"Times3",
"Times4",
};
var metaBuilder = new MetaObjectBuilder(null);
for (int i = 0; i < arguments.Length; i++) {
RubyOverloadResolver resolver;
var bindingTarget = RubyMethodGroupInfo.ResolveOverload(
metaBuilder, arguments[i], "times", GetStaticMethods(typeof(OverloadsWithBlock), "Times*"), SelfCallConvention.SelfIsParameter,
false, out resolver
);
Assert(bindingTarget.Success);
Assert(bindingTarget.Method.Name == results[i]);
}
}
开发者ID:techarch,项目名称:ironruby,代码行数:35,代码来源:OverloadResolutionTests.cs
示例6: Each
private static object Each(RubyContext/*!*/ context, object self, Proc/*!*/ block) {
if (self is Enumerator) {
return ((Enumerator)self).Each(context, block);
} else {
return RubySites.Each(context, self, block);
}
}
开发者ID:mscottford,项目名称:ironruby,代码行数:7,代码来源:Enumerable.cs
示例7: MethodRetry
public static object MethodRetry(RuntimeFlowControl/*!*/ rfc, Proc proc) {
if (proc != null) {
return RetrySingleton;
} else {
throw new LocalJumpError("retry used out of rescue", rfc);
}
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:7,代码来源:RuntimeFlowControl.cs
示例8: Each
private static object Each(CallSiteStorage<EachSite>/*!*/ each, RubyContext/*!*/ context, object self, Proc/*!*/ block) {
var enumerator = self as Enumerator;
if (enumerator != null) {
return enumerator.Each(context, block);
} else {
var site = each.GetCallSite("each", RubyCallSignature.WithBlock(0));
return site.Target(site, context, self, block);
}
}
开发者ID:joshholmes,项目名称:ironruby,代码行数:9,代码来源:Enumerable.cs
示例9: RubyPart
public RubyPart(RubyPartDefinition definition, Proc createInstance)
{
if (definition == null)
throw new ArgumentNullException("definition");
if (createInstance == null)
throw new ArgumentNullException("createInstance");
_definition = definition;
_instance = new DelayedInit<object>(() => createInstance.Call(createInstance));
}
开发者ID:JogoShugh,项目名称:IronRubyMef,代码行数:10,代码来源:RubyPart.cs
示例10: MethodRetry
public static object MethodRetry(RubyScope/*!*/ scope, Proc proc) {
if (proc != null) {
return BlockReturnResult.Retry;
} else {
// TODO: can this happen?
// If proc was null then the block argument passed to the call-with-block that returned RetrySingleton would be null and thus
// the call cannot yield to any block that retries.
throw new LocalJumpError("retry used out of rescue", scope.FlowControlScope);
}
}
开发者ID:BenHall,项目名称:ironruby,代码行数:10,代码来源:RubyOps.FlowControl.cs
示例11: CreateRfcForMethod
public static RuntimeFlowControl/*!*/ CreateRfcForMethod(Proc proc) {
RuntimeFlowControl result = new RuntimeFlowControl();
result.IsActiveMethod = true;
if (proc != null && proc.Kind == ProcKind.Block) {
proc.Kind = ProcKind.Proc;
proc.Converter = result;
}
return result;
}
开发者ID:Hank923,项目名称:ironruby,代码行数:11,代码来源:RuntimeFlowControl.cs
示例12: RubyPartDefinition
public RubyPartDefinition(string displayName, Proc createPart)
{
if (createPart == null)
throw new ArgumentNullException("createPart");
if (displayName == null)
throw new ArgumentNullException("displayName");
_createPart = createPart;
_displayName = displayName;
}
开发者ID:JogoShugh,项目名称:IronRubyMef,代码行数:11,代码来源:RubyPartDefinition.cs
示例13: Trap
public static object Trap(
RubyContext/*!*/ context,
object self,
object signalId,
Proc proc) {
if ((signalId is MutableString) && ((MutableString)signalId).ConvertToString() == "INT") {
context.InterruptSignalHandler = delegate() { proc.Call(); };
} else {
// TODO: For now, just ignore unknown signals. This should be changed to throw an
// exception. We are not doing it yet as it is close to the V1 RTM, and throwing
// an exception might cause some app to misbehave whereas it might have happenned
// to work if no exception is thrown
}
return null;
}
开发者ID:rudimk,项目名称:dlr-dotnet,代码行数:16,代码来源:Signal.cs
示例14: ToS
public static MutableString/*!*/ ToS(Proc/*!*/ self) {
var context = self.LocalScope.RubyContext;
var str = RubyUtils.ObjectToMutableStringPrefix(context, self);
str.Append('@');
str.Append(self.SourcePath ?? "(unknown)");
str.Append(':');
str.Append(self.SourceLine.ToString());
if (context.RubyOptions.Compatibility >= RubyCompatibility.Ruby19 && self.Kind == ProcKind.Lambda) {
str.Append(" (lambda)");
}
str.Append('>');
return str;
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:17,代码来源:ProcOps.cs
示例15: OverloadResolution_Block
public void OverloadResolution_Block() {
var t = GetType();
var gse = new RubyGlobalScope(Context, new Scope(), new object(), true);
var scope = new RubyTopLevelScope(gse, null, new SymbolDictionary());
var proc = new Proc(ProcKind.Proc, null, scope, new BlockDispatcher0((x, y) => null, BlockSignatureAttributes.None));
var scopeArg = new DynamicMetaObject(Ast.Constant(proc.LocalScope), BindingRestrictions.Empty, proc.LocalScope);
var contextArg = new DynamicMetaObject(Ast.Constant(Context), BindingRestrictions.Empty, Context);
var instanceInt = new DynamicMetaObject(Ast.Constant(1), BindingRestrictions.Empty, 1);
var str = "foo";
var instanceStr = new DynamicMetaObject(Ast.Constant(str), BindingRestrictions.Empty, str);
var procArg = new DynamicMetaObject(Ast.Constant(proc), BindingRestrictions.Empty, proc);
var nullArg = new DynamicMetaObject(Ast.Constant(Ast.Constant(null)), BindingRestrictions.Empty, null);
var arguments = new[] {
// 1.times
new CallArguments(scopeArg, instanceInt, new DynamicMetaObject[0], RubyCallSignature.WithScope(0)),
// 1.times &nil
new CallArguments(scopeArg, instanceInt, new[] { nullArg }, RubyCallSignature.WithScopeAndBlock(0)),
// 1.times &p
new CallArguments(contextArg, instanceInt, new[] { procArg }, RubyCallSignature.WithBlock(0)),
// obj.times &p
new CallArguments(contextArg, instanceStr, new[] { procArg }, RubyCallSignature.WithBlock(0)),
};
var results = new[] {
"Times2",
"Times1",
"Times3",
"Times4",
};
for (int i = 0; i < arguments.Length; i++) {
var bindingTarget = RubyMethodGroupInfo.ResolveOverload("times", new[] {
t.GetMethod("Times1"),
t.GetMethod("Times2"),
t.GetMethod("Times3"),
t.GetMethod("Times4"),
}, arguments[i], true, false);
Assert(bindingTarget.Success);
Assert(bindingTarget.Method.Name == results[i]);
}
}
开发者ID:joshholmes,项目名称:ironruby,代码行数:45,代码来源:OverloadResolutionTests.cs
示例16: ToLambdaMethodInfo
public static RubyLambdaMethodInfo/*!*/ ToLambdaMethodInfo(Proc/*!*/ block, string/*!*/ definitionName, RubyMethodVisibility visibility,
RubyModule/*!*/ owner) {
return new RubyLambdaMethodInfo(block, definitionName, (RubyMemberFlags)visibility, owner);
}
开发者ID:kevinkeeney,项目名称:ironruby,代码行数:4,代码来源:Proc.cs
示例17: ToLambda
/// <summary>
/// Creates a lambda Proc that has the same target, context and self object as this block.
/// Doesn't preserve the class of the Proc.
/// </summary>
public Proc/*!*/ ToLambda(RubyLambdaMethodInfo method) {
Proc result = new Proc(this);
result.Kind = ProcKind.Lambda;
result._method = method;
return result;
}
开发者ID:kevinkeeney,项目名称:ironruby,代码行数:10,代码来源:Proc.cs
示例18: Create
/// <summary>
/// Creates a copy of the proc that has the same target, context and self object as this block.
/// </summary>
public Proc/*!*/ Create(Proc/*!*/ proc) {
return new Proc(proc);
}
开发者ID:kevinkeeney,项目名称:ironruby,代码行数:6,代码来源:Proc.cs
示例19: Proc
protected Proc(Proc/*!*/ proc)
: this(proc.Kind, proc.Self, proc.LocalScope, proc.Dispatcher) {
Converter = proc.Converter;
}
开发者ID:kevinkeeney,项目名称:ironruby,代码行数:4,代码来源:Proc.cs
示例20: Clone
public static Proc/*!*/ Clone(Proc/*!*/ self) {
return self.Copy();
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:3,代码来源:ProcOps.cs
注:本文中的IronRuby.Builtins.Proc类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论