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


C# AdhocWorkspace.OnProjectRemoved方法代码示例

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


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

示例1: TestP2PReference

        public void TestP2PReference()
        {
            var workspace = new AdhocWorkspace();

            var project1 = ProjectInfo.Create(ProjectId.CreateNewId(), VersionStamp.Default, "proj1", "proj1", LanguageNames.CSharp);
            var project2 = ProjectInfo.Create(ProjectId.CreateNewId(), VersionStamp.Default, "proj2", "proj2", LanguageNames.CSharp, projectReferences: SpecializedCollections.SingletonEnumerable(new ProjectReference(project1.Id)));
            var solutionInfo = SolutionInfo.Create(SolutionId.CreateNewId(), VersionStamp.Default, projects: new ProjectInfo[] { project1, project2 });

            var solution = workspace.AddSolution(solutionInfo);

            var instance = new object();
            var weak = new WeakReference(instance);

            var cacheService = new ProjectCacheService(workspace, int.MaxValue);
            using (var cache = cacheService.EnableCaching(project2.Id))
            {
                cacheService.CacheObjectIfCachingEnabledForKey(project1.Id, (object)null, instance);
                instance = null;
                solution = null;

                workspace.OnProjectRemoved(project1.Id);
                workspace.OnProjectRemoved(project2.Id);
            }

            // make sure p2p reference doesnt go to implicit cache
            CollectGarbage();
            Assert.False(weak.IsAlive);

        }
开发者ID:GloryChou,项目名称:roslyn,代码行数:29,代码来源:ProjectCacheHostServiceFactoryTests.cs


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