Ejemplo n.º 1
0
        private static void TryInjectValueInteractive(MemberInfo member, NukeBuild build)
        {
            if (!member.HasCustomAttribute <ParameterAttribute>())
            {
                return;
            }

            if (member is PropertyInfo property && !property.CanWrite)
            {
                return;
            }

            var memberType        = member.GetMemberType();
            var nameOrDescription = ParameterService.GetParameterDescription(member) ??
                                    ParameterService.GetParameterMemberName(member);
            var text = $"{nameOrDescription.TrimEnd('.')}:";

            while (member.GetValue(build) == null)
            {
                var valueSet = ParameterService.GetParameterValueSet(member, build);
                var value    = valueSet == null
                    ? ConsoleUtility.PromptForInput(text, defaultValue : null)
                    : ConsoleUtility.PromptForChoice(text, valueSet.Select(x => (x.Object, x.Text)).ToArray());

                member.SetValue(build, ReflectionService.Convert(value, memberType));
            }
        }
Ejemplo n.º 2
0
        private static void InjectValueInteractive(NukeBuild build, MemberInfo member)
        {
            var memberType        = member.GetMemberType();
            var nameOrDescription = ParameterService.Instance.GetParameterDescription(member) ??
                                    ParameterService.Instance.GetParameterName(member);
            var text = $"{nameOrDescription.TrimEnd('.')}:";

            while (member.GetValue(build) == null)
            {
                var valueSet = ParameterService.Instance.GetParameterValueSet(member, build);
                var value    = valueSet == null
                    ? ConsoleUtility.PromptForInput(text, defaultValue : null)
                    : ConsoleUtility.PromptForChoice(text, valueSet.Select(x => (x.Object, x.Text)).ToArray());

                member.SetValue(build, ReflectionService.Convert(value, memberType));
            }
        }