Classes that extend PatternConverter expose the value passed into the
pattern:
%foo{valuePassedIntoThePattern}
as a property called Option. If someone wants to pass in more than one
value they are responsible for parsing the string using their own
delimiters:
%foo{valuePassedIntoThePattern,secondValue,thirdValue}
%foo{valuePassedIntoThePattern:secondValue:thirdValue}
%foo{valuePassedIntoThePattern|secondValue|thirdValue}
Perhaps we could use the following notation to help the user deal with
multiple values being passed in:
%foo{valuePassedIntoThePattern}{secondValue}{thirdValue}
We would introduce another property on PatternConverter called Options
which would be a string array of all the values passed into the
pattern. The index would be the matching index of the value passed in.
We would still keep Option for quick reference:
public virtual string Option
{
get { return m_option; }
set { m_option = value; }
}
public virtual string[] Options
{
get { return m_options; }
set { m_options = value; }
}
Assert.AreEqual(Options, Options[0]);
This would make it very easy to write a FormatPropertyPatternConverter
that accepted a format as an optional 2nd parameter:
%property{InvoiceAmount}{##.##}
Deep within PatternConverter you could replace this code:
writer.Write( value.ToString() );
with this:
if (values.Count == 2)
{
writer.Write(values[1], values[0] );
}
else
{
writer.Write( values[0] );
}
Comments?
- Ron