예제 #1
0
        public void Import(Stream stream, PlatformExportManifest manifest, Action <ExportImportProgressInfo> progressCallback)
        {
            if (manifest == null)
            {
                throw new ArgumentNullException("manifest");
            }

            var progressInfo = new ExportImportProgressInfo
            {
                Description = "Starting platform import..."
            };

            progressCallback(progressInfo);

            using (var package = Package.Open(stream, FileMode.Open))
                using (var guard = EventSupressor.SupressEvents())
                {
                    //Import selected platform entries
                    ImportPlatformEntriesInternal(package, manifest, progressCallback);
                    //Import selected modules
                    ImportModulesInternal(package, manifest, progressCallback);
                    //Reset cache
                    _cacheManager.Clear();
                }
        }
예제 #2
0
        public void NotInheritedSetAfterAsyncMethodStartsInAnotherAsyncMethod()
        {
            Assert.False(EventSupressor.EventsSuppressed,
                         "EventSupressor shouldn't be active in this thread before test.");

            var         taskCompletionSource = new TaskCompletionSource <object>();
            Func <Task> notInheritedAction   = async() =>
            {
                await taskCompletionSource.Task;
                Assert.False(EventSupressor.EventsSuppressed, "EventSupressor shouldn't be active in this thread.");
            };

            var checkTask = notInheritedAction();

            Task.Run(async() =>
            {
                using (var guard = EventSupressor.SupressEvents())
                {
                    Assert.True(EventSupressor.EventsSuppressed, "EventSupressor inherits value in another thread!");
                    taskCompletionSource.TrySetResult(null);
                    await checkTask;
                }
                Assert.False(EventSupressor.EventsSuppressed, "EventSupressor shouldn't be active in this thread after test.");
            }).Wait();

            Assert.False(EventSupressor.EventsSuppressed, "EventSupressor shouldn't be active in this thread after test.");
        }
예제 #3
0
        public void SuppressInCurrentThread()
        {
            Assert.False(EventSupressor.EventsSuppressed, "EventSupressor shouldn't be active in this thread before test.");

            using (var guard = EventSupressor.SupressEvents())
            {
                Assert.True(EventSupressor.EventsSuppressed, "EventSupressor should be active in this thread.");
            }

            Assert.False(EventSupressor.EventsSuppressed, "EventSupressor shouldn't be active in this thread after test.");
        }
예제 #4
0
        public void InheritedSuppressInAnotherThread()
        {
            Assert.False(EventSupressor.EventsSuppressed,
                         "EventSupressor shouldn't be active in this thread before test.");

            using (var guard = EventSupressor.SupressEvents())
            {
                Assert.True(EventSupressor.EventsSuppressed, "EventSupressor should be active in this thread.");
                Task.Run(() =>
                {
                    Assert.True(EventSupressor.EventsSuppressed, "EventSupressor inherits value in another thread!");
                }).Wait();
            }

            Assert.False(EventSupressor.EventsSuppressed, "EventSupressor shouldn't be active in this thread after test.");
        }