public static Dictionary<string, string> CreateTagDictionary(Hashtable tags, bool validate) { Dictionary<string, string> tagDictionary = null; if (tags != null) { tagDictionary = new Dictionary<string, string>(); PSTagValuePair tvPair = new PSTagValuePair(); foreach(DictionaryEntry entry in tags) { tvPair.Name = entry.Key.ToString(); if (entry.Value != null) { tvPair.Value = entry.Value.ToString(); } else { tvPair.Value = string.Empty; } tagDictionary[tvPair.Name] = tvPair.Value; } } if (validate) { if (tags != null && tags.Count > 0 && (tagDictionary == null || tagDictionary.Count == 0)) { throw new ArgumentException(ProjectResources.InvalidTagFormat); } } return tagDictionary; }
public static Dictionary<string, string> CreateTagDictionary(Hashtable tags, bool validate) { Dictionary<string, string> tagDictionary = null; if (tags != null) { tagDictionary = new Dictionary<string, string>(); PSTagValuePair tvPair = new PSTagValuePair(); foreach(DictionaryEntry entry in tags) { tvPair.Name = entry.Key.ToString(); if (entry.Value != null) { tvPair.Value = entry.Value.ToString(); } else { tvPair.Value = string.Empty; } tagDictionary[tvPair.Name] = tvPair.Value; } } if (validate) { if (tags != null && tags.Count > 0 && (tagDictionary == null || tagDictionary.Count == 0)) { throw new ArgumentException(ProjectResources.InvalidTagFormat); } } return tagDictionary; }
public static PSTagValuePair Create(Hashtable hashtable) { if (hashtable == null) { return null; } IDictionaryEnumerator ide = hashtable.GetEnumerator(); PSTagValuePair tagValuePair = new PSTagValuePair(); if(ide.MoveNext()) { DictionaryEntry entry = (DictionaryEntry) ide.Current; tagValuePair.Name = entry.Key.ToString(); if(entry.Value != null) { tagValuePair.Value = entry.Value.ToString(); } } return tagValuePair; }
public static PSTagValuePair Create(Hashtable hashtable) { if (hashtable == null) { return null; } IDictionaryEnumerator ide = hashtable.GetEnumerator(); PSTagValuePair tagValuePair = new PSTagValuePair(); if(ide.MoveNext()) { DictionaryEntry entry = (DictionaryEntry) ide.Current; tagValuePair.Name = entry.Key.ToString(); if(entry.Value != null) { tagValuePair.Value = entry.Value.ToString(); } } return tagValuePair; }