本文整理汇总了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);
}