本文整理汇总了C#中this.ContainsKey方法的典型用法代码示例。如果您正苦于以下问题:C# this.ContainsKey方法的具体用法?C# this.ContainsKey怎么用?C# this.ContainsKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类this
的用法示例。
在下文中一共展示了this.ContainsKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToItem
public static Item ToItem(this JsonObject jo)
{
var category = jo.GetNamedString("category", "");
var icon = jo.GetNamedString("icon", "");
var label = jo.GetNamedString("label", "");
var type = jo.GetNamedString("type", "");
var name = jo.GetNamedString("name", "");
var link = jo.GetNamedString("link", "");
var state = jo.GetNamedString("state", "");
var stateDescription = jo.GetNamedObject("stateDescription", null).ToStateDescription();
var tags = new string[0];
var groupNames = new string[0];
if (jo.ContainsKey("tags"))
{
tags = jo.GetNamedArray("tags").Select(j => j.GetString()).ToArray();
}
if (jo.ContainsKey("groupNames"))
{
groupNames = jo.GetNamedArray("groupNames").Select(j => j.GetString()).ToArray();
}
return new Item(link, name, state, type)
.SetStateDescription(stateDescription)
.SetCategory(category)
.SetIcon(icon)
.SetLabel(label)
.SetGroupNames(groupNames)
.SetTags(tags);
}
示例2: a
public static NSAction a(this JsonObject json, JsonDialogViewController dvc){
if (json!=null && json.ContainsKey("navigateto") && json.ContainsKey("action")) {
string file = json["navigateto"];
string action = json["action"];
return ()=>{
dvc.InvokeAction(action, new object[]{file});
};
}
if (json.ContainsKey("navigateto")) {
string file = json["navigateto"];
return ()=>{
dvc.NavigateTo(file);
};
}
if (json.ContainsKey("action")) {
return ()=>{
dvc.InvokeAction(json["action"], new Element("adf"));
};
}
return null;
}
示例3: MergeAttributes
public static IDictionary<string, object> MergeAttributes(this IDictionary<string, object> @this,
IDictionary<string, object> toMerge,
bool replace = false)
{
foreach(var pair in toMerge)
{
string key = Convert.ToString(pair.Key, CultureInfo.InvariantCulture);
string val = Convert.ToString(pair.Value, CultureInfo.InvariantCulture);
if(string.IsNullOrEmpty(key))
{
throw new ArgumentException("Key cannot be null or empty", "key");
}
if(replace || [email protected](key))
{
@this[key] = val;
}
else if(@this.ContainsKey(key))
{
// combine - works great for css classes, but can cause issues with data-* and others (like double readonly)
@this[key] = @this[key] + " " + val;
}
}
return @this;
}
示例4: GetContentLength
public static int GetContentLength(this IDictionary<string, string> headers)
{
int contentLength = -1;
// ugly. we need to decide in one spot whether or not we're case-sensitive for all headers.
if (headers.ContainsKey("Content-Length"))
int.TryParse(headers["Content-Length"], out contentLength);
else if (headers.ContainsKey("Content-length"))
int.TryParse(headers["Content-length"], out contentLength);
else if (headers.ContainsKey("content-length"))
int.TryParse(headers["content-length"], out contentLength);
return contentLength;
}
示例5: AddCard
public static void AddCard(this IDictionary<string, ActivityRepository.ActivityList> lists, string listId, ActivityRepository.ActivityCard card)
{
if (lists.ContainsKey(listId))
{
lists[listId].AddCard(card);
}
}
示例6: AddOrReplace
public static void AddOrReplace(this RouteValueDictionary dictionary, string key, object value)
{
if (dictionary.ContainsKey(key))
dictionary[key] = value;
else
dictionary.Add(key, value);
}
示例7: GetDoubleValue
public static double? GetDoubleValue(this JsonObject jsonObject, string key)
{
IJsonValue value;
double? returnValue = null;
double parsedValue;
if (jsonObject.ContainsKey(key))
{
if (jsonObject.TryGetValue(key, out value))
{
if (value.ValueType == JsonValueType.String)
{
if (double.TryParse(jsonObject.GetNamedString(key), out parsedValue))
{
returnValue = parsedValue;
}
}
else if (value.ValueType == JsonValueType.Number)
{
returnValue = jsonObject.GetNamedNumber(key);
}
}
}
return returnValue;
}
示例8: TryGet
public static object TryGet(this Hashtable hashtable, object key, object notFound){
if (hashtable == null) return notFound;
if (hashtable.ContainsKey(key)){
return hashtable[key];
}
return notFound;
}
示例9: AddHashtable
public static void AddHashtable(this Hashtable hash, Hashtable addHash, bool overwriteExistingKeys)
{
ICollection keyColl = addHash.Keys;
foreach(string key in keyColl) {
if(overwriteExistingKeys || (!hash.ContainsKey(key))) hash[key] = addHash[key];
}
}
示例10: Merge
/// <summary>
/// Merges the specified instance.
/// </summary>
/// <param name="instance">The instance.</param>
/// <param name="key">The key.</param>
/// <param name="value">The value.</param>
/// <param name="replaceExisting">if set to <c>true</c> [replace existing].</param>
public static void Merge(this IDictionary<string, object> instance, string key, object value, bool replaceExisting)
{
if (replaceExisting || !instance.ContainsKey(key))
{
instance[key] = value;
}
}
示例11: TimeSent
public static DateTime TimeSent(this IDictionary<string, string> headers)
{
if (!headers.ContainsKey(TimeSentHeader))
return DateTime.MinValue;
return headers[TimeSentHeader].ToUtcDateTime();
}
示例12: ProcessingStarted
public static DateTime ProcessingStarted(this IDictionary<string, string> headers)
{
if (!headers.ContainsKey(ProcessingStartedHeader))
return DateTime.MinValue;
return headers[ProcessingStartedHeader].ToUtcDateTime();
}
示例13: GetComponentLinkedValue
public static string GetComponentLinkedValue(this IFieldSet fields, string schemaFieldName, bool isLinkedFieldMetadata, string componentFieldName)
{
if (fields.ContainsKey(schemaFieldName))
{
if (fields[schemaFieldName].LinkedComponentValues.Count > 0)
{
var linkedComponent = fields[schemaFieldName].LinkedComponentValues[0];
if (isLinkedFieldMetadata)
{
if (linkedComponent.MetadataFields.ContainsKey(componentFieldName))
{
return linkedComponent.MetadataFields.GetValue(componentFieldName);
}
}
else
{
if (linkedComponent.Fields.ContainsKey(componentFieldName))
{
return linkedComponent.Fields.GetValue(componentFieldName);
}
}
}
}
return string.Empty;
}
示例14: AddUnique
public static void AddUnique(this Dictionary<string, string> dictionary, string key, string value)
{
if (!dictionary.ContainsKey(key))
{
dictionary.Add(key, value);
}
}
示例15: GetBrainTreeProviderSettings
/// <summary>
/// Utility extension the deserializes BraintreeProviderSettings from the ExtendedDataCollection
/// </summary>
/// <param name="extendedData">
/// The extended data.
/// </param>
/// <returns>
/// The <see cref="BraintreeProviderSettings"/>.
/// </returns>
public static BraintreeProviderSettings GetBrainTreeProviderSettings(this ExtendedDataCollection extendedData)
{
return extendedData.ContainsKey(Constants.ExtendedDataKeys.BraintreeProviderSettings)
? JsonConvert.DeserializeObject<BraintreeProviderSettings>(
extendedData.GetValue(Constants.ExtendedDataKeys.BraintreeProviderSettings))
: new BraintreeProviderSettings();
}