当前位置: 首页>>代码示例>>C#>>正文


C# this.ContainsKey方法代码示例

本文整理汇总了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);
        }
开发者ID:altima,项目名称:openhabUWP,代码行数:33,代码来源:openhabFluent.cs

示例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;
			
		}
开发者ID:escoz,项目名称:MonoMobile.Forms,代码行数:26,代码来源:JsonObjectExtensions.cs

示例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;
        }
开发者ID:Gutek,项目名称:MVC-3-Html5EditorFor,代码行数:27,代码来源:DictionaryExtensions.cs

示例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;
        }
开发者ID:nithinphilips,项目名称:bbwifimusicsync,代码行数:14,代码来源:Http.cs

示例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);
     }
 }
开发者ID:kvnallen,项目名称:trello-cfd,代码行数:7,代码来源:ActivityRepository.cs

示例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);
 }
开发者ID:beardeddev,项目名称:shamrock,代码行数:7,代码来源:RouteValueDictionaryExtensions.cs

示例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;
        }
开发者ID:craigshoemaker,项目名称:ParseJSONInWindowStore,代码行数:26,代码来源:JsonObjectExtensions.cs

示例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;
	}
开发者ID:steampunkrpg,项目名称:steampunk-rpg-main,代码行数:7,代码来源:HashtableExt.cs

示例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];
     }
 }
开发者ID:abdelazizbenyahia,项目名称:StandExpo,代码行数:7,代码来源:CollectionExtensions.cs

示例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;
     }
 }
开发者ID:hxhlb,项目名称:EasyUI.Mvc,代码行数:14,代码来源:DictionaryExtensions.cs

示例11: TimeSent

        public static DateTime TimeSent(this IDictionary<string, string> headers)
        {
            if (!headers.ContainsKey(TimeSentHeader))
                return DateTime.MinValue;

            return headers[TimeSentHeader].ToUtcDateTime();
        }
开发者ID:northshoreab,项目名称:Hygia,代码行数:7,代码来源:HeaderExtensions.cs

示例12: ProcessingStarted

        public static DateTime ProcessingStarted(this IDictionary<string, string> headers)
        {
            if (!headers.ContainsKey(ProcessingStartedHeader))
                return DateTime.MinValue;

            return headers[ProcessingStartedHeader].ToUtcDateTime();
        }
开发者ID:northshoreab,项目名称:Hygia,代码行数:7,代码来源:HeaderExtensions.cs

示例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;
 }
开发者ID:rsleggett,项目名称:BuildingBlocks.DD4T.MarkupModels,代码行数:25,代码来源:IFieldSetExtensionMethods.cs

示例14: AddUnique

 public static void AddUnique(this Dictionary<string, string> dictionary, string key, string value)
 {
     if (!dictionary.ContainsKey(key))
     {
         dictionary.Add(key, value);
     }
 }
开发者ID:barrett2474,项目名称:CMS2,代码行数:7,代码来源:ExtensionMethods.cs

示例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();
 }
开发者ID:GaryLProthero,项目名称:Merchello,代码行数:16,代码来源:MappingExtensions.cs


注:本文中的this.ContainsKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。