Exemplo n.º 1
0
 protected override string Format(TFormatter formatter, PersonIdentifierFormatOption option)
 {
     if (string.IsNullOrEmpty(option.HyphenChar) && CanCalculateBirthDate)
     {
         option.HyphenChar = CalculateAge() >= 100 ? PersonIdentifierFormatter.HyphenWhenOver100YearsOld : PersonIdentifierFormatter.DefaultHyphen;
     }
     return(base.Format(formatter, option));
 }
        public override string Format(PersonIdentifierFormatOption option)
        {
            var sb = new StringBuilder();

            FormatYear(sb, option);
            FormatMonth(sb, option);
            FormatDay(sb, option);
            FormatHyphen(sb, option);
            FormatSerial(sb, option);
            return(sb.ToString());
        }
        protected virtual void FormatHyphen(StringBuilder sb, PersonIdentifierFormatOption option)
        {
            var useHyphen = option.WithHyphen ?? !string.IsNullOrEmpty(Hyphen);

            if (useHyphen)
            {
                var hyphen = option.HyphenChar;
                if (string.IsNullOrEmpty(hyphen))
                {
                    hyphen = Hyphen;
                }
                if (string.IsNullOrEmpty(hyphen))
                {
                    hyphen = DefaultHyphen;
                }

                sb.Append(hyphen);
            }
        }
        protected virtual void FormatYear(StringBuilder sb, PersonIdentifierFormatOption option)
        {
            if (option == null)
            {
                throw new ArgumentNullException(nameof(option));
            }
            var withCentury = (option.WithCentury.HasValue && option.WithCentury.Value) || CenturySpecified;

            if (withCentury)
            {
                sb.Append(Century.ToString("00"));
                if (option.CenturySeparated)
                {
                    sb.Append(option.CenturySeparationChar);
                }
            }

            sb.Append(TwoDigitYear.ToString("00"));
        }
Exemplo n.º 5
0
        protected override void FormatDay(StringBuilder sb, PersonIdentifierFormatOption option)
        {
            var day = Day + AddToDays;

            sb.Append(day.ToString("00"));
        }
 protected virtual void FormatSerial(StringBuilder sb, PersonIdentifierFormatOption option)
 {
     sb.Append(SerialNumber);
 }
 protected virtual void FormatDay(StringBuilder sb, PersonIdentifierFormatOption option)
 {
     sb.Append(Day.ToString("00"));
 }
 public virtual string Format(PersonIdentifierFormatOption option)
 {
     return(Value);
 }
Exemplo n.º 9
0
 protected virtual string Format(TFormatter formatter, PersonIdentifierFormatOption option)
 {
     return(formatter.Format(option));
 }
Exemplo n.º 10
0
 public string ToString(PersonIdentifierFormatOption option)
 {
     return(Format(_formatter, option));
 }