/// <summary> /// Asserts whether a <see cref="MeasurementUnit"/> is in the chain of <see cref="ReferenceDataLibrary"/> /// </summary> /// <param name="measurementUnit"> /// The subject <see cref="MeasurementUnit"/> /// </param> /// <returns> /// true if the <see cref="MeasurementUnit"/> is on the chain of <see cref="ReferenceDataLibrary"/>, false if not /// </returns> /// <remarks> /// The current <see cref="ReferenceDataLibrary"/> is in included in the chain of <see cref="ReferenceDataLibrary"/>. /// Equality is determined based on unique identifier (iid) equality. /// </remarks> public bool IsMeasurementUnitInChainOfRdls(MeasurementUnit measurementUnit) { foreach (var referenceDataLibrary in this.AggregatedReferenceDataLibrary) { if (referenceDataLibrary.Unit.Any(f => f.Iid == measurementUnit.Iid)) { return(true); } } return(false); }
/// <summary> /// Validates the cardinalities of the properties of this <see cref="ConversionBasedUnit"/>. /// </summary> /// <returns> /// A list of potential errors. /// </returns> protected override IEnumerable <string> ValidatePocoCardinality() { var errorList = new List <string>(base.ValidatePocoCardinality()); if (string.IsNullOrWhiteSpace(this.ConversionFactor)) { errorList.Add("The property ConversionFactor is null or empty."); } if (this.ReferenceUnit == null || this.ReferenceUnit.Iid == Guid.Empty) { errorList.Add("The property ReferenceUnit is null."); this.ReferenceUnit = SentinelThingProvider.GetSentinel <MeasurementUnit>(); this.sentinelResetMap["ReferenceUnit"] = () => this.ReferenceUnit = null; } return(errorList); }
/// <summary> /// Resolve the properties of the current <see cref="UnitFactor"/> from its <see cref="DTO.Thing"/> counter-part /// </summary> /// <param name="dtoThing">The source <see cref="DTO.Thing"/></param> internal override void ResolveProperties(DTO.Thing dtoThing) { if (dtoThing == null) { throw new ArgumentNullException("dtoThing"); } var dto = dtoThing as DTO.UnitFactor; if (dto == null) { throw new InvalidOperationException(string.Format("The DTO type {0} does not match the type of the current UnitFactor POCO.", dtoThing.GetType())); } this.ExcludedDomain.ResolveList(dto.ExcludedDomain, dto.IterationContainerId, this.Cache); this.ExcludedPerson.ResolveList(dto.ExcludedPerson, dto.IterationContainerId, this.Cache); this.Exponent = dto.Exponent; this.ModifiedOn = dto.ModifiedOn; this.RevisionNumber = dto.RevisionNumber; this.ThingPreference = dto.ThingPreference; this.Unit = this.Cache.Get <MeasurementUnit>(dto.Unit, dto.IterationContainerId) ?? SentinelThingProvider.GetSentinel <MeasurementUnit>(); this.ResolveExtraProperties(); }