Exemple #1
0
        protected virtual TeamCityConfigurationParameter GetParameter(MemberInfo member, NukeBuild build, bool required)
        {
            var attribute = member.GetCustomAttribute <ParameterAttribute>();
            var valueSet  = ParameterService.GetParameterValueSet(member, build);

            var defaultValue = member.GetValue(build);

            if (member.GetMemberType() == typeof(AbsolutePath) ||
                member.GetMemberType() == typeof(Solution) ||
                member.GetMemberType() == typeof(Project))
            {
                defaultValue = (UnixRelativePath)GetRelativePath(NukeBuild.RootDirectory, defaultValue.ToString());
            }

            return(new TeamCityConfigurationParameter
            {
                Name = member.Name,
                Description = attribute.Description,
                Options = valueSet?.ToDictionary(x => x.Item1, x => x.Item2),
                Type = valueSet != null ? TeamCityParameterType.Select : TeamCityParameterType.Text,
                DefaultValue = defaultValue?.ToString(),
                Display = required ? TeamCityParameterDisplay.Prompt : TeamCityParameterDisplay.Normal,
                AllowMultiple = member.GetMemberType().IsArray,
                ValueSeparator = attribute.Separator ?? " "
            });
        }
Exemple #2
0
        protected virtual TeamCityParameter GetParameter(MemberInfo member, NukeBuild build, bool required)
        {
            var attribute      = member.GetCustomAttribute <ParameterAttribute>();
            var valueSet       = ParameterService.GetParameterValueSet(member, build);
            var valueSeparator = attribute.Separator ?? " ";

            // TODO: Abstract AbsolutePath/Solution/Project etc.
            var defaultValue = !member.HasCustomAttribute <SecretAttribute>() ? member.GetValue(build) : default(string);

            // TODO: enumerables of ...
            if (defaultValue != null &&
                (member.GetMemberType() == typeof(AbsolutePath) ||
                 member.GetMemberType() == typeof(Solution) ||
                 member.GetMemberType() == typeof(Project)))
            {
                defaultValue = (UnixRelativePath)GetRelativePath(NukeBuild.RootDirectory, defaultValue.ToString());
            }

            TeamCityParameterType GetParameterType()
            {
                if (member.HasCustomAttribute <SecretAttribute>())
                {
                    return(TeamCityParameterType.Password);
                }
                if (member.GetMemberType() == typeof(bool))
                {
                    return(TeamCityParameterType.Checkbox);
                }
                if (valueSet != null)
                {
                    return(TeamCityParameterType.Select);
                }
                return(TeamCityParameterType.Text);
            }

            return(new TeamCityConfigurationParameter
            {
                // TODO: #555 - Should this use ParameterService.GetParameterMemberName(member) ?
                Name = ParameterService.GetParameterMemberName(member),
                Description = attribute.Description,
                Options = valueSet?.ToDictionary(x => x.Item1, x => x.Item2),
                Type = GetParameterType(),
                DefaultValue = member.GetMemberType().IsArray&& defaultValue is IEnumerable enumerable
                           ? enumerable.Cast <object>().Select(x => x.ToString()).Join(valueSeparator)
                           : defaultValue?.ToString(),
                Display = required ? TeamCityParameterDisplay.Prompt : TeamCityParameterDisplay.Normal,
                AllowMultiple = member.GetMemberType().IsArray&& valueSet is not null,
                ValueSeparator = valueSeparator
            });
        protected virtual AzurePipelinesVariable GetParameter(MemberInfo member, NukeBuild build, bool required)
        {
            var attribute      = member.GetCustomAttribute <ParameterAttribute>();
            var valueSet       = ParameterService.GetParameterValueSet(member, build);
            var valueSeparator = attribute.Separator ?? " ";

            // TODO: Abstract AbsolutePath/Solution/Project etc.
            var defaultValue = !member.HasCustomAttribute <SecretAttribute>() ? member.GetValue(build) : default(string);

            // TODO: enumerables of ...
            if (defaultValue != null &&
                (member.GetMemberType() == typeof(AbsolutePath) ||
                 member.GetMemberType() == typeof(Solution) ||
                 member.GetMemberType() == typeof(Project)))
            {
                defaultValue = (UnixRelativePath)GetRelativePath(NukeBuild.RootDirectory, defaultValue.ToString());
            }

            return(new AzurePipelinesVariable(ParameterService.GetParameterMemberName(member),
                                              member.GetMemberType().IsArray&& defaultValue is IEnumerable enumerable
                ? enumerable.Cast <object>().Select(x => x.ToString()).Join(valueSeparator)
                : defaultValue?.ToString()));
        }