/// <summary> /// Enriches the package from assembly. /// </summary> /// <param name="source">The source.</param> /// <param name="assembly">The assembly.</param> /// <returns></returns> public static DnnPackage EnrichPackageFromAssembly(this DnnPackage source, Assembly assembly) { // Package friendly name: if empty set from the AssemblyTitle attribute or defaults to the package name. if (string.IsNullOrWhiteSpace(source.FriendlyName)) { var titleAttribute = assembly.GetCustomAttribute <AssemblyTitleAttribute>(); source.FriendlyName = titleAttribute != null && !string.IsNullOrWhiteSpace(titleAttribute.Title) ? titleAttribute.Title : source.Name; } // Package description: if empty set from AssemblyDescription attribute or defaults to the package name. if (string.IsNullOrWhiteSpace(source.Description)) { var descriptionAttribute = assembly.GetCustomAttribute <AssemblyDescriptionAttribute>(); source.Description = descriptionAttribute != null && !string.IsNullOrWhiteSpace(descriptionAttribute.Description) ? descriptionAttribute.Description : source.Name; } // Package owner var owner = assembly.GetCustomAttribute <AssemblyCompanyAttribute>(); if (owner != null) { source.Owner.Organisation = owner.Company; } var companyInfo = assembly.GetCustomAttribute <AssemblyCompanyInfoAttribute>(); if (companyInfo != null) { source.Owner.Email = companyInfo.EmailAddress; source.Owner.Url = companyInfo.Url; } return(source); }
/// <summary> /// Creates the package from attribute. /// </summary> /// <param name="attribute">The attribute.</param> /// <returns></returns> private DnnPackage CreatePackageFromAttribute(DnnPackageAttribute attribute) { var assemblyName = this.Assembly.GetName(); return(DnnPackage.FromAttribute(attribute, assemblyName).EnrichPackageFromAssembly(this.Assembly)); }