public override bool RuntimeValidation(ref string error) { // Get the zone system from the travel demand model if (ZoneSystemSource != null) { ZoneSystemSource.LoadData(); ZoneSystem = ZoneSystemSource.GiveData(); } else { if (Functions.ModelSystemReflection.GetRootOfType(Config, typeof(ITravelDemandModel), this, out IModelSystemStructure tdm)) { ZoneSystem = ((ITravelDemandModel)tdm.Module).ZoneSystem; if (ZoneSystem != null && !ZoneSystem.Loaded) { ZoneSystem.LoadData(); } } } if (ZoneSystem == null) { error = $"In {Name} we were unable to load a zone system for our calculations!"; return(false); } return(base.RuntimeValidation(ref error)); }
public bool RuntimeValidation(ref string error) { if ((_SecondaryPool = Root.Pools.FirstOrDefault(p => p.Name == SecondaryPool.Data)) == null) { error = $"In '{Name}' we were unable to find a pool with the name '{SecondaryPool.Data}'."; return(false); } // this is safe because a parent's runtime validation will always execute first if ((_PrimaryAttribute = Parent._PrimaryPool.Attributes.FirstOrDefault(a => a.Name == PrimaryAttribute.Data)) == null) { error = $"In '{Name} we were unable to find an attribute called '{PrimaryAttribute.Data}' in the pool '{Parent._PrimaryPool.Name}'.'"; return(false); } _SecondaryAttributes = SecondaryAttributes.Select(s => _SecondaryPool.Attributes.FirstOrDefault(at => at.Name == s.Data)).ToArray(); for (int i = 0; i < _SecondaryAttributes.Length; i++) { if (_SecondaryAttributes[i] == null) { error = $"In '{Name}' we were unable to find an attribute named '{SecondaryAttributes[i].Data}' in the pool '{SecondaryPool.Name}'"; return(false); } } // Get the zone system from the travel demand model if (ZoneSystemSource != null) { ZoneSystemSource.LoadData(); ZoneSystem = ZoneSystemSource.GiveData(); } else { if (Functions.ModelSystemReflection.GetRootOfType(Config, typeof(ITravelDemandModel), this, out IModelSystemStructure tdm)) { ZoneSystem = ((ITravelDemandModel)tdm.Module).ZoneSystem; if (ZoneSystem != null && !ZoneSystem.Loaded) { ZoneSystem.LoadData(); } } } return(true); }
public bool RuntimeValidation(ref string error) { // Get the zone system from the travel demand model if (ZoneSystemSource != null) { ZoneSystemSource.LoadData(); ZoneSystem = ZoneSystemSource.GiveData(); } else { if (Functions.ModelSystemReflection.GetRootOfType(Config, typeof(ITravelDemandModel), this, out IModelSystemStructure tdm)) { ZoneSystem = ((ITravelDemandModel)tdm.Module).ZoneSystem; if (ZoneSystem != null && !ZoneSystem.Loaded) { ZoneSystem.LoadData(); } } } // ZoneSystem can still be null at the end of this return(true); }