public static Address Parse(string address) { var rx = new Regex("Street : (.*), City : (.*), PostCode : (.*)"); var match = rx.Match(address); var street = new Street(match.Groups[0].Value); var city = new City(match.Groups[1].Value); var postcode = new PostCode(match.Groups[2].Value); return new Address(street, city, postcode); }
public static Address Parse(string address) { var rx = new Regex("BuildingNumber: (.*), StreetName: (.*), City: (.*), PostCode: (.*)"); var match = rx.Match(address); var streetNumber = match.Groups[1].Value; int number; if (!int.TryParse(streetNumber, out number)) { number = 0; } var streetName = match.Groups[2].Value; var street = new Street(number, streetName); var city = new City(match.Groups[3].Value); var postcode = new PostCode(match.Groups[4].Value); return(new Address(street, city, postcode)); }
public Address() { city = new City(); postalCode = new PostCode(); street = new Street(); }
public Address(Street street, City city, PostCode postalCode) { this.street = street; this.postalCode = postalCode; this.city = city; }