private string GetFileName(NPanday.Model.Pom.Dependency dependency) { RegistryKey root = Registry.ClassesRoot; string filename = string.Empty; try { String[] classTokens = dependency.classifier.Split("}".ToCharArray()); String[] versionTokens = classTokens[1].Split("-".ToCharArray()); classTokens[1] = classTokens[1].Replace("-", "\\"); String newClassifier = classTokens[0] + "}" + classTokens[1]; RegistryKey typeLib = root.OpenSubKey("TypeLib"); RegistryKey target = typeLib.OpenSubKey(classTokens[0] + "}").OpenSubKey(versionTokens[1]).OpenSubKey(versionTokens[2]).OpenSubKey("win32"); filename = target.GetValue("").ToString(); } catch (Exception exe) { Console.WriteLine(exe.Message); } return(filename); }
public void AddPomDependency(string groupId, string artifactId, string version, string type, string scope, string systemPath) { NPanday.Model.Pom.Dependency dependency = new NPanday.Model.Pom.Dependency(); ; dependency.artifactId = artifactId; dependency.groupId = groupId; dependency.version = version; dependency.type = type; dependency.scope = scope; if (!string.IsNullOrEmpty(systemPath)) { dependency.systemPath = new FileInfo(systemPath).FullName; } AddPomDependency(dependency); }
private void LocalInstall(NPanday.Model.Pom.Dependency dependency, string fileName) { try { String[] rawName = GetFileName(dependency).Split("\\".ToCharArray()); string generatedDLL = rawName[rawName.Length - 1]; generatedDLL = generatedDLL.Replace("tlb", "dll"); string directory = localRepository.Replace("\\", "/"); //Creating of Directories directory = directory + "/" + dependency.groupId; if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } directory = directory + "/" + dependency.artifactId; if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } directory = directory + "/" + dependency.version; if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } string newDll = dependency.artifactId + "-" + dependency.version + "-" + dependency.classifier + "." + dependency.type; string destinationFile = localRepository + "\\" + dependency.groupId + "\\" + dependency.artifactId + "\\" + dependency.version + "\\" + newDll; destinationFile = destinationFile.Replace("\\", "/"); string tempDir = "c:/Windows/Temp/NPanday"; if (!Directory.Exists(tempDir)) { Directory.CreateDirectory(tempDir); } fileName = "\"" + fileName + "\""; fileName = fileName + " /out:" + tempDir + "/" + dependency.artifactId + ".dll"; GenerateDependency(fileName); string sourceFile = tempDir + "/" + dependency.artifactId + ".dll"; bool waiting = true; while (waiting) { if (File.Exists(sourceFile)) { waiting = false; } } if (!File.Exists(destinationFile)) { System.Threading.Thread.Sleep(4500); File.Copy(sourceFile, destinationFile); } } catch (Exception exe) { Console.WriteLine("[ERROR] The Reference is not located.\n" + exe.Message); } }
public void SystemInstall(NPanday.Model.Pom.Dependency dependency) { try { if (dependency.systemPath == null || dependency.systemPath == string.Empty) { Assembly a = System.Reflection.Assembly.LoadWithPartialName(dependency.artifactId); dependency.systemPath = a.Location; } string sourceFile = dependency.systemPath; sourceFile = sourceFile.Replace("\\", "/"); string directory = localRepository.Replace("\\", "/"); //Creating of Directories directory = directory + "/" + dependency.groupId; if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } directory = directory + "/" + dependency.artifactId; if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } directory = directory + "/" + dependency.version; if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } string newDll = dependency.artifactId + "-" + dependency.version + "-" + dependency.classifier + "." + dependency.type; string destinationFile = localRepository + "\\" + dependency.groupId + "\\" + dependency.artifactId + "\\" + dependency.version + "\\" + newDll; destinationFile = destinationFile.Replace("\\", "/"); if (!File.Exists(destinationFile)) { File.Copy(sourceFile, destinationFile); } } catch (Exception exe) { Console.WriteLine(exe.Message); } }