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


C# Behavior.Dispose方法代码示例

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


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

示例1: TestApply

 public void TestApply()
 {
     var pbf = new FirableEvent<Func<long, string>>();
     var bf = new Behavior<Func<long, string>>(b => "1 " + b, pbf);
     var pba = new FirableEvent<long>();
     var ba = new Behavior<long>(5L, pba);
     var results = new List<string>();
     var apply = Functor.Apply(bf, ba);
     var listener = apply.SubscribeWithInitialFire(results.Add);
     pbf.Fire(b => "12 " + b);
     pba.Fire(6L);
     listener.Dispose();
     apply.Dispose();
     bf.Dispose();
     ba.Dispose();
     AssertArraysEqual(Arrays<string>.AsList("1 5", "12 5", "12 6"), results);
 }
开发者ID:jerometerry,项目名称:potassium,代码行数:17,代码来源:BehaviorTester.cs

示例2: TestSnapshot

        public void TestSnapshot()
        {
            var publisher = new FirableEvent<int>();
            var behavior = new Behavior<int>(0, publisher);
            var evt = new FirableEvent<long>();
            var results = new List<string>();
            Func<long, int, string> snapshotFunction = (x, y) => string.Format("{0} {1}", x, y);
            var listener = evt.Snapshot(snapshotFunction, behavior).Subscribe(results.Add);

            evt.Fire(100L);
            publisher.Fire(2);
            evt.Fire(200L);
            publisher.Fire(9);
            publisher.Fire(1);
            evt.Fire(300L);
            listener.Dispose();
            behavior.Dispose();
            evt.Dispose();
            AssertArraysEqual(Arrays<string>.AsList("100 0", "200 2", "300 1"), results);
        }
开发者ID:jerometerry,项目名称:potassium,代码行数:20,代码来源:BehaviorTester.cs

示例3: TestMapBLateListen

 public void TestMapBLateListen()
 {
     var publisher = new FirableEvent<int>();
     var behavior = new Behavior<int>(6, publisher);
     var results = new List<string>();
     var map = behavior.Map(x => x.ToString(CultureInfo.InvariantCulture));
     publisher.Fire(2);
     var listener = map.SubscribeWithInitialFire(results.Add);
     publisher.Fire(8);
     listener.Dispose();
     map.Dispose();
     behavior.Dispose();
     AssertArraysEqual(Arrays<string>.AsList("2", "8"), results);
 }
开发者ID:jerometerry,项目名称:potassium,代码行数:14,代码来源:BehaviorTester.cs

示例4: TestMapB3

 public void TestMapB3()
 {
     var publisher = new FirableEvent<int>();
     var behavior = new Behavior<int>(1, publisher);
     var behavior1 = behavior.Map(x => x * 3);
     var results = new List<int>();
     var listener = behavior1.SubscribeWithInitialFire(results.Add);
     publisher.Fire(2);
     listener.Dispose();
     behavior.Dispose();
     AssertArraysEqual(Arrays<int>.AsList(3, 6), results);
 }
开发者ID:jerometerry,项目名称:potassium,代码行数:12,代码来源:BehaviorTester.cs

示例5: TestLiftGlitch

 public void TestLiftGlitch()
 {
     var publisher = new FirableEvent<int>();
     var behavior = new Behavior<int>(1, publisher);
     var mappedBehavior1 = behavior.Map(x => x * 3);
     var mappedBehavior2 = behavior.Map(x => x * 5);
     var results = new List<string>();
     var combinedBehavior = Functor.Lift((x, y) => x + " " + y, mappedBehavior1, mappedBehavior2);
     var listener = combinedBehavior.SubscribeWithInitialFire(results.Add);
     publisher.Fire(2);
     listener.Dispose();
     behavior.Dispose();
     AssertArraysEqual(Arrays<string>.AsList("3 5", "6 10"), results);
 }
开发者ID:jerometerry,项目名称:potassium,代码行数:14,代码来源:BehaviorTester.cs

示例6: TestLift

 public void TestLift()
 {
     var pub1 = new FirableEvent<int>();
     var behavior1 = new Behavior<int>(1, pub1);
     var pub2 = new FirableEvent<long>();
     var behavior2 = new Behavior<long>(5L, pub2);
     var results = new List<string>();
     var combinedBehavior = Functor.Lift((x, y) => x + " " + y, behavior1, behavior2);
     var listener = combinedBehavior.SubscribeWithInitialFire(results.Add);
     pub1.Fire(12);
     pub2.Fire(6L);
     listener.Dispose();
     behavior1.Dispose();
     behavior2.Dispose();
     AssertArraysEqual(Arrays<string>.AsList("1 5", "12 5", "12 6"), results);
 }
开发者ID:jerometerry,项目名称:potassium,代码行数:16,代码来源:BehaviorTester.cs


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