public static InstallerPhase InspectRhinoAndWriteXml(string PathToRhino, string OutputDirectory) { Logger.Log(LogLevel.Debug, "InspectRhino\tBeginning inspection of '" + PathToRhino + "'"); // This should only be called from a separate process. if (string.IsNullOrEmpty(OutputDirectory)) { return(InstallerPhase.InspctWrkDirMissing); } RhinoInfo info = new RhinoInfo(); info.Inspect(PathToRhino); if (!info.IsValid()) { return(InstallerPhase.InspctFailed); } string xmlname = info.GetXmlFileName(); Directory.CreateDirectory(OutputDirectory); string path = Path.Combine(OutputDirectory, xmlname); info.WriteXml(path); return(InstallerPhase.Success); }
public bool IsCompatible(RhinoInfo rhino) { PluginInfo plugin = this; if (!rhino.IsValid()) { Logger.Log(LogLevel.Debug, "RhinoInfo::IsPluginCompatible called with invalid PluginInfo: " + plugin.m_plugin_path); return(false); } // Plug-in uses RhinoDotNet? if (!string.IsNullOrEmpty(plugin.DotNetSDKVersion)) { // Get last section of Rhino DotNet version number Match m = Regex.Match(rhino.RhinoDotNetVersion, @"\.(\d+)$"); string sRhinoRev = m.Groups[1].Value; int nRhinoRev = -1; if (!int.TryParse(sRhinoRev, out nRhinoRev)) { nRhinoRev = -1; } // Get last section of Plug-in DotNet version number m = Regex.Match(plugin.DotNetSDKVersion, @"\.(\d+)$"); string sPluginRev = m.Groups[1].Value; int nPluginRev = -1; if (!int.TryParse(sPluginRev, out nPluginRev)) { nPluginRev = -1; } if (nRhinoRev < 0 || nPluginRev < 0) { Logger.Log(LogLevel.Debug, "RhinoDotNet version incompatibility: Rhino: " + rhino.RhinoDotNetVersion + ", Plug-in: " + plugin.DotNetSDKVersion); return(false); } if (nRhinoRev < 100) { // Rhino is 4.0 if (nPluginRev < 100) { // Plug-in is 4.0; go ahead and install } else { // Plug-in is newer than 4.0; do not install. Logger.Log(LogLevel.Debug, "RhinoDotNet version incompatibility: Rhino: " + rhino.RhinoDotNetVersion + ", Plug-in: " + plugin.DotNetSDKVersion); return(false); } } else { // Rhino is 5.0 } // Plug-in is dotNet, but Rhino has older version of dotNet int cf = string.Compare(rhino.RhinoDotNetVersion, plugin.DotNetSDKVersion, StringComparison.OrdinalIgnoreCase); if (cf < 0) { Logger.Log(LogLevel.Debug, "RhinoDotNet version incompatibility: Rhino: " + rhino.RhinoDotNetVersion + ", Plug-in: " + plugin.DotNetSDKVersion); return(false); } } // Plug-in uses RhinoCommon? if (!string.IsNullOrEmpty(plugin.RhinoCommonSDKVersion)) { // Plug-in uses RhinoCommon, but Rhino doesn't have it if (string.IsNullOrEmpty(rhino.RhinoCommonVersion)) { Logger.Log(LogLevel.Debug, "RhinoCommon version incompatibility: Rhino: not found, Plug-in: " + plugin.RhinoCommonSDKVersion); return(false); } // Plug-in uses RhinoCommon, but Rhino has older version of RhinoCommon int cf = string.Compare(rhino.RhinoCommonVersion, plugin.RhinoCommonSDKVersion, StringComparison.OrdinalIgnoreCase); if (cf < 0) { Logger.Log(LogLevel.Debug, "RhinoCommon version incompatibility: Rhino: " + rhino.RhinoCommonVersion + ", Plug-in: " + plugin.RhinoCommonSDKVersion); return(false); } } // Plug-in uses C++? if (!string.IsNullOrEmpty(plugin.RhinoSDKVersion)) { if (rhino.RhinoSdkVersion.EndsWith("0", StringComparison.OrdinalIgnoreCase)) { // Rhino is 4.0 if (plugin.RhinoSDKVersion.EndsWith("0", StringComparison.OrdinalIgnoreCase)) { // Do nothing. Plug-in is compatible. } else { Logger.Log(LogLevel.Debug, "RhinoSdkVersion incompatibility: Rhino: " + rhino.RhinoSdkVersion + ", Plug-in: " + plugin.RhinoSDKVersion); return(false); // Plug-in is not compatible } } else if (rhino.RhinoSdkVersion.EndsWith("5", StringComparison.OrdinalIgnoreCase)) { // Rhino is 5.0 if (plugin.RhinoSDKVersion.EndsWith("5", StringComparison.OrdinalIgnoreCase)) { // Plugin is 4.0 or 5.0 // do nothing; rhino is compatible } else { Logger.Log(LogLevel.Debug, "RhinoSdkVersion incompatibility: Rhino: " + rhino.RhinoSdkVersion + ", Plug-in: " + plugin.RhinoSDKVersion); return(false); } } else { Logger.Log(LogLevel.Debug, "RhinoSdkVersion incompatibility: Rhino: " + rhino.RhinoSdkVersion + ", Plug-in: " + plugin.RhinoSDKVersion); return(false); } } if (!string.IsNullOrEmpty(plugin.RhinoSDKServiceRelease)) { if (rhino.RhinoSdkServiceRelease.EndsWith("0", StringComparison.OrdinalIgnoreCase)) { // Rhino is 4.0 if (plugin.RhinoSDKServiceRelease.EndsWith("0", StringComparison.OrdinalIgnoreCase)) { // do nothing, rhino is compatible } else { Logger.Log(LogLevel.Debug, "RhinoSdkServiceRelease incompatibility: Rhino: " + rhino.RhinoSdkServiceRelease + ", Plug-in: " + plugin.RhinoSDKServiceRelease); return(false); } } else if (rhino.RhinoSdkServiceRelease.EndsWith("5", StringComparison.OrdinalIgnoreCase)) { if (plugin.RhinoSDKServiceRelease.EndsWith("0", StringComparison.OrdinalIgnoreCase) || plugin.RhinoSDKServiceRelease.EndsWith("5", StringComparison.OrdinalIgnoreCase)) { // do nothing, rhino is compatible } else { Logger.Log(LogLevel.Debug, "RhinoSdkServiceRelease incompatibility: Rhino: " + rhino.RhinoSdkServiceRelease + ", Plug-in: " + plugin.RhinoSDKServiceRelease); return(false); } } else { // unknown Rhino Logger.Log(LogLevel.Debug, "RhinoSdkServiceRelease incompatibility: Rhino: " + rhino.RhinoSdkServiceRelease + ", Plug-in: " + plugin.RhinoSDKServiceRelease); return(false); } } Logger.Log(LogLevel.Info, "Compatible Rhino found: " + rhino.RhinoExePath); return(true); }
public bool IsCompatible(RhinoInfo rhino) { PluginInfo plugin = this; if (!rhino.IsValid()) { Logger.Log(LogLevel.Debug, "RhinoInfo::IsPluginCompatible called with invalid PluginInfo: " + plugin.m_plugin_path); return false; } // Plug-in uses RhinoDotNet? if (!string.IsNullOrEmpty(plugin.DotNetSDKVersion)) { // Get last section of Rhino DotNet version number Match m = Regex.Match(rhino.RhinoDotNetVersion, @"\.(\d+)$"); string sRhinoRev = m.Groups[1].Value; int nRhinoRev = -1; if (!int.TryParse(sRhinoRev, out nRhinoRev)) nRhinoRev = -1; // Get last section of Plug-in DotNet version number m = Regex.Match(plugin.DotNetSDKVersion, @"\.(\d+)$"); string sPluginRev = m.Groups[1].Value; int nPluginRev = -1; if (!int.TryParse(sPluginRev, out nPluginRev)) nPluginRev = -1; if (nRhinoRev < 0 || nPluginRev < 0) { Logger.Log(LogLevel.Debug, "RhinoDotNet version incompatibility: Rhino: " + rhino.RhinoDotNetVersion + ", Plug-in: " + plugin.DotNetSDKVersion); return false; } if (nRhinoRev < 100) { // Rhino is 4.0 if (nPluginRev < 100) { // Plug-in is 4.0; go ahead and install } else { // Plug-in is newer than 4.0; do not install. Logger.Log(LogLevel.Debug, "RhinoDotNet version incompatibility: Rhino: " + rhino.RhinoDotNetVersion + ", Plug-in: " + plugin.DotNetSDKVersion); return false; } } else { // Rhino is 5.0 } // Plug-in is dotNet, but Rhino has older version of dotNet int cf = string.Compare(rhino.RhinoDotNetVersion, plugin.DotNetSDKVersion, StringComparison.OrdinalIgnoreCase); if (cf < 0) { Logger.Log(LogLevel.Debug, "RhinoDotNet version incompatibility: Rhino: " + rhino.RhinoDotNetVersion + ", Plug-in: " + plugin.DotNetSDKVersion); return false; } } // Plug-in uses RhinoCommon? if (!string.IsNullOrEmpty(plugin.RhinoCommonSDKVersion)) { // Plug-in uses RhinoCommon, but Rhino doesn't have it if (string.IsNullOrEmpty(rhino.RhinoCommonVersion)) { Logger.Log(LogLevel.Debug, "RhinoCommon version incompatibility: Rhino: not found, Plug-in: " + plugin.RhinoCommonSDKVersion); return false; } // Plug-in uses RhinoCommon, but Rhino has older version of RhinoCommon int cf = string.Compare(rhino.RhinoCommonVersion, plugin.RhinoCommonSDKVersion, StringComparison.OrdinalIgnoreCase); if (cf < 0) { Logger.Log(LogLevel.Debug, "RhinoCommon version incompatibility: Rhino: " + rhino.RhinoCommonVersion + ", Plug-in: " + plugin.RhinoCommonSDKVersion); return false; } } // Plug-in uses C++? if (!string.IsNullOrEmpty(plugin.RhinoSDKVersion)) { if (rhino.RhinoSdkVersion.EndsWith("0", StringComparison.OrdinalIgnoreCase)) { // Rhino is 4.0 if (plugin.RhinoSDKVersion.EndsWith("0", StringComparison.OrdinalIgnoreCase)) { // Do nothing. Plug-in is compatible. } else { Logger.Log(LogLevel.Debug, "RhinoSdkVersion incompatibility: Rhino: " + rhino.RhinoSdkVersion + ", Plug-in: " + plugin.RhinoSDKVersion); return false; // Plug-in is not compatible } } else if (rhino.RhinoSdkVersion.EndsWith("5", StringComparison.OrdinalIgnoreCase)) { // Rhino is 5.0 if (plugin.RhinoSDKVersion.EndsWith("5", StringComparison.OrdinalIgnoreCase)) { // Plugin is 4.0 or 5.0 // do nothing; rhino is compatible } else { Logger.Log(LogLevel.Debug, "RhinoSdkVersion incompatibility: Rhino: " + rhino.RhinoSdkVersion + ", Plug-in: " + plugin.RhinoSDKVersion); return false; } } else { Logger.Log(LogLevel.Debug, "RhinoSdkVersion incompatibility: Rhino: " + rhino.RhinoSdkVersion + ", Plug-in: " + plugin.RhinoSDKVersion); return false; } } if (!string.IsNullOrEmpty(plugin.RhinoSDKServiceRelease)) { if (rhino.RhinoSdkServiceRelease.EndsWith("0", StringComparison.OrdinalIgnoreCase)) { // Rhino is 4.0 if (plugin.RhinoSDKServiceRelease.EndsWith("0", StringComparison.OrdinalIgnoreCase)) { // do nothing, rhino is compatible } else { Logger.Log(LogLevel.Debug, "RhinoSdkServiceRelease incompatibility: Rhino: " + rhino.RhinoSdkServiceRelease + ", Plug-in: " + plugin.RhinoSDKServiceRelease); return false; } } else if (rhino.RhinoSdkServiceRelease.EndsWith("5", StringComparison.OrdinalIgnoreCase)) { if (plugin.RhinoSDKServiceRelease.EndsWith("0", StringComparison.OrdinalIgnoreCase) || plugin.RhinoSDKServiceRelease.EndsWith("5", StringComparison.OrdinalIgnoreCase)) { // do nothing, rhino is compatible } else { Logger.Log(LogLevel.Debug, "RhinoSdkServiceRelease incompatibility: Rhino: " + rhino.RhinoSdkServiceRelease + ", Plug-in: " + plugin.RhinoSDKServiceRelease); return false; } } else { // unknown Rhino Logger.Log(LogLevel.Debug, "RhinoSdkServiceRelease incompatibility: Rhino: " + rhino.RhinoSdkServiceRelease + ", Plug-in: " + plugin.RhinoSDKServiceRelease); return false; } } Logger.Log(LogLevel.Info, "Compatible Rhino found: " + rhino.RhinoExePath); return true; }
public static InstallerPhase InspectRhinoAndWriteXml(string PathToRhino, string OutputDirectory) { Logger.Log(LogLevel.Debug, "InspectRhino\tBeginning inspection of '" + PathToRhino + "'"); // This should only be called from a separate process. if (string.IsNullOrEmpty(OutputDirectory)) return InstallerPhase.InspctWrkDirMissing; RhinoInfo info = new RhinoInfo(); info.Inspect(PathToRhino); if (!info.IsValid()) return InstallerPhase.InspctFailed; string xmlname = info.GetXmlFileName(); Directory.CreateDirectory(OutputDirectory); string path = Path.Combine(OutputDirectory, xmlname); info.WriteXml(path); return InstallerPhase.Success; }