本文整理汇总了C#中System.Collections.Specialized.StringDictionary.ContainsKey方法的典型用法代码示例。如果您正苦于以下问题:C# StringDictionary.ContainsKey方法的具体用法?C# StringDictionary.ContainsKey怎么用?C# StringDictionary.ContainsKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Specialized.StringDictionary
的用法示例。
在下文中一共展示了StringDictionary.ContainsKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Arguments
public Arguments(string[] args)
{
_params = new StringDictionary();
Regex spliter = new Regex(@"^-{1,2}|^/|=|:", RegexOptions.IgnoreCase | RegexOptions.Compiled);
Regex remover = new Regex(@"^['""]?(.*?)['""]?$", RegexOptions.IgnoreCase | RegexOptions.Compiled);
string parm = null;
string[] parts;
foreach (var a in args)
{
parts = spliter.Split(a, 3);
switch (parts.Length)
{
case 1:
if (parm != null)
{
if (!_params.ContainsKey(parm))
{
parts[0] = remover.Replace(parts[0], "$1");
_params.Add(parm, parts[0]);
}
parm = null;
}
break;
case 2:
if (parm != null)
{
if (!_params.ContainsKey(parm))
_params.Add(parm, "true");
}
parm = parts[1];
break;
case 3:
if (parm != null)
{
if (!_params.ContainsKey(parm))
_params.Add(parm, "true");
}
parm = parts[1];
if (!_params.ContainsKey(parm))
{
parts[2] = remover.Replace(parts[2], "$1");
_params.Add(parm, parts[2]);
}
parm = null;
break;
}
}
if (parm != null)
{
if (!_params.ContainsKey(parm))
_params.Add(parm, "true");
}
}
示例2: Arguments
// Constructor
public Arguments(string[] Args)
{
Parameters=new StringDictionary();
Regex Spliter=new Regex(@"^-{1,2}|^/|=|:",RegexOptions.IgnoreCase|RegexOptions.Compiled);
Regex Remover= new Regex(@"^['""]?(.*?)['""]?$",RegexOptions.IgnoreCase|RegexOptions.Compiled);
string Parameter=null;
string[] Parts;
// Valid parameters forms:
// {-,/,--}param{ ,=,:}((",')value(",'))
// Examples: -param1 value1 --param2 /param3:"Test-:-work" /param4=happy -param5 '--=nice=--'
foreach(string Txt in Args){
// Look for new parameters (-,/ or --) and a possible enclosed value (=,:)
Parts=Spliter.Split(Txt,3);
switch(Parts.Length){
// Found a value (for the last parameter found (space separator))
case 1:
if(Parameter!=null){
if(!Parameters.ContainsKey(Parameter)){
Parts[0]=Remover.Replace(Parts[0],"$1");
Parameters.Add(Parameter,Parts[0]);
}
Parameter=null;
}
// else Error: no parameter waiting for a value (skipped)
break;
// Found just a parameter
case 2:
// The last parameter is still waiting. With no value, set it to true.
if(Parameter!=null){
if(!Parameters.ContainsKey(Parameter)) Parameters.Add(Parameter,"true");
}
Parameter=Parts[1];
break;
// Parameter with enclosed value
case 3:
// The last parameter is still waiting. With no value, set it to true.
if(Parameter!=null){
if(!Parameters.ContainsKey(Parameter)) Parameters.Add(Parameter,"true");
}
Parameter=Parts[1];
// Remove possible enclosing characters (",')
if(!Parameters.ContainsKey(Parameter)){
Parts[2]=Remover.Replace(Parts[2],"$1");
Parameters.Add(Parameter,Parts[2]);
}
Parameter=null;
break;
}
}
// In case a parameter is still waiting
if(Parameter!=null){
if(!Parameters.ContainsKey(Parameter)) Parameters.Add(Parameter,"true");
}
}
示例3: TestComplexKeepOldJoininUri
public void TestComplexKeepOldJoininUri()
{
Uri source = new Uri( "http://www.localhost.name/path/page?query=value¶m=values" );
string pathAndQuery = "/otherpath/otherpage?newquery=newvalue¶m=othervalue";
Uri result = new Uri( source, pathAndQuery );
StringDictionary queryParameters = new StringDictionary();
// add the new parameters
foreach (string parameter in result.Query.Trim("?&".ToCharArray()).Split("&".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
{
string name = parameter.Split("=".ToCharArray())[0];
string value = parameter.Substring(name.Length + 1);
if (queryParameters.ContainsKey(name)) // do not duplicate a parameter, keep last value
{
queryParameters[name] = value;
}
else
{
queryParameters.Add(name, value);
}
}
// keep the original set
foreach ( string parameter in source.Query.Trim( "?&".ToCharArray() ).Split( "&".ToCharArray(), StringSplitOptions.RemoveEmptyEntries ) )
{
string name = parameter.Split( "=".ToCharArray() )[0];
string value = parameter.Substring( name.Length + 1 );
if ( queryParameters.ContainsKey( name ) ) // do not duplicate a parameter, keep last original value
{
queryParameters[name] = value;
}
else
{
queryParameters.Add( name, value );
}
}
// recreate the uri
result = new Uri(result.GetLeftPart(UriPartial.Path));
StringBuilder query = new StringBuilder();
foreach (string key in queryParameters.Keys)
{
if (query.Length > 0)
{
query.AppendFormat("&{0}={1}", key, queryParameters[key]);
}
else
{
query.AppendFormat( "?{0}={1}", key, queryParameters[key] );
}
}
result = new Uri(result.ToString() + query.ToString());
Debug.WriteLine( "Complex Join Maintain Original " + result );
}
示例4: Configure
public new void Configure(StringDictionary attributes)
{
base.Configure(attributes);
if (attributes.ContainsKey("XPathNamespace"))
{
XPathNamespace = attributes["XPathNamespace"];
}
if (attributes.ContainsKey("XPath"))
{
XPath = attributes["XPath"];
}
}
示例5: Configure
public void Configure(StringDictionary attributes)
{
if (attributes.ContainsKey("SharePointVersions"))
{
sharePointVersions = attributes["SharePointVersions"];
}
if (attributes.ContainsKey("NotSandboxSupported"))
{
try
{
notSandboxSupported = Boolean.Parse(attributes["NotSandboxSupported"]);
}
catch { }
}
}
开发者ID:sunday-out,项目名称:SharePoint-Software-Factory,代码行数:15,代码来源:SharePointVersionDependendReferenceTemplate.cs
示例6: OnNext
public override bool OnNext()
{
if (this._saveCheckBox.Checked)
{
ICollection connections = this._dataEnvironment.Connections;
StringDictionary dictionary = new StringDictionary();
foreach (DesignerDataConnection connection in connections)
{
if (connection.IsConfigured)
{
dictionary.Add(connection.Name, null);
}
}
if (dictionary.ContainsKey(this._nameTextBox.Text))
{
UIServiceHelper.ShowError(base.ServiceProvider, System.Design.SR.GetString("SqlDataSourceSaveConfiguredConnectionPanel_DuplicateName", new object[] { this._nameTextBox.Text }));
this._nameTextBox.Focus();
return false;
}
}
WizardPanel panel = SqlDataSourceConnectionPanel.CreateCommandPanel((SqlDataSourceWizardForm) base.ParentWizard, this._dataConnection, base.NextPanel);
if (panel == null)
{
return false;
}
base.NextPanel = panel;
return true;
}
开发者ID:Reegenerator,项目名称:Sample-CustomizeDatasetCS,代码行数:28,代码来源:SqlDataSourceSaveConfiguredConnectionPanel.cs
示例7: Args
public Args(string[] args)
{
argDict = new StringDictionary();
Regex regEx = new Regex(@"^-", RegexOptions.IgnoreCase | RegexOptions.Compiled);
Regex regTrim = new Regex(@"^['""]?(.*?)['""]?$", RegexOptions.IgnoreCase | RegexOptions.Compiled);
string arg = "";
string[] chunks;
foreach (string s in args)
{
chunks = regEx.Split(s, 3);
if (regEx.IsMatch(s))
{
arg = chunks[1];
argDict.Add(arg, "true");
}
else
{
if (argDict.ContainsKey(arg))
{
chunks[0] = regTrim.Replace(chunks[0], "$1");
argDict.Remove(arg);
argDict.Add(arg, chunks[0]);
arg = "";
}
}
}
}
示例8: Format
/// <summary>
/// Replaces one or more placeholders in a string with the specified values.
/// </summary>
/// <param name="format">The composite format string.</param>
/// <param name="args">
/// A string dictionary containing the placeholder names and values that
/// they are to be replaced with.
/// </param>
/// <param name="date">
/// A <see cref="DateTime"/> object to format dates and times with.
/// </param>
/// <returns>
/// A new string with the placeholders replaced by their values.
/// </returns>
public static string Format(string format, StringDictionary args,
DateTime date)
{
if (format == null) return null;
if (args == null) return format;
var stringBuilder = new StringBuilder(format.Length);
var i = 0;
var c = '\0';
while (i < format.Length)
{
c = format[i];
i++;
if (c == PlaceholderStart)
{
var end = format.IndexOf(PlaceholderEnd, i);
if (end <= i)
{
var message = SR.ExpectedAtPos.With(PlaceholderEnd, i);
throw new FormatException(message);
}
var placeholder = format.Substring(i, end - i);
var value = args[placeholder];
if (!args.ContainsKey(placeholder))
{
try
{
value = date.ToString(placeholder);
}
catch (Exception ex)
{
var message = SR.InvalidPlaceholder.With(placeholder);
throw new FormatException(message, ex);
}
}
stringBuilder.Append(RemoveInvalidFilenameChars(value));
i = end + 1;
}
else if (c == PlaceholderEscape)
{
if (i >= format.Length)
{
var message = SR.EndOfString.With(PlaceholderEscape);
throw new FormatException(message);
}
stringBuilder.Append(format[i]);
i++;
}
else
{
stringBuilder.Append(c);
}
}
return stringBuilder.ToString();
}
示例9: Configure
public void Configure(StringDictionary attributes)
{
if (!attributes.ContainsKey("Values"))
{
throw new ArgumentException("Attribute Values is missing in Converter");
}
this.values = attributes["Values"];
}
示例10: GetOrCreateProperty
private static String GetOrCreateProperty(StringDictionary bag, String key)
{
if (!bag.ContainsKey(key))
{
bag.Add(key, Constants.DefaultVersionMinor);
}
return bag[key];
}
示例11: Configure
public new void Configure(StringDictionary attributes)
{
base.Configure(attributes);
if (attributes.ContainsKey("FeatureScopes"))
{
FeatureScopes = attributes["FeatureScopes"];
}
}
示例12: This_Empty
public void This_Empty ()
{
StringDictionary sd = new StringDictionary ();
sd[String.Empty] = null;
Assert.IsNull (sd[String.Empty], "this[String.Empty]");
Assert.AreEqual (1, sd.Count, "Count-1");
Assert.IsTrue (sd.ContainsKey (String.Empty), "ContainsKey");
Assert.IsTrue (sd.ContainsValue (null), "ContainsValue");
}
示例13: GetExistDataItem
/// <summary>
/// 数据存在检查(主键重复)
/// </summary>
/// <param name="TableName">数据表名称</param>
/// <param name="dicItemData">数据内容</param>
/// <param name="dicPrimarName">主键列名</param>
/// <returns></returns>
public bool GetExistDataItem(String TableName,
StringDictionary dicItemData,
StringDictionary dicPrimarName)
{
bool IsExist = false;
DataTable dt = new DataTable();
int rowIndex = 0;
SqlParameter[] cmdParamters = null;
SqlParameter SqlParameter = null;
string w_strWhere = "";
try
{
if (dicItemData == null || dicItemData.Count <= 0
|| dicPrimarName == null || dicPrimarName.Count <= 0) return false ;
string strSql = "SELECT CAST('0' AS Bit) AS SlctValue," + TableName + ".* "
+ " FROM " + TableName
+ " WHERE 1=1 ";
Common.AdoConnect.Connect.ConnectOpen();
cmdParamters = new SqlParameter[dicPrimarName.Count];
foreach (string strKey in dicPrimarName.Keys)
{
if (dicItemData.ContainsKey(strKey) == true)
{
w_strWhere += " AND " + strKey + "[email protected]" + strKey;
SqlParameter = new SqlParameter("@" + strKey, DataFiledType.FiledType[strKey]);
SqlParameter.Value = dicItemData[strKey];
SqlParameter.Direction = ParameterDirection.Input;
cmdParamters[rowIndex] = SqlParameter;
rowIndex++;
}
}
strSql += w_strWhere;
dt = Common.AdoConnect.Connect.GetDataSet(strSql, cmdParamters);
if (dt != null)
{
if (dt.Rows.Count>0)
IsExist = true;
}
return IsExist;
}
catch (Exception ex)
{
throw ex;
}
}
示例14: UpdateFromDomain
/// <summary>
/// Adds any errors from the domain to the view model.
/// </summary>
/// <param name="currentState">The model state dictionary to update.</param>
/// <param name="result">The result from the domain validation, which contains any errors that occurred in the domain validation.</param>
/// <param name="mappingFromDomainToUi">Provides a set of mappings that map the propeties of a domain object to those of a view model object.</param>
public static void UpdateFromDomain(this ModelStateDictionary currentState, ValidationResult result, StringDictionary mappingFromDomainToUi)
{
foreach (var message in result.Messages)
{
var propertyName = message.PropertyName;
if (mappingFromDomainToUi.ContainsKey(message.PropertyName))
propertyName = mappingFromDomainToUi[message.PropertyName];
currentState.AddModelError(propertyName, message.Message);
}
}
示例15: Parse
public OperationModel Parse(string[] args)
{
var methodName = args[0].Replace("-", "");
var parameters = new StringDictionary();
var spliter = new Regex(@"^-{1,2}|^/|=|:", RegexOptions.IgnoreCase | RegexOptions.Compiled);
var remover = new Regex(@"^['""]?(.*?)['""]?$", RegexOptions.IgnoreCase | RegexOptions.Compiled);
string parameter = null;
foreach (string txt in args)
{
string[] parts = spliter.Split(txt, 3);
switch (parts.Length)
{
case 1:
if (parameter != null)
{
if (!parameters.ContainsKey(parameter))
{
parts[0] = remover.Replace(parts[0], "$1");
parameters.Add(parameter, parts[0]);
}
parameter = null;
}
break;
case 2:
if (parameter != null)
{
if (!parameters.ContainsKey(parameter))
parameters.Add(parameter, "true");
}
parameter = parts[1];
break;
}
}
OperationNameEnum operation;
Enum.TryParse(methodName, out operation);
return MapParameters(parameters, operation);
}