/// <summary> /// Initializes a new instance of the <see cref="Venue"/> class. /// </summary> /// <param name="ci">A <see cref="VenueCI"/> used to create new instance</param> /// <param name="cultures">A culture of the current instance of <see cref="VenueCI"/></param> public Venue(VenueCI ci, IEnumerable <CultureInfo> cultures) { Contract.Requires(ci != null); Contract.Requires(cultures != null && cultures.Any()); var cultureList = cultures as IList <CultureInfo> ?? cultures.ToList(); Id = ci.Id; Coordinates = ci.Coordinates; Capacity = ci.Capacity; Names = new ReadOnlyDictionary <CultureInfo, string>( cultureList.Where(c => ci.GetName(c) != null).ToDictionary(c => c, ci.GetName)); Cities = new ReadOnlyDictionary <CultureInfo, string>( cultureList.Where(c => ci.GetCity(c) != null).ToDictionary(c => c, ci.GetCity)); Countries = new ReadOnlyDictionary <CultureInfo, string>( cultureList.Where(c => ci.GetCountry(c) != null).ToDictionary(c => c, ci.GetCountry)); CountryCode = ci.CountryCode; }
/// <summary> /// Initializes a new instance of the <see cref="Venue"/> class. /// </summary> /// <param name="ci">A <see cref="VenueCI"/> used to create new instance</param> /// <param name="cultures">A culture of the current instance of <see cref="VenueCI"/></param> public Venue(VenueCI ci, IEnumerable <CultureInfo> cultures) { Guard.Argument(ci, nameof(ci)).NotNull(); Guard.Argument(cultures, nameof(cultures)).NotNull().NotEmpty(); var cultureList = cultures as IList <CultureInfo> ?? cultures.ToList(); Id = ci.Id; Coordinates = ci.Coordinates; Capacity = ci.Capacity; Names = new ReadOnlyDictionary <CultureInfo, string>( cultureList.Where(c => ci.GetName(c) != null).ToDictionary(c => c, ci.GetName)); Cities = new ReadOnlyDictionary <CultureInfo, string>( cultureList.Where(c => ci.GetCity(c) != null).ToDictionary(c => c, ci.GetCity)); Countries = new ReadOnlyDictionary <CultureInfo, string>( cultureList.Where(c => ci.GetCountry(c) != null).ToDictionary(c => c, ci.GetCountry)); CountryCode = ci.CountryCode; }
public void VenueMergeTest() { var venue1 = new venue { id = SR.Urn("venue").ToString(), capacity = 5, capacitySpecified = true, city_name = "my city", country_name = "eng country name", state = "state", map_coordinates = "coordinates", name = "eng name" }; var venue2 = new venue { id = SR.Urn("venue").ToString(), capacity = 5, capacitySpecified = true, city_name = "my city", country_name = "de country name", state = "state", map_coordinates = "coordinates", name = "eng name" }; var venueDTO1 = new VenueDTO(venue1); var venueDTO2 = new VenueDTO(venue2); var venueCI = new VenueCI(venueDTO1, _cultureFirst); venueCI.Merge(venueDTO2, _cultureSecond); Assert.IsNotNull(venueCI); Assert.AreEqual(venue1.id, venueCI.Id.ToString()); Assert.AreEqual(venue1.name, venueCI.GetName(_cultureFirst)); Assert.AreEqual(venue1.capacity, venueCI.Capacity); Assert.AreEqual(venue1.map_coordinates, venueCI.Coordinates); Assert.AreEqual(venue1.state, venueCI.State); Assert.AreEqual(venue1.city_name, venueCI.GetCity(_cultureFirst)); Assert.AreEqual(venue1.country_name, venueCI.GetCountry(_cultureFirst)); Assert.AreEqual(venue2.country_name, venueCI.GetCountry(_cultureSecond)); Assert.AreNotEqual(venueCI.GetCountry(_cultureFirst), venueCI.GetCountry(_cultureSecond)); }
/// <summary> /// Initializes a new instance of the <see cref="Venue"/> class. /// </summary> /// <param name="ci">A <see cref="VenueCI"/> used to create new instance</param> /// <param name="cultures">A culture of the current instance of <see cref="VenueCI"/></param> public Venue(VenueCI ci, IEnumerable <CultureInfo> cultures) { Guard.Argument(ci, nameof(ci)).NotNull(); Guard.Argument(cultures, nameof(cultures)).NotNull();//.NotEmpty(); if (!cultures.Any()) { throw new ArgumentOutOfRangeException(nameof(cultures)); } var cultureList = cultures as IList <CultureInfo> ?? cultures.ToList(); Id = ci.Id; Coordinates = ci.Coordinates; Capacity = ci.Capacity; Names = new ReadOnlyDictionary <CultureInfo, string>(cultureList.Where(c => ci.GetName(c) != null).ToDictionary(c => c, ci.GetName)); Cities = new ReadOnlyDictionary <CultureInfo, string>(cultureList.Where(c => ci.GetCity(c) != null).ToDictionary(c => c, ci.GetCity)); Countries = new ReadOnlyDictionary <CultureInfo, string>(cultureList.Where(c => ci.GetCountry(c) != null).ToDictionary(c => c, ci.GetCountry)); CountryCode = ci.CountryCode; State = ci.State; Course = ci.Course?.Select(s => new Hole(s)); }