コード例 #1
0
ファイル: CaseExtensions.cs プロジェクト: artemiymax/hugmun
        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);
        }
コード例 #2
0
ファイル: CaseExtensions.cs プロジェクト: artemiymax/hugmun
        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);
        }
コード例 #3
0
ファイル: MinMaxNormalizer.cs プロジェクト: artemiymax/hugmun
        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);
        }