TMXGlueLib.TiledMapSave.BuildPropertyDictionaryConcurrently C# (CSharp) Méthode

BuildPropertyDictionaryConcurrently() public static méthode

public static BuildPropertyDictionaryConcurrently ( IEnumerable properties ) : string>.IDictionary
properties IEnumerable
Résultat string>.IDictionary
        public static IDictionary<string, string> BuildPropertyDictionaryConcurrently(IEnumerable<property> properties)
        {
            ConcurrentDictionary<string, string> propertyDictionary = new ConcurrentDictionary<string, string>();
            Parallel.ForEach(properties, (p) =>
            {
                if (p != null && !propertyDictionary.ContainsKey(p.name))
                {
                    // Don't ToLower it - it causes problems when we try to get the column name out again.
                    //propertyDictionaryField.Add(p.name.ToLower(), p.value);

                    propertyDictionary[p.name] = p.value;
                }
            });
            return propertyDictionary;
        }
        

Usage Example

 public void ForceRebuildPropertyDictionary()
 {
     propertyDictionaryField = TiledMapSave.BuildPropertyDictionaryConcurrently(properties);
 }