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


C# Closure类代码示例

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


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

示例1: Add

		static public Handle Add (uint t, GLib.TimeoutHandler timeout_handler)
		{
			Closure c;
			c = new Closure (timeout_handler);
			c.Id = GLib.Timeout.Add (t, new GLib.TimeoutHandler (c.Handler));
			return c;
		}
开发者ID:ArsenShnurkov,项目名称:beagle-1,代码行数:7,代码来源:Action.cs

示例2: IfClosure

 /**
  * Constructor that performs no validation.
  * Use <code>getInstance</code> if you want that.
  *
  * @param predicate  predicate to switch on, not null
  * @param trueClosure  closure used if true, not null
  * @param falseClosure  closure used if false, not null
  */
 public IfClosure(Predicate predicate, Closure trueClosure, Closure falseClosure)
     : base()
 {
     iPredicate = predicate;
     iTrueClosure = trueClosure;
     iFalseClosure = falseClosure;
 }
开发者ID:gadfly,项目名称:nofs,代码行数:15,代码来源:org.apache.commons.collections.functors.IfClosure.cs

示例3: SwitchClosure

 /**
  * Constructor that performs no validation.
  * Use <code>getInstance</code> if you want that.
  *
  * @param predicates  array of predicates, not cloned, no nulls
  * @param closures  matching array of closures, not cloned, no nulls
  * @param defaultClosure  the closure to use if no match, null means nop
  */
 public SwitchClosure(Predicate[] predicates, Closure[] closures, Closure defaultClosure)
     : base()
 {
     iPredicates = predicates;
     iClosures = closures;
     iDefault = (defaultClosure == null ? NOPClosure.INSTANCE : defaultClosure);
 }
开发者ID:gadfly,项目名称:nofs,代码行数:15,代码来源:org.apache.commons.collections.functors.SwitchClosure.cs

示例4: LuaFFreeClosure

 // we have a gc, so nothing to do
 public static void LuaFFreeClosure(LuaState L, Closure c)
 {
     int size = (c.c.isC != 0) ? SizeCclosure(c.c.nupvalues) :
                             SizeLclosure(c.l.nupvalues);
     //luaM_freemem(L, c, size);
     SubtractTotalBytes(L, size);
 }
开发者ID:arkanoid1,项目名称:FakePacketSender,代码行数:8,代码来源:lfunc.cs

示例5: WhileClosure

 /**
  * Constructor that performs no validation.
  * Use <code>getInstance</code> if you want that.
  *
  * @param predicate  the predicate used to evaluate when the loop terminates, not null
  * @param closure  the closure the execute, not null
  * @param doLoop  true to act as a do-while loop, always executing the closure once
  */
 public WhileClosure(Predicate predicate, Closure closure, bool doLoop)
     : base()
 {
     iPredicate = predicate;
     iClosure = closure;
     iDoLoop = doLoop;
 }
开发者ID:gadfly,项目名称:nofs,代码行数:15,代码来源:org.apache.commons.collections.functors.WhileClosure.cs

示例6: StronglyTypedAstBuilder

 public StronglyTypedAstBuilder(Closure externalClosure)
 {
     foreach (var pair in externalClosure)
     {
         _closure.Add(pair.Key, pair.Value);
     }
 }
开发者ID:xeno-by,项目名称:relinq,代码行数:7,代码来源:StronglyTypedAstBuilder.cs

示例7: Generate

 public void Generate()
 {
     indensionStack.Clear();
     indensionStack.Push(-1);
     if (app == null) app = new Application();
     thisPresentation = app.Presentations.Add(MsoTriState.msoFalse);
     var cl = new DocumentClosure(null, thisPresentation, app);
     CurrentClosure = cl;
     ChangeTheme();
     cl.Initialize();
     cl.WorkPath = DefaultWorkPath;
     var module = thisPresentation.VBProject.VBComponents.Add(vbext_ComponentType.vbext_ct_StdModule);
     module.CodeModule.AddFromString(Resources.VBAModule);
     while (true)
     {
         var thisLine = ScriptReader.ReadLine();
         if (thisLine == null) break;
         Console.WriteLine(thisLine);
         if (!string.IsNullOrWhiteSpace(thisLine) && thisLine.TrimStart()[0] != '#')
             ParseLine(thisLine);
     }
     while (CurrentClosure != null) ExitClosure();
     app.Run("PAG_PostProcess", thisPresentation);
     var wnd = thisPresentation.NewWindow();
     thisPresentation.VBProject.VBComponents.Remove(module);
     wnd.Activate();
     //thisPresentation.Close();
 }
开发者ID:CXuesong,项目名称:PptAlbumGenerator,代码行数:28,代码来源:AlbumGenerator.cs

示例8: luaF_freeclosure

 // we have a gc, so nothing to do
 public static void luaF_freeclosure(lua_State L, Closure c)
 {
     int size = (c.c.isC != 0) ? sizeCclosure(c.c.nupvalues) :
                           sizeLclosure(c.l.nupvalues);
       //luaM_freemem(L, c, size);
       SubtractTotalBytes(L, size);
 }
开发者ID:raymanyu,项目名称:kopilua,代码行数:8,代码来源:lfunc.cs

示例9: ShouldBeAbleToNestClosures

        public void ShouldBeAbleToNestClosures()
        {
            MathOperation add = delegate(int a, int b) { return a + b; };
            Closure doMath = new Closure(add, new Closure(add, new Closure(add, 1, 1), 1), 1);

            int result = (int) doMath.Invoke();
            Assert.IsTrue(result == 4);
        }
开发者ID:jonfuller,项目名称:LinFu.DynamicObject,代码行数:8,代码来源:ClosureTests.cs

示例10: CallLuaClosure

 protected IEnumerator CallLuaClosure(LuaEnvironment luaEnv, Closure callback)
 {
     yield return new WaitForEndOfFrame();
     if (callback != null)
     {
         luaEnv.RunLuaFunction(callback, true);
     }
 }
开发者ID:abstractmachine,项目名称:Fungus-3D-Template,代码行数:8,代码来源:MenuDialog.cs

示例11: getInstance

 /**
  * Factory method that performs validation.
  *
  * @param closure  the closure to call, not null
  * @return the <code>closure</code> transformer
  * @throws IllegalArgumentException if the closure is null
  */
 public static Transformer getInstance(Closure closure)
 {
     if (closure == null)
     {
         throw new java.lang.IllegalArgumentException("Closure must not be null");
     }
     return new ClosureTransformer(closure);
 }
开发者ID:gadfly,项目名称:nofs,代码行数:15,代码来源:org.apache.commons.collections.functors.ClosureTransformer.cs

示例12: copy

 /**
  * Clone the closures to ensure that the internal reference can't be messed with.
  *
  * @param closures  the closures to copy
  * @return the cloned closures
  */
 internal static Closure[] copy(Closure[] closures)
 {
     if (closures == null)
     {
         return null;
     }
     return (Closure[])closures.clone();
 }
开发者ID:gadfly,项目名称:nofs,代码行数:14,代码来源:org.apache.commons.collections.functors.FunctorUtils.cs

示例13: getInstance

 /**
  * Factory method that performs validation and copies the parameter array.
  *
  * @param closures  the closures to chain, copied, no nulls
  * @return the <code>chained</code> closure
  * @throws IllegalArgumentException if the closures array is null
  * @throws IllegalArgumentException if any closure in the array is null
  */
 public static Closure getInstance(Closure[] closures)
 {
     FunctorUtils.validate(closures);
     if (closures.Length == 0)
     {
         return NOPClosure.INSTANCE;
     }
     closures = FunctorUtils.copy(closures);
     return new ChainedClosure(closures);
 }
开发者ID:gadfly,项目名称:nofs,代码行数:18,代码来源:org.apache.commons.collections.functors.ChainedClosure.cs

示例14: Coroutine_Create

		public DynValue Coroutine_Create(Closure closure)
		{
			// create a processor instance
			Processor P = new Processor(this);

			// Put the closure as first value on the stack, for future reference
			P.m_ValueStack.Push(DynValue.NewClosure(closure));

			// Return the coroutine handle
			return DynValue.NewCoroutine(new Coroutine(P));
		}
开发者ID:cyecp,项目名称:moonsharp,代码行数:11,代码来源:Processor_Coroutines.cs

示例15: CurriedClosureShouldBeAbleToBindToAStronglyTypedDelegate

        public void CurriedClosureShouldBeAbleToBindToAStronglyTypedDelegate()
        {
            MathOperation add = delegate(int a, int b) { return a + b; };
            Closure doMath = new Closure(add, Args.Lambda, 1);
            SingleOperatorMathOperation mathOp = doMath.AdaptTo<SingleOperatorMathOperation>();

            // return 5 + 1
            int result = mathOp(5);
            // The result should be 6
            Assert.AreEqual(6, result);
        }
开发者ID:jonfuller,项目名称:LinFu.DynamicObject,代码行数:11,代码来源:ClosureTests.cs


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