Esempio n. 1
0
        public virtual string Description(string text)
        {
            string wrappedText = WrapText(text, LINE_LENGTH);

            if (_namedArgs.Count == 0)
            {
                return(wrappedText);
            }

            wrappedText = string.join(_newline + _newline, wrappedText, "options:");

            //noinspection OptionalGetWithoutIsPresent handled by if-statement above
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int alignLength = namedArgs.values().stream().map(a -> a.optionsListing().length()).reduce(0, System.Nullable<int>::max);
            int alignLength = _namedArgs.Values.Select(a => a.optionsListing().length()).Aggregate(0, int?.max);

//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            return(string.join(_newline, wrappedText, _namedArgs.Values.Select(c => FormatArgumentDescription(alignLength, c)).collect(Collectors.joining(_newline))));
        }
Esempio n. 2
0
        /// <summary>
        /// Original line-endings in the text are respected.
        /// </summary>
        /// <param name="text"> to wrap </param>
        /// <param name="lineLength"> no line will exceed this length </param>
        /// <returns> the text where no line exceeds the specified length </returns>
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: public static String wrapText(final String text, final int lineLength)
        public static string WrapText(string text, int lineLength)
        {
            IList <string> lines = Arrays.asList(text.Split("\r?\n", true));

//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            return(lines.Select(l => l.length() > lineLength ? WordUtils.wrap(l, lineLength) : l).collect(Collectors.joining(_newline)));
        }
Esempio n. 3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private static String read(String input) throws IOException
        private static string read(string input)
        {
            using (System.IO.StreamReader buffer = new System.IO.StreamReader(new System.IO.FileStream(input, System.IO.FileMode.Open, System.IO.FileAccess.Read)))
            {
                return(buffer.lines().filter(l => !l.Trim().StartsWith("//")).filter(l => !l.Trim().StartsWith("#")).collect(Collectors.joining("\n")));                //ignore comment -  ignore comment
            }
        }