コード例 #1
0
ファイル: PostalAddress.cs プロジェクト: itpreneur/DDD
 public static PostalAddress CreateIfNotEmpty(string street,
                                              string city,
                                              string postalCode             = null,
                                              Alpha2CountryCode countryCode = null,
                                              string houseNumber            = null,
                                              string boxNumber = null)
 {
     if (string.IsNullOrWhiteSpace(street))
     {
         return(null);
     }
     if (string.IsNullOrWhiteSpace(city))
     {
         return(null);
     }
     return(new PostalAddress
            (
                street,
                city,
                postalCode,
                countryCode,
                houseNumber,
                boxNumber
            ));
 }
コード例 #2
0
ファイル: PostalAddress.cs プロジェクト: itpreneur/DDD
 public PostalAddress(string street,
                      string city,
                      string postalCode             = null,
                      Alpha2CountryCode countryCode = null,
                      string houseNumber            = null,
                      string boxNumber = null)
 {
     Condition.Requires(street, nameof(street)).IsNotNullOrWhiteSpace();
     Condition.Requires(city, nameof(city)).IsNotNullOrWhiteSpace();
     this.Street = street.ToTitleCase();
     this.City   = city.ToTitleCase();
     if (!string.IsNullOrWhiteSpace(postalCode))
     {
         this.PostalCode = postalCode.ToUpper();
     }
     this.CountryCode = countryCode;
     if (!string.IsNullOrWhiteSpace(houseNumber))
     {
         this.HouseNumber = houseNumber.ToUpper();
     }
     if (!string.IsNullOrWhiteSpace(boxNumber))
     {
         this.BoxNumber = boxNumber.ToUpper();
     }
 }
コード例 #3
0
ファイル: PostalAddress.cs プロジェクト: itpreneur/DDD
 public static PostalAddress FromState(PostalAddressState state)
 {
     if (state == null)
     {
         return(null);
     }
     return(CreateIfNotEmpty
            (
                state.Street,
                state.City,
                state.PostalCode,
                Alpha2CountryCode.CreateIfNotEmpty(state.CountryCode),
                state.HouseNumber,
                state.BoxNumber
            ));
 }