private static FileSystemPath ResolveAsAbsolutePath([NotNull] IT4PathWithMacros pathWithMacros) { var path = pathWithMacros.ResolvePath(); if (path.IsAbsolute) { return(path); } return(null); }
private FileSystemPath ResolveAsAssemblyFile([NotNull] IT4PathWithMacros pathWithMacros) { string name = pathWithMacros.ResolveString(); string nameWithoutExtension = TryRemoveBinaryExtension(name); if (nameWithoutExtension == null) { return(null); } string fileName = name.Substring(0, name.Length - 4); return(ResolveAssemblyNameOrFile(pathWithMacros.ProjectFile, fileName)); }
private bool TryAddReference(IT4PathWithMacros pathWithMacros) { var path = AssemblyReferenceResolver.Resolve(pathWithMacros); if (path == null) { return(false); } if (MyAssemblyReferences.ContainsKey(path)) { return(false); } if (MyProjectReferences.ContainsKey(path)) { return(false); } return(TryAddProjectReference(path) || TryAddAssemblyReference(path)); }
private bool TryRemoveReference(IT4PathWithMacros pathWithMacros) { var path = AssemblyReferenceResolver.Resolve(pathWithMacros); if (path == null) { return(false); } if (MyAssemblyReferences.TryGetValue(path, out var cookie)) { MyAssemblyReferences.Remove(path); cookie.Dispose(); return(true); } if (MyProjectReferences.ContainsKey(path)) { MyProjectReferences.Remove(path); return(true); } return(false); }
private FileSystemPath ResolveAsAssemblyName([NotNull] IT4PathWithMacros pathWithMacros) => ResolveAssemblyNameOrFile(pathWithMacros.ProjectFile, pathWithMacros.ResolveString());
private FileSystemPath ResolveAsLightReference([NotNull] IT4PathWithMacros pathWithMacros) => LightWeightResolver.TryResolve(pathWithMacros.ProjectFile, pathWithMacros.ResolveString());
public FileSystemPath Resolve([NotNull] IT4PathWithMacros pathWithMacros) => ResolveAsAbsolutePath(pathWithMacros) ?? ResolveAsLightReference(pathWithMacros) ?? ResolveAsAssemblyName(pathWithMacros) ?? ResolveAsAssemblyFile(pathWithMacros);