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


C# AtomicComposition.TryGetValue方法代码示例

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


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

示例1: SetValue_ToNull_ShouldBeAllowed

        public void SetValue_ToNull_ShouldBeAllowed()
        {
            var ct = new AtomicComposition();

            ct.SetValue(ct, null);

            object value = new object();

            Assert.IsTrue(ct.TryGetValue(ct, out value));
            Assert.IsNull(value);
        }
开发者ID:nlhepler,项目名称:mono,代码行数:11,代码来源:CompositionTransactionTests.cs

示例2: AfterComplete_AllMethodsShouldThrow

        public void AfterComplete_AllMethodsShouldThrow()
        {
            var ct = new AtomicComposition();

            ct.Complete();

            ExceptionAssert.Throws<InvalidOperationException>(() => ct.AddCompleteAction(() => ct = null));
            ExceptionAssert.Throws<InvalidOperationException>(() => ct.Complete());
            ExceptionAssert.Throws<InvalidOperationException>(() => ct.SetValue(ct, 10));
            object value;
            ExceptionAssert.Throws<InvalidOperationException>(() => ct.TryGetValue(ct, out value));
        }
开发者ID:nlhepler,项目名称:mono,代码行数:12,代码来源:CompositionTransactionTests.cs

示例3: Dispose_AllMethodsShouldThrow

        public void Dispose_AllMethodsShouldThrow()
        {
            var ct = new AtomicComposition();

            ct.Dispose();

            ExceptionAssert.ThrowsDisposed(ct, () => ct.AddCompleteAction(() => ct = null));
            ExceptionAssert.ThrowsDisposed(ct, () => ct.Complete());
            ExceptionAssert.ThrowsDisposed(ct, () => ct.SetValue(ct, 10));
            object value;
            ExceptionAssert.ThrowsDisposed(ct, () => ct.TryGetValue(ct, out value));
        }
开发者ID:nlhepler,项目名称:mono,代码行数:12,代码来源:CompositionTransactionTests.cs

示例4: SetValue_Reference_ShouldBeAllowed

        public void SetValue_Reference_ShouldBeAllowed()
        {
            var ct = new AtomicComposition();

            var sb = new StringBuilder();
            ct.SetValue(ct, sb);

            StringBuilder value;

            Assert.IsTrue(ct.TryGetValue(ct, out value));
            Assert.AreEqual(sb, value);
        }
开发者ID:nlhepler,项目名称:mono,代码行数:12,代码来源:CompositionTransactionTests.cs

示例5: SetValue_ValueType_ShouldBeAllowed

        public void SetValue_ValueType_ShouldBeAllowed()
        {
            var ct = new AtomicComposition();

            ct.SetValue(ct, 45);

            int value;

            Assert.IsTrue(ct.TryGetValue(ct, out value));
            Assert.AreEqual(45, value);
        }
开发者ID:nlhepler,项目名称:mono,代码行数:11,代码来源:CompositionTransactionTests.cs

示例6: SetQuery

 private void SetQuery(AtomicComposition context, object key, Func<int, Func<int, bool>, bool> query)
 {
     Func<int, bool> parentQuery;
     context.TryGetValue(key, out parentQuery);
     Func<int, bool> queryFunction = parameter => { return query(parameter, parentQuery); };
     context.SetValue(key, queryFunction);
 }
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:CompositionTransactionTests.cs

示例7: TestValue

 private void TestValue(AtomicComposition context, object key, string expectedValue)
 {
     string value;
     Assert.IsTrue(context.TryGetValue(key, out value));
     Assert.AreEqual(expectedValue, value);
 }
开发者ID:nlhepler,项目名称:mono,代码行数:6,代码来源:CompositionTransactionTests.cs

示例8: TestQuery

 private void TestQuery(AtomicComposition context, object key, int parameter, bool expectation)
 {
     Func<int, bool> query;
     if (context.TryGetValue(key, out query))
         Assert.AreEqual(expectation, query(parameter));
 }
开发者ID:nlhepler,项目名称:mono,代码行数:6,代码来源:CompositionTransactionTests.cs

示例9: NoComplete_ShouldNotCopyValuesToInner

        public void NoComplete_ShouldNotCopyValuesToInner()
        {
            var innerAtomicComposition = new AtomicComposition();

            object value;
            using (var ct = new AtomicComposition(innerAtomicComposition))
            {
                ct.SetValue(this, 21);

                Assert.IsFalse(innerAtomicComposition.TryGetValue(this, out value));

                // Do not call complete
            }

            // reverify after dispose
            Assert.IsFalse(innerAtomicComposition.TryGetValue(this, out value));
        }
开发者ID:nlhepler,项目名称:mono,代码行数:17,代码来源:CompositionTransactionTests.cs

示例10: TestNoValue

 private void TestNoValue(AtomicComposition context, object key)
 {
     string value;
     Assert.IsFalse(context.TryGetValue(key, out value));
 }
开发者ID:nlhepler,项目名称:mono,代码行数:5,代码来源:CompositionTransactionTests.cs

示例11: Complete_ShouldCopyValuesToInner

        public void Complete_ShouldCopyValuesToInner()
        {
            var innerAtomicComposition = new AtomicComposition();

            object value;
            using (var ct = new AtomicComposition(innerAtomicComposition))
            {
                ct.SetValue(this, 21);

                Assert.IsFalse(innerAtomicComposition.TryGetValue(this, out value));

                ct.Complete();

                Assert.IsTrue(innerAtomicComposition.TryGetValue(this, out value));
                Assert.AreEqual(21, value);
            }

            // reverify after dispose
            Assert.IsTrue(innerAtomicComposition.TryGetValue(this, out value));
            Assert.AreEqual(21, value);
        }
开发者ID:nlhepler,项目名称:mono,代码行数:21,代码来源:CompositionTransactionTests.cs

示例12: SetValue_ChangeOuterValuesWhileHaveInner_ShouldThrow

        public void SetValue_ChangeOuterValuesWhileHaveInner_ShouldThrow()
        {
            var ct = new AtomicComposition();

            var ct2 = new AtomicComposition(ct);

            var key = new object();
            ExceptionAssert.Throws<InvalidOperationException>(() => ct.SetValue(key, 1));

            object value;
            Assert.IsFalse(ct2.TryGetValue(key, out value));
            Assert.IsFalse(ct.TryGetValue(key, out value));

            // remove the inner atomicComposition so the outer one becomes unlocked.
            ct2.Dispose();

            ct.SetValue(key, 2);
            Assert.IsTrue(ct.TryGetValue(key, out value));
            Assert.AreEqual(2, value);
        }
开发者ID:nlhepler,项目名称:mono,代码行数:20,代码来源:CompositionTransactionTests.cs

示例13: SetValue_CauseResize_ShouldWorkFine

        public void SetValue_CauseResize_ShouldWorkFine()
        {
            var ct = new AtomicComposition();

            var keys = new List<object>();
            var values = new List<object>();


            for (int i = 0; i < 20; i++)
            {
                var key = new object();
                keys.Add(key);
                values.Add(i);
                ct.SetValue(key, i);
            }

            for (int i = 0; i < keys.Count; i++)
            {
                object value;
                Assert.IsTrue(ct.TryGetValue(keys[i], out value));
                Assert.AreEqual(i, value);
            }
        }
开发者ID:nlhepler,项目名称:mono,代码行数:23,代码来源:CompositionTransactionTests.cs

示例14: GetExportsCore

            protected override IEnumerable<Export> GetExportsCore(ImportDefinition importDefinition, AtomicComposition context)
            {
                IEnumerable<Export> contextExports;

                if (context == null || !context.TryGetValue(this, out contextExports))
                {
                    contextExports = this._exports;
                }

                List<Export> exports = new List<Export>();
                var func = importDefinition.Constraint.Compile();
                foreach (Export export in contextExports)
                {
                    if (func(export.Definition))
                    {
                        exports.Add(export);
                    }
                }
                return exports;
            }
开发者ID:JackFong,项目名称:FreeRadical,代码行数:20,代码来源:ExportProviderFactory.RecomposableExportProvider.cs

示例15: GetEngineContext

        private EngineContext GetEngineContext(AtomicComposition atomicComposition)
        {
            Assumes.NotNull(atomicComposition);

            EngineContext engineContext;
            if (!atomicComposition.TryGetValue(this, true, out engineContext))
            {
                EngineContext parentContext;
                atomicComposition.TryGetValue(this, false, out parentContext);
                engineContext = new EngineContext(this, parentContext);
                atomicComposition.SetValue(this, engineContext);
                atomicComposition.AddCompleteAction(engineContext.Complete);
            }
            return engineContext;
        }
开发者ID:GuySrinivasan,项目名称:mono,代码行数:15,代码来源:ImportEngine.cs


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