當前位置: 首頁>>代碼示例>>C#>>正文


C# AtomicComposition.SetValue方法代碼示例

本文整理匯總了C#中AtomicComposition.SetValue方法的典型用法代碼示例。如果您正苦於以下問題:C# AtomicComposition.SetValue方法的具體用法?C# AtomicComposition.SetValue怎麽用?C# AtomicComposition.SetValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在AtomicComposition的用法示例。


在下文中一共展示了AtomicComposition.SetValue方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: ChangeExports

            private void ChangeExports(List<Export> newExports)
            {
                using (var atomicComposition = new AtomicComposition())
                {
                    atomicComposition.AddCompleteAction(() => this._exports = newExports);
                    atomicComposition.SetValue(this, newExports);

                    var addedExports = newExports.Except(this._exports).Select(export => export.Definition);
                    var removedExports = this._exports.Except(newExports).Select(export => export.Definition);

                    this.OnExportsChanging(new ExportsChangeEventArgs(addedExports, removedExports, atomicComposition));

                    atomicComposition.AddCompleteAction(() => this.OnExportsChanged(
                        new ExportsChangeEventArgs(addedExports, removedExports, null)));

                    atomicComposition.Complete();
                }
            }
開發者ID:JackFong,項目名稱:FreeRadical,代碼行數:18,代碼來源:ExportProviderFactory.RecomposableExportProvider.cs

示例5: 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

示例6: 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

示例7: 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

示例8: AtomicComposition_CompleteValues

        public void AtomicComposition_CompleteValues()
        {
            object key1 = new Object();
            object key2 = new Object();

            using (var contextA = new AtomicComposition())
            {
                TestNoValue(contextA, key1);
                TestNoValue(contextA, key2);
                contextA.SetValue(key1, "Hello");
                TestValue(contextA, key1, "Hello");
                TestNoValue(contextA, key2);

                // Try overwriting
                using (var contextB = new AtomicComposition(contextA))
                {
                    TestValue(contextB, key1, "Hello");
                    TestNoValue(contextB, key2);
                    contextB.SetValue(key1, "Greetings");
                    TestValue(contextB, key1, "Greetings");
                    TestNoValue(contextB, key2);

                    contextB.Complete();
                }
                TestValue(contextA, key1, "Greetings");
                TestNoValue(contextA, key2);

                // Try overwrite with revert
                using (var contextC = new AtomicComposition(contextA))
                {
                    TestValue(contextC, key1, "Greetings");
                    TestNoValue(contextC, key2);
                    contextC.SetValue(key1, "Goodbye");
                    contextC.SetValue(key2, "Goodbye, Again");
                    TestValue(contextC, key1, "Goodbye");
                    TestValue(contextC, key2, "Goodbye, Again");

                    // Don't complete
                }
                TestValue(contextA, key1, "Greetings");
                TestNoValue(contextA, key2);

                contextA.Complete();
            }
        }
開發者ID:nlhepler,項目名稱:mono,代碼行數:45,代碼來源: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: 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

示例11: 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

示例12: 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

示例13: 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.SetValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。