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