示例#1
0
        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));
        }
示例#2
0
        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);
        }
示例#3
0
 public static string GetAssemblyTitle(Type type)
 {
     return(AssemblyHelpers.GetAssembly(type).GetCustomAttribute <AssemblyTitleAttribute>().Title);
 }
示例#4
0
 public static string GetAssemblyInformationalVersion(Type type)
 {
     return(AssemblyHelpers.GetAssemblyInformationalVersion(AssemblyHelpers.GetAssembly(type)));
 }
示例#5
0
 public static Version GetVersionPrefix(Type type)
 {
     return(AssemblyHelpers.GetVersionPrefix(AssemblyHelpers.GetAssembly(type)));
 }