本文整理汇总了C#中IParameterCollection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# IParameterCollection.Add方法的具体用法?C# IParameterCollection.Add怎么用?C# IParameterCollection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IParameterCollection
的用法示例。
在下文中一共展示了IParameterCollection.Add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
/// <summary>
/// Parse a query string
/// </summary>
/// <param name="reader">string to parse</param>
/// <param name="parameters">Parameter collection to fill</param>
/// <returns>A collection</returns>
/// <exception cref="ArgumentNullException"><c>reader</c> is <c>null</c>.</exception>
public void Parse(TextReader reader, IParameterCollection parameters)
{
if (reader == null)
throw new ArgumentNullException("reader");
var canRun = true;
while (canRun)
{
var result = reader.ReadToEnd("&=");
var name = Uri.UnescapeDataString(result.Value);
switch (result.Delimiter)
{
case '&':
parameters.Add(name, string.Empty);
break;
case '=':
result = reader.ReadToEnd("&");
parameters.Add(name, Uri.UnescapeDataString(result.Value));
break;
case char.MinValue:
// EOF = no delimiter && no value
if (!string.IsNullOrEmpty(name))
parameters.Add(name, string.Empty);
break;
}
canRun = result.Delimiter != char.MinValue;
}
}
示例2: Parse
public void Parse(string value, IParameterCollection target)
{
int index = 0;
var lastCh = char.MinValue;
var name = "";
int oldPos = 0;
while (index < value.Length)
{
var ch = value[index];
switch (ch)
{
case '=':
if (lastCh != '\\')
{
name = value.Substring(oldPos, index - oldPos).Trim(' ');
oldPos = index + 1;
}
break;
case ',':
if (lastCh != '\\')
{
target.Add(name, value.Substring(oldPos, index - oldPos).Trim(' ', '"'));
oldPos = index + 1;
}
break;
}
lastCh = value[index];
++index;
}
}
示例3: Parse
/// <summary>
/// Parse string
/// </summary>
/// <param name="value">contains "a=b,c=d" etc</param>
/// <param name="target">Collection to fill with the values</param>
public void Parse(string value, IParameterCollection target)
{
if (value == null) throw new ArgumentNullException("value");
if (target == null) throw new ArgumentNullException("target");
var index = 0;
var lastCh = char.MinValue;
var name = "";
var oldPos = 0;
while (index < value.Length)
{
var ch = value[index];
switch (ch)
{
case '=':
if (lastCh != '\\')
{
name = value.Substring(oldPos, index - oldPos).Trim(' ');
oldPos = index + 1;
}
break;
case ',':
if (lastCh != '\\')
{
target.Add(name, value.Substring(oldPos, index - oldPos).Trim(' ', '"'));
name = "";
oldPos = index + 1;
}
break;
}
lastCh = value[index];
++index;
}
if (name != "")
{
target.Add(name, value.Substring(oldPos).Trim(' ', '"'));
}
}