public static Module ToModuleInfo(this Assembly assembly) { if (assembly == null) { return(null); } return(_moduleCache.GetOrAdd(assembly.FullName, k => { var mod = new Module(); var name = assembly.GetAssemblyName(); string infoVersion = assembly.GetInformationalVersion(); string fileVersion = assembly.GetFileVersion(); if (name != null) { mod.Name = name.Name; mod.Version = infoVersion ?? fileVersion ?? name.Version.ToString(); byte[] pkt = name.GetPublicKeyToken(); if (pkt.Length > 0) { mod.Data["PublicKeyToken"] = pkt.ToHex(); } var version = name.Version.ToString(); if (!String.IsNullOrEmpty(version) && version != mod.Version) { mod.Data["Version"] = name.Version.ToString(); } } if (!String.IsNullOrEmpty(infoVersion) && infoVersion != mod.Version) { mod.Data["ProductVersion"] = infoVersion; } if (!String.IsNullOrEmpty(fileVersion) && fileVersion != mod.Version) { mod.Data["FileVersion"] = fileVersion; } DateTime?creationTime = assembly.GetCreationTime(); if (creationTime.HasValue) { mod.CreatedDate = creationTime.Value; } DateTime?lastWriteTime = assembly.GetLastWriteTime(); if (lastWriteTime.HasValue) { mod.ModifiedDate = lastWriteTime.Value; } if (assembly == Assembly.GetEntryAssembly()) { mod.IsEntry = true; } return mod; })); }
public static Module ToModuleInfo(this Assembly assembly) { if (assembly == null) return null; return _moduleCache.GetOrAdd(assembly.FullName, k => { var mod = new Module(); AssemblyName name = assembly.GetAssemblyName(); if (name != null) { mod.Name = name.Name; mod.Version = name.Version.ToString(); byte[] pkt = name.GetPublicKeyToken(); if (pkt.Length > 0) mod.Data["PublicKeyToken"] = pkt.ToHex(); } string infoVersion = assembly.GetInformationalVersion(); if (!String.IsNullOrEmpty(infoVersion) && infoVersion != mod.Version) mod.Data["ProductVersion"] = infoVersion; string fileVersion = assembly.GetFileVersion(); if (!String.IsNullOrEmpty(fileVersion) && fileVersion != mod.Version) mod.Data["FileVersion"] = fileVersion; DateTime? creationTime = assembly.GetCreationTime(); if (creationTime.HasValue) mod.CreatedDate = creationTime.Value; DateTime? lastWriteTime = assembly.GetLastWriteTime(); if (lastWriteTime.HasValue) mod.ModifiedDate = lastWriteTime.Value; if (assembly == Assembly.GetEntryAssembly()) mod.IsEntry = true; return mod; }); }
public static Module ToModuleInfo(this Assembly assembly, IExceptionlessLog log = null) { if (assembly == null) { return(null); } if (log == null) { log = new NullExceptionlessLog(); } Action <Exception, string> logError; #if EMBEDDED logError = (e, message) => log.Error(e, message); #else logError = (e, message) => Log.Error().Exception(e).Message(message).Report().Write(); #endif Module module = _moduleCache.GetOrAdd(assembly.FullName, k => { var mod = new Module(); AssemblyName name = assembly.GetAssemblyName(); if (name != null) { mod.Name = name.Name; mod.Version = name.Version.ToString(); byte[] pkt = name.GetPublicKeyToken(); if (pkt.Length > 0) { mod.Data["PublicKeyToken"] = pkt.ToHex(); } } string infoVersion = assembly.GetInformationalVersion(); if (!String.IsNullOrEmpty(infoVersion) && infoVersion != mod.Version) { mod.Data["ProductVersion"] = infoVersion; } string fileVersion = assembly.GetFileVersion(); if (!String.IsNullOrEmpty(fileVersion) && fileVersion != mod.Version) { mod.Data["FileVersion"] = fileVersion; } DateTime?creationTime = assembly.GetCreationTime(); if (creationTime.HasValue) { mod.CreatedDate = creationTime.Value; } DateTime?lastWriteTime = assembly.GetLastWriteTime(); if (lastWriteTime.HasValue) { mod.ModifiedDate = lastWriteTime.Value; } return(mod); }); if (module != null) { if (assembly == Assembly.GetEntryAssembly()) { module.IsEntry = true; } } return(module); }
protected bool Equals(Module other) { return ModuleId == other.ModuleId && string.Equals(Name, other.Name) && string.Equals(Version, other.Version) && IsEntry == other.IsEntry && CreatedDate.Equals(other.CreatedDate) && ModifiedDate.Equals(other.ModifiedDate) && Equals(Data, other.Data); }
public static Module ToModuleInfo(this Assembly assembly, IExceptionlessLog log = null) { if (assembly == null) return null; if (log == null) log = new NullExceptionlessLog(); Action<Exception, string> logError; #if EMBEDDED logError = (e, message) => log.Error(e, message); #else logError = (e, message) => Log.Error().Exception(e).Message(message).Report().Write(); #endif Module module = _moduleCache.GetOrAdd(assembly.FullName, k => { var mod = new Module(); AssemblyName name = assembly.GetAssemblyName(); if (name != null) { mod.Name = name.Name; mod.Version = name.Version.ToString(); byte[] pkt = name.GetPublicKeyToken(); if (pkt.Length > 0) mod.Data["PublicKeyToken"] = pkt.ToHex(); } string infoVersion = assembly.GetInformationalVersion(); if (!String.IsNullOrEmpty(infoVersion) && infoVersion != mod.Version) mod.Data["ProductVersion"] = infoVersion; string fileVersion = assembly.GetFileVersion(); if (!String.IsNullOrEmpty(fileVersion) && fileVersion != mod.Version) mod.Data["FileVersion"] = fileVersion; DateTime? creationTime = assembly.GetCreationTime(); if (creationTime.HasValue) mod.CreatedDate = creationTime.Value; DateTime? lastWriteTime = assembly.GetLastWriteTime(); if (lastWriteTime.HasValue) mod.ModifiedDate = lastWriteTime.Value; return mod; }); if (module != null) { if (assembly == Assembly.GetEntryAssembly()) module.IsEntry = true; } return module; }