nant / nantcontrib

NAntContrib is the project for tasks and tools that haven't made it into the main NAnt distribution yet or for whatever reason don't belong there.
nantcontrib.sourceforge.net
GNU Lesser General Public License v2.1
51 stars 35 forks source link

reverse a string list #16

Closed messkat closed 12 years ago

messkat commented 12 years ago

Something like this, so we don't have to code it in C#. Useful if you have to stop and start services or deploy something in a particular order.

  <script language="C#">
<code><![CDATA[
    public static void ScriptMain(Project project) 
    {
                string str = project.Properties["original.string"];
                String[] myList = str.Split(',');
                Array.Reverse(myList);
                project.Properties["original.string.reverse"] = String.Join(",", myList);
    }
  ]]>
</code>
  </script>
rmboggs commented 12 years ago

Yeah, I can see value here. I can see this become a function. Should probably create an "Array" function set in the process. While here, might as well add a sort function.

rmboggs commented 12 years ago

Committed feature. You can now use array::reverse(array, separator) function in NAntContrib to accomplish your request. Like so:

<project>
    <property name='array.orig' value='four,nine,six,two,zero,one' />
    <property name='array.reverse' value='${array::reverse(array.orig,',')}' />
    <echo message='array.reverse=${array.reverse}' /> 
</project>

This will print out: "array.reverse=one,zero,two,six,nine,four"

messkat commented 12 years ago

Thanks! You will break me of my dependency on Perl

Ryan Boggs reply@reply.github.com wrote:

Committed feature. You can now use array::reverse(array, separator) function in NAntContrib to accomplish your request. Like so:

This will print out: "array.reverse=one,zero,two,six,nine,four"


Reply to this email directly or view it on GitHub: https://github.com/nant/nantcontrib/issues/16#issuecomment-4361421

rmboggs commented 12 years ago

No problem, it was a good suggestion. Thanks again.

BTW, the commit is here: f052a9b20af742f6a2c7bb614e7b67a49e49b3bb