public static Version GetVersionPrefix(Assembly assembly) { var assemblyVersion = AssemblyHelpers.GetAssemblyInformationalVersion(assembly); var indexOfVersionSuffix = assemblyVersion.IndexOf('-'); var versionPrefix = indexOfVersionSuffix == -1 ? assemblyVersion : assemblyVersion.Substring(0, indexOfVersionSuffix); return(Version.Parse(versionPrefix)); }
public static Assembly GetEntryAssembly() { AssemblyHelpers.Logger.Verbose("Attempting to get entry assembly."); Assembly assembly = null; try { assembly = Assembly.GetEntryAssembly(); } catch (Exception ex) { AssemblyHelpers.Logger.Info("Could not get entry assembly by the default method. Exception: {0}", ex.ToString()); } #if !NETSTANDARD1_5 if (assembly == null) { AssemblyHelpers.Logger.Verbose("Attempting to get entry assembly by main module."); try { assembly = AssemblyHelpers.GetEntryAssemblyByMainModule(); } catch (Exception ex) { AssemblyHelpers.Logger.Info("Could not get entry assembly by main module. Exception: {0}", ex.ToString()); } } if (assembly == null) { AssemblyHelpers.Logger.Verbose("Attempting to get entry assembly by stack trace."); try { assembly = AssemblyHelpers.GetEntryAssemblyByStacktrace(); } catch (Exception ex) { AssemblyHelpers.Logger.Info("Could not get entry assembly by stack trace. Exception: {0}", ex.ToString()); } } #endif if (assembly == null) { AssemblyHelpers.Logger.Warning("Could not get entry assembly."); } return(assembly); }
public static string GetAssemblyTitle(Type type) { return(AssemblyHelpers.GetAssembly(type).GetCustomAttribute <AssemblyTitleAttribute>().Title); }
public static string GetAssemblyInformationalVersion(Type type) { return(AssemblyHelpers.GetAssemblyInformationalVersion(AssemblyHelpers.GetAssembly(type))); }
public static Version GetVersionPrefix(Type type) { return(AssemblyHelpers.GetVersionPrefix(AssemblyHelpers.GetAssembly(type))); }