internal static void AddToDataSource(this IEnumerable itemsSource, Graphic graphic, Type objectType) { Dictionary<string, object> dictionary = new Dictionary<string, object>(); if (!graphic.AllAttributesMatch(objectType)) // A graphic element added with no matching attributes { if (objectType != null) { FieldInfo[] fieldInfo = GetFieldInfo(objectType); foreach (FieldInfo fldInfo in fieldInfo) { Type fldType = fldInfo.FieldType; string fldName = fldInfo.Name.Substring(1); object defaultValue = fldType.IsValueType ? Activator.CreateInstance(fldType) : null; dictionary.Add(fldName, defaultValue); } } } else // A graphic object from the graphics layer { foreach (KeyValuePair<string, object> keyVal in graphic.Attributes) { if (_fieldMapping.ContainsKey(keyVal.Key) && !dictionary.ContainsKey(_fieldMapping[keyVal.Key])) dictionary.Add(_fieldMapping[keyVal.Key], keyVal.Value); } } if (objectType != null) AddToEnumerable(objectType, graphic, itemsSource); }