public static void ExpireOverlappingInstances(ITemporalList <T> list, T newInstance) { TimeInterval effectivePeriod = newInstance.EffectivePeriod; if (null != effectivePeriod) { DateTime effectiveDate = effectivePeriod.EffectiveDate; //Verfiy that the effective date of the new instance is more than that of all instances in the list foreach (T i in list) { if (null != i.EffectivePeriod && i.EffectivePeriod.EffectiveDate > effectiveDate) { throw new iSabayaException("The effective date of the added instance is less than some existing effective dates"); } } //Expire the current one foreach (T i in list) { if (null != i.EffectivePeriod && i.EffectivePeriod.IsEffectiveOn(effectiveDate)) { i.EffectivePeriod.ExpiryDate = effectiveDate; } } } }
public static T GetInstance(ITemporalList <T> list, DateTime when) { foreach (T i in list) { if (i.EffectivePeriod.IsEffectiveOn(when)) { return(i); } } return(default(T)); }