Revision: 264
Author: azizatif
Date: Tue Feb 2 14:46:14 2010
Log: Updated ConsoleFizzler to use string extensions from Mannex.
http://code.google.com/p/fizzler/source/detail?r=264
Modified:
/trunk/ConsoleFizzler/CommandLine.cs
/trunk/ConsoleFizzler/ConsoleFizzler.csproj
/trunk/ConsoleFizzler/StringExtensions.cs
=======================================
--- /trunk/ConsoleFizzler/CommandLine.cs Tue Feb 2 14:28:39 2010
+++ /trunk/ConsoleFizzler/CommandLine.cs Tue Feb 2 14:46:14 2010
@@ -1,4 +1,6 @@
-namespace ConsoleFizzler
+using Mannex;
+
+namespace ConsoleFizzler
{
#region Imports
@@ -106,10 +108,10 @@
// Allows `arg=value` or `arg:value` style.
var paired = name.IndexOfAny(_argSeparators) > 0;
- var pair = name.SplitPair(_argSeparators);
+ var pair = name.Split(_argSeparators, (n, v) => new { Name
= n, Value = v });
if (paired)
- name = pair.Key; // Break the name out of the pair
+ name = pair.Name; // Break the name out of the pair
// Get setting property from name.
=======================================
--- /trunk/ConsoleFizzler/ConsoleFizzler.csproj Wed May 20 02:18:25 2009
+++ /trunk/ConsoleFizzler/ConsoleFizzler.csproj Tue Feb 2 14:46:14 2010
@@ -3,7 +3,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)'
== '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.21022</ProductVersion>
+ <ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{296C2824-A7D7-42A0-9B4C-1BC8FA0A1859}</ProjectGuid>
<OutputType>Exe</OutputType>
@@ -36,6 +36,10 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Libs\HtmlAgilityPack.dll</HintPath>
</Reference>
+ <Reference Include="Mannex, Version=1.0.12026.0, Culture=neutral,
processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\Libs\Mannex.dll</HintPath>
+ </Reference>
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Core">
=======================================
--- /trunk/ConsoleFizzler/StringExtensions.cs Tue Feb 2 14:28:39 2010
+++ /trunk/ConsoleFizzler/StringExtensions.cs Tue Feb 2 14:46:14 2010
@@ -2,66 +2,12 @@
{
#region Imports
- using System;
- using System.Collections.Generic;
using System.Globalization;
#endregion
static class StringExtensions
{
- /// <summary>
- /// Splits a string into a key and a value part using a specified
- /// character to separate the two.
- /// </summary>
- /// <remarks>
- /// The key or value of the resulting pair is never <c>null</c>.
- /// </remarks>
-
- public static KeyValuePair<string, string> SplitPair(this string
str, char separator)
- {
- if (str == null) throw new ArgumentNullException("str");
-
- return SplitPair(str, str.IndexOf(separator), 1);
- }
-
- /// <summary>
- /// Splits a string into a key and a value part using any of a
- /// specified set of characters to separate the two.
- /// </summary>
- /// <remarks>
- /// The key or value of the resulting pair is never <c>null</c>.
- /// </remarks>
-
- public static KeyValuePair<string, string> SplitPair(this string
str, params char[] separators)
- {
- if (str == null) throw new ArgumentNullException("str");
-
- return separators == null || separators.Length == 0
- ? new KeyValuePair<string, string>(str,
string.Empty)
- : SplitPair(str, str.IndexOfAny(separators), 1);
- }
-
- /// <summary>
- /// Splits a string into a key and a value part by removing a
- /// portion of the string.
- /// </summary>
- /// <remarks>
- /// The key or value of the resulting pair is never <c>null</c>.
- /// </remarks>
-
- public static KeyValuePair<string, string> SplitPair(this string
str, int index, int count)
- {
- if (str == null) throw new ArgumentNullException("str");
- if (count <= 0) throw new ArgumentOutOfRangeException("count",
count, null);
-
- return new KeyValuePair<string, string>(
- /* key */ index < 0 ? str : str.Substring(0, index),
- /* value */ index < 0 || index + 1 >=
str.Length
- ? string.Empty
- : str.Substring(index
+ count));
- }
-
/// <summary>
/// Converts the specified string to titlecase using the invariant
culture.
/// </summary>