Esempio n. 1
0
        private static T RandomizeNumber <T>(UIComponentMetadata metadata)
        {
            var attribute = metadata.Get <RandomizeNumberSettingsAttribute>(AttributeLevels.Declared) ?? new RandomizeNumberSettingsAttribute();

            decimal value = Randomizer.GetDecimal(attribute.Min, attribute.Max, attribute.Precision);

            return((T)Convert.ChangeType(value, typeof(T)));
        }
Esempio n. 2
0
        private static T RandomizeNumber <T>(UIComponentMetadata metadata)
        {
            if (!TryRandomizeOneOfIncluded(metadata, out T value))
            {
                var attribute = metadata.Get <RandomizeNumberSettingsAttribute>()
                                ?? new RandomizeNumberSettingsAttribute();

                decimal valueAsDecimal = Randomizer.GetDecimal(attribute.Min, attribute.Max, attribute.Precision);
                value = (T)Convert.ChangeType(valueAsDecimal, typeof(T));
            }

            return(value);
        }