/// <summary>
        /// Formats the Accession number according to the specified format string
        /// </summary>
        /// <remarks>
        /// Valid format specifiers are as follows:
        ///		%L - accession number label as specified in <see cref="FormatSettings"/>
        ///		%N - number masked as specified in <see cref="FormatSettings"/>
        ///		%n - number without mask
        /// </remarks>
        /// <param name="accession"></param>
        /// <param name="format"></param>
        /// <returns></returns>
        public static string Format(string accession, string format)
        {
            string result = format;

            result = result.Replace("%L", FormatSettings.Default.AccessionNumberLabel ?? "");
            result = result.Replace("%N", StringMask.Apply(accession, FormatSettings.Default.AccessionNumberMask) ?? "");
            result = result.Replace("%n", accession ?? "");

            return(result.Trim());
        }
Esempio n. 2
0
        /// <summary>
        /// Formats the address according to the specified format string.
        /// </summary>
        /// <remarks>
        /// Valid format specifiers are as follows:
        ///     %C - country code, preceded by +
        ///     %c - country code if different from default country code specified in <see cref="FormatSettings"/>
        ///     %A - area code
        ///     %N - phone number in form XXX-XXXX
        ///     %X - extension, preceded by x
        /// </remarks>
        /// <param name="tn"></param>
        /// <param name="format"></param>
        /// <returns></returns>
        public static string Format(TelephoneDetail tn, string format)
        {
            string result = format;

            result = result.Replace("%C", tn.CountryCode == null ? "" : string.Format("+{0}", tn.CountryCode));

            result = result.Replace("%c",
                                    (tn.CountryCode == null || tn.CountryCode == FormatSettings.Default.TelephoneNumberSuppressCountryCode) ? ""
                : string.Format("+{0}", tn.CountryCode));

            result = result.Replace("%A", tn.AreaCode == null ? "" : tn.AreaCode);
            result = result.Replace("%N", StringMask.Apply(tn.Number, FormatSettings.Default.TelephoneNumberLocalMask) ?? "");
            result = result.Replace("%X", string.IsNullOrEmpty(tn.Extension) ? "" : string.Format("x{0}", tn.Extension));

            return(result.Trim());
        }