private string GetChangeLogFilename() { return(ProductName.Trim() + ".ChangeLog.html"); }
private void SetNamesAndVersion(string applicationFilename, Assembly exeAssembly, bool isHttp) { Type mainType = null; // Get CompanyName, ProductName, and ProductVersion // First try custom attributes on the assembly. if (exeAssembly != null) { object[] attrs = exeAssembly.GetCustomAttributes(typeof(AssemblyCompanyAttribute), false); if ((attrs != null) && (attrs.Length > 0)) { _companyName = ((AssemblyCompanyAttribute)attrs[0]).Company; _companyName = _companyName?.Trim(); } attrs = exeAssembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false); if ((attrs != null) && (attrs.Length > 0)) { ProductName = ((AssemblyProductAttribute)attrs[0]).Product; ProductName = ProductName?.Trim(); } ProductVersion = exeAssembly.GetName().Version.ToString(); ProductVersion = ProductVersion?.Trim(); } // If we couldn't get custom attributes, fall back on the entry type namespace if (!isHttp && (string.IsNullOrEmpty(_companyName) || string.IsNullOrEmpty(ProductName) || string.IsNullOrEmpty(ProductVersion))) { if (exeAssembly != null) { MethodInfo entryPoint = exeAssembly.EntryPoint; if (entryPoint != null) { mainType = entryPoint.ReflectedType; } } string ns = null; if (mainType != null) { ns = mainType.Namespace; } if (string.IsNullOrEmpty(ProductName)) { // Try the remainder of the namespace if (ns != null) { int lastDot = ns.LastIndexOf(".", StringComparison.Ordinal); if ((lastDot != -1) && (lastDot < ns.Length - 1)) { ProductName = ns.Substring(lastDot + 1); } else { ProductName = ns; } ProductName = ProductName.Trim(); } // Try the type of the entry assembly if (string.IsNullOrEmpty(ProductName) && (mainType != null)) { ProductName = mainType.Name.Trim(); } // give up, return empty string if (ProductName == null) { ProductName = string.Empty; } } if (string.IsNullOrEmpty(_companyName)) { // Try the first part of the namespace if (ns != null) { int firstDot = ns.IndexOf(".", StringComparison.Ordinal); _companyName = firstDot != -1 ? ns.Substring(0, firstDot) : ns; _companyName = _companyName.Trim(); } // If that doesn't work, use the product name if (string.IsNullOrEmpty(_companyName)) { _companyName = ProductName; } } } // Desperate measures for product version - assume 1.0 if (string.IsNullOrEmpty(ProductVersion)) { ProductVersion = "1.0.0.0"; } }
/// <inheritdoc /> public override string ToString() { return(string.Format(CultureInfo.InvariantCulture, "{0} ({1}VID {2}, PID {3}, version {4})", Manufacturer.Length > 0 || ProductName.Length > 0 ? Manufacturer.Trim() + " " + ProductName.Trim() : "(unnamed)", SerialNumber.Length > 0 ? "serial " + SerialNumber.Trim() + ", " : "", VendorID, ProductID, ProductVersion)); }