/// <summary>
        /// Fixes the license placeholder.
        /// </summary>
        /// <remarks>
        /// This method fixes the license placeholder if necessary.
        /// </remarks>
        /// <param name="value">
        /// The help license attribute to be fixed.
        /// </param>
        /// <returns>
        /// The fixed help license attribute.
        /// </returns>
        private HelpLicenseAttribute FixupLicense(HelpLicenseAttribute value)
        {
            if (value.IsContent)
            {
                if (value.Content.Contains(Placeholders.Copyright))
                {
                    try
                    {
                        AssemblyCopyrightAttribute copyright = Assembly.GetEntryAssembly().GetCustomAttributes()
                                                               .Where(x => x is AssemblyCopyrightAttribute).FirstOrDefault() as AssemblyCopyrightAttribute;

                        if (copyright != null && !String.IsNullOrWhiteSpace(copyright.Copyright))
                        {
                            value.Content = value.Content.Replace(Placeholders.Copyright, copyright.Copyright);
                        }
                    }
                    catch (Exception exception)
                    {
                        Debug.WriteLine(exception);
                    }
                }

                if (value.Content.Contains(Placeholders.Company))
                {
                    try
                    {
                        AssemblyCompanyAttribute company = Assembly.GetEntryAssembly().GetCustomAttributes()
                                                           .Where(x => x is AssemblyCompanyAttribute).FirstOrDefault() as AssemblyCompanyAttribute;

                        if (company != null && !String.IsNullOrWhiteSpace(company.Company))
                        {
                            value.Content = value.Content.Replace(Placeholders.Company, company.Company);
                        }
                    }
                    catch (Exception exception)
                    {
                        Debug.WriteLine(exception);
                    }
                }

                if (value.Content.Contains(Placeholders.Version))
                {
                    try
                    {
                        String version = Assembly.GetEntryAssembly().GetName().Version.ToString();

                        if (!String.IsNullOrWhiteSpace(version))
                        {
                            value.Content = value.Content.Replace(Placeholders.Version, version);
                        }
                    }
                    catch (Exception exception)
                    {
                        Debug.WriteLine(exception);
                    }
                }
            }

            return(value);
        }
Пример #2
0
        public void HelpLicense_SetProperty_TrimmedContent(String actual)
        {
            HelpLicenseAttribute attribute = new HelpLicenseAttribute();

            attribute.Content = actual;
            Assert.AreEqual(attribute.Content, "Hello World");
        }
Пример #3
0
        public void HelpLicense_SetProperty_ResultIsEmptyContent(String actual)
        {
            HelpLicenseAttribute attribute = new HelpLicenseAttribute();

            attribute.Content = actual;
            Assert.IsEmpty(attribute.Content);
        }
Пример #4
0
        public void HelpLicense_Construction_ResultIsEmptyContent(String actual)
        {
            HelpLicenseAttribute attribute = new HelpLicenseAttribute(actual);

            Assert.IsEmpty(attribute.Content);
        }
Пример #5
0
        public void HelpLicense_DefaultConstruction_ResultIsDefaultContent()
        {
            HelpLicenseAttribute attribute = new HelpLicenseAttribute();

            Assert.AreEqual(attribute.Content, "Copyright © <company>");
        }