public DestinationParkingNodeDao() { Framework.DomainModels.Persisters.IPersisterReader <IDestinationParkingNode> reader = Global .ContainerDaySim.GetInstance <IPersistenceFactory <IDestinationParkingNode> >() .Reader; IDestinationParkingNodeCreator creator = Global .ContainerDaySim .GetInstance <IWrapperFactory <IDestinationParkingNodeCreator> >() .Creator; Dictionary <int, HashSet <int> > zoneIdKeys = new Dictionary <int, HashSet <int> >(); Dictionary <int, HashSet <int> > parcelIdKeys = new Dictionary <int, HashSet <int> >(); Dictionary <int, Framework.ShadowPricing.IDestinationParkingShadowPriceNode> destinationParkingShadowPrices = DestinationParkingShadowPriceReader.ReadDestinationParkingShadowPrices(); foreach (IDestinationParkingNode destinationParkingNode in reader) { IDestinationParkingNodeWrapper node = creator.CreateWrapper(destinationParkingNode); int id = node.Id; _nodes.Add(id, node); int zoneId = node.ZoneId; if (!zoneIdKeys.TryGetValue(zoneId, out HashSet <int> zoneIdKey)) { zoneIdKey = new HashSet <int>(); zoneIdKeys.Add(zoneId, zoneIdKey); } zoneIdKey.Add(id); int parcelId = node.ParcelId; if (!parcelIdKeys.TryGetValue(parcelId, out HashSet <int> parcelIdKey)) { parcelIdKey = new HashSet <int>(); parcelIdKeys.Add(parcelId, parcelIdKey); } node.SetDestinationParkingShadowPricing(destinationParkingShadowPrices); parcelIdKey.Add(id); } foreach (KeyValuePair <int, HashSet <int> > entry in zoneIdKeys) { _zoneIdKeys.Add(entry.Key, entry.Value.ToArray()); } foreach (KeyValuePair <int, HashSet <int> > entry in parcelIdKeys) { _parcelIdKeys.Add(entry.Key, entry.Value.ToArray()); } }
public DestinationParkingNodeDao() { var reader = Global .ContainerDaySim.GetInstance <IPersistenceFactory <IDestinationParkingNode> >() .Reader; var creator = Global .ContainerDaySim .GetInstance <IWrapperFactory <IDestinationParkingNodeCreator> >() .Creator; var zoneIdKeys = new Dictionary <int, HashSet <int> >(); var parcelIdKeys = new Dictionary <int, HashSet <int> >(); var destinationParkingShadowPrices = DestinationParkingShadowPriceReader.ReadDestinationParkingShadowPrices(); foreach (var destinationParkingNode in reader) { var node = creator.CreateWrapper(destinationParkingNode); var id = node.Id; _nodes.Add(id, node); var zoneId = node.ZoneId; HashSet <int> zoneIdKey; if (!zoneIdKeys.TryGetValue(zoneId, out zoneIdKey)) { zoneIdKey = new HashSet <int>(); zoneIdKeys.Add(zoneId, zoneIdKey); } zoneIdKey.Add(id); var parcelId = node.ParcelId; HashSet <int> parcelIdKey; if (!parcelIdKeys.TryGetValue(parcelId, out parcelIdKey)) { parcelIdKey = new HashSet <int>(); parcelIdKeys.Add(parcelId, parcelIdKey); } node.SetDestinationParkingShadowPricing(destinationParkingShadowPrices); parcelIdKey.Add(id); } foreach (var entry in zoneIdKeys) { _zoneIdKeys.Add(entry.Key, entry.Value.ToArray()); } foreach (var entry in parcelIdKeys) { _parcelIdKeys.Add(entry.Key, entry.Value.ToArray()); } }