ResolvedImport Import(ProjectCollectionLinker importer) { var importElement = (ProjectImportElement)importer.Import <ProjectElement, MockProjectImportElementLinkRemoter>(this.ImportingElement); var projectElement = (ProjectRootElement)importer.Import <ProjectElement, MockProjectRootElementLinkRemoter>(this.ImportedProject); return(importer.LinkFactory.Create(importElement, projectElement, 0, this.SdkResult, this.IsImported)); }
public TestCollectionGroup(int remoteCount, int stdFilesCount) { this.RemoteCount = 2; this.Group = ProjectCollectionLinker.CreateGroup(); this.Local = this.Group.AddNew(); this.Remote = new ProjectCollectionLinker[this.RemoteCount]; for (int i = 0; i < this.RemoteCount; i++) { this.Remote[i] = this.Group.AddNew(); } this.ImmutableDisk = new TransientIO(); this.Disk = this.ImmutableDisk.GetSubFolder("Mutable"); List <string> stdFiles = new List <string>(); for (int i = 0; i < stdFilesCount; i++) { stdFiles.Add(this.ImmutableDisk.WriteProjectFile($"Proj{i}.proj", TestCollectionGroup.SampleProjectFile)); } this.StdProjectFiles = stdFiles; }
public static MockProjectElementLinkRemoter ExportElement(this ProjectCollectionLinker exporter, ProjectElement xml) { if (xml == null) { return(null); } var implType = xml.GetType(); if (knownTypes.TryGetValue(implType, out var factory)) { return(factory(exporter, xml)); } factory = NotImplemented; foreach (var t in canonicalTypes) { if (t.Checker(xml)) { factory = t.ExportFactory; break; } } lock (knownTypes) { var newKnown = new Dictionary <Type, ExporterFactory>(knownTypes); newKnown[implType] = factory; knownTypes = newKnown; } return(factory(exporter, xml)); }
public RemotedResolvedImport(ResolvedImport resolvedImport, ProjectCollectionLinker exporter) { this.ImportingElement = exporter.Export <ProjectElement, MockProjectImportElementLinkRemoter>(resolvedImport.ImportingElement); this.ImportedProject = exporter.Export <ProjectElement, MockProjectRootElementLinkRemoter>(resolvedImport.ImportedProject); this.IsImported = resolvedImport.IsImported; this.SdkResult = resolvedImport.SdkResult; }
private void Clear(ProjectCollectionLinker linker) { linker.Importing = false; HashSet <Project> toKeep = null; this.ImmutableProjects?.TryGetValue(linker, out toKeep); if (toKeep == null) { linker.Collection.UnloadAllProjects(); } else { var toUnload = new List <Project>(); foreach (var p in linker.Collection.LoadedProjects) { if (!toKeep.Contains(p)) { toUnload.Add(p); } } foreach (var p in toUnload) { linker.Collection.UnloadProject(p); linker.Collection.UnloadProject(p.Xml); } } }
public static IList <MockProjectElementLinkRemoter> ExportCollection <T>(this ProjectCollectionLinker exporter, IEnumerable <T> source) where T : ProjectElement { if (source == null) { return(null); } // Just copy ... List <MockProjectElementLinkRemoter> result = new List <MockProjectElementLinkRemoter>(); foreach (var s in source) { var sRemoter = exporter.ExportElement(s); result.Add(sRemoter); } return(result); }
public static IList <RMock> ExportCollection <T, RMock>(this ProjectCollectionLinker exporter, IEnumerable <T> source) where T : class where RMock : MockLinkRemoter <T>, new() { if (source == null) { return(null); } // Just copy ... List <RMock> result = new List <RMock>(); foreach (var s in source) { var sRemoter = exporter.Export <T, RMock>(s); result.Add(sRemoter); } return(result); }
public static IDictionary <key, RMock> ExportDictionary <key, T, RMock>(this ProjectCollectionLinker exporter, IDictionary <key, T> source) where T : class where RMock : MockLinkRemoter <T>, new() { if (source == null) { return(null); } // Just copy ... Dictionary <key, RMock> result = new Dictionary <key, RMock>(); foreach (var s in source) { var valueRemoter = exporter.Export <T, RMock>(s.Value); result.Add(s.Key, valueRemoter); } return(result); }
public static void VerifyProjectCollectionLinks(this ProjectCollectionLinker linker, string path, int expectedLocal, int expectedLinks) => VerifyProjectCollectionLinks(linker.Collection, path, expectedLocal, expectedLinks);
public override ProjectElement ImportImpl(ProjectCollectionLinker remote) { return(remote.Import <ProjectElement, MockProjectUsingTaskParameterElementLinkRemoter>(this)); }
public MyTestCollectionGroup() : base(2, 0) { this.Target = this.Remote[0]; this.Local.Importing = true; }
private static MockProjectElementLinkRemoter Export <RMock>(ProjectCollectionLinker exporter, ProjectElement xml) where RMock : MockProjectElementLinkRemoter, new() { return(exporter.Export <ProjectElement, RMock>(xml)); }
public override ProjectElement ImportImpl(ProjectCollectionLinker remote) { return(remote.Import <ProjectElement, MockProjectExtensionsElementLinkRemoter>(this)); }
private static MockProjectElementLinkRemoter NotImplemented(ProjectCollectionLinker exporter, ProjectElement xml) { throw new NotImplementedException(); }
public abstract ProjectElement ImportImpl(ProjectCollectionLinker remote);
public override void Initialize(object key, T source, object context) { base.Initialize(key, source, context); this.OwningCollection = (ProjectCollectionLinker)context; }
public override ProjectElement ImportImpl(ProjectCollectionLinker remote) { return(remote.Import <ProjectElement, MockProjectItemDefinitionGroupElementLinkRemoter>(this)); }
internal static RemotedResolvedImport Export(this ResolvedImport resolvedImport, ProjectCollectionLinker exporter) { return(new RemotedResolvedImport(resolvedImport, exporter)); }
// this is so we dont use ?. everywhere. // for null remoters the local object is always null public static ProjectElement Import(this MockProjectElementLinkRemoter remoter, ProjectCollectionLinker remote) { if (remoter == null) { return(null); } return(remoter.ImportImpl(remote)); }
internal static ResolvedImport Import(this RemotedResolvedImport remoted, ProjectCollectionLinker importer) { return(remoted.Import(importer)); }