public static T GetAttribute <T>(this ICase targetCase, AttributeSchema attribute) { if (targetCase == null) { throw new ArgumentNullException(nameof(targetCase)); } T value = default; var getter = targetCase.GetAttributeGetter <T>(attribute); getter(ref value); return(value); }
public static T GetAttribute <T>(this ICase targetCase, AttributeSchema attribute) { if (targetCase == null) { throw new ArgumentNullException(nameof(targetCase)); } if (attribute.Type != typeof(T)) { throw new ArgumentOutOfRangeException($"Attribute {attribute.Name} type is {attribute.Type}."); } T value = default; var getter = targetCase.GetAttributeGetter <T>(attribute); getter(ref value); return(value); }
internal override Delegate[] GetTransformingGetters(ICase targetCase) { if (targetCase == null) { throw new ArgumentNullException(nameof(targetCase)); } var getters = new AttributeGetter <double> [AttributeBinding.Count]; foreach (var binding in AttributeBinding) { var min = attributeMin[binding.Binding]; var max = attributeMax[binding.Binding]; var attributeGetter = targetCase.GetAttributeGetter <double>(targetCase.Schema[binding.Attribute]); getters[binding.Binding] = (ref double value) => { attributeGetter(ref value); Normalize(ref value, min, max); }; } return(getters); }