public static void GetAccessors(this ILotAttributes lotAttributes, IAttributeNameKey attribute, out Func <decimal?> get, out Func <decimal?, decimal?> set) { var attributeNameKey = new AttributeNameKey(attribute); get = () => AttributeGetters[attributeNameKey](lotAttributes); set = v => AttributeSetters[attributeNameKey](lotAttributes, v); }
public LotAttributesCopy(ILotAttributes source) { _wrappedAttributes = this.GetAttributes(null).ToDictionary(a => a.AttributeNameKey.ToString()); foreach (var attribute in _wrappedAttributes) { attribute.Value.Value = source.AttributeGet(attribute.Value.AttributeNameKey)(); } }
public static Func <decimal?> AttributeGet(this ILotAttributes lotAttributes, IAttributeNameKey attributeNameKey) { Func <ILotAttributes, decimal?> getter; AttributeGetters.TryGetValue(new AttributeNameKey(attributeNameKey), out getter); if (getter == null) { return(null); } return(() => getter(lotAttributes)); }
public LotAttributeWrapper(ILotAttributes lot, ILotAttributes untestedHistory, AttributeName attributeName) { ActualValueRequired = attributeName.ActualValueRequired; AttributeNameKey = new AttributeNameKey(attributeName); lot.GetAccessors(attributeName, out _get, out _set); Computed = lot.TestDate == null; if (untestedHistory != null) { Computed = Value == untestedHistory.AttributeGet(attributeName)(); } }
public static Func <decimal?, decimal?> AttributeSet(this ILotAttributes lotAttributes, IAttributeNameKey attributeNameKey, bool rounded = false) { Func <ILotAttributes, decimal?, decimal?> setter; AttributeSetters.TryGetValue(new AttributeNameKey(attributeNameKey), out setter); if (setter == null) { return(null); } if (rounded) { return(v => setter(lotAttributes, Rounded(v, GetRoundDecimalPlaces(attributeNameKey)))); } return(v => setter(lotAttributes, v)); }
public static LotAttribute AddNewAttribute(this Lot lot, ILotAttributes oldLot, IAttributeNameKey attributeNameKey, CreateChileLotHelper.AttributeCommonData attributeData, ILotMother lotMother) { var getter = oldLot.AttributeGet(attributeNameKey); if (getter == null) { return(null); } var setter = oldLot.AttributeSet(attributeNameKey, true); var value = setter(getter()); if (value == null) { return(null); } lotMother.AddRead(EntityTypes.LotAttribute); if (attributeData.EntryDate == null) { return(null); } var lotAttribute = new LotAttribute { LotDateCreated = lot.LotDateCreated, LotDateSequence = lot.LotDateSequence, LotTypeId = lot.LotTypeId, AttributeShortName = attributeNameKey.AttributeNameKey_ShortName, AttributeValue = (double)value, AttributeDate = attributeData.DeterminedTestDate, EmployeeId = attributeData.TesterId, TimeStamp = attributeData.EntryDate.Value, Computed = attributeData.NullTestDate }; lot.Attributes.Add(lotAttribute); return(lotAttribute); }
private void AddNewLotAttribute(ILotAttributes oldAttributes, Lot newLot, ChileProductAttributeRange range, AttributeName attributeName, AttributeCommonData attributeData, double value, ref List <LotAttributeDefect> lotAttributeDefects) { var attribute = newLot.AddNewAttribute(oldAttributes, attributeName, attributeData, LotMother); if (attribute == null) { return; } if (range.ValueOutOfRange(attribute.AttributeValue)) { LotMother.AddRead(EntityTypes.LotDefect); LotMother.AddRead(EntityTypes.LotAttributeDefect); CreateOrUpdateOpenAttributeDefect(newLot, attributeName, value, range, ref lotAttributeDefects); } else { CloseOpenAttributeDefects(attribute, lotAttributeDefects); } }
public static IEnumerable <LotAttributeWrapper> GetAttributes(this ILotAttributes lot, ILotAttributes oldestUntestedHistory) { return(StaticAttributeNames.AttributeNames.Select(attribute => new LotAttributeWrapper(lot, oldestUntestedHistory, attribute))); }