public ProjectLayoutElement GetOverrideElement(ProjectLayoutElement zElement, int nCardIndex, List <string> arrayLine, DeckLine zDeckLine) { Dictionary <string, int> dictionaryOverrideColumns; string sNameLower = zElement.name.ToLower(); DictionaryElementOverrides.TryGetValue(sNameLower, out dictionaryOverrideColumns); if (null == dictionaryOverrideColumns) { return(zElement); } var zOverrideElement = new ProjectLayoutElement(); zOverrideElement.DeepCopy(zElement, false); zOverrideElement.name = zElement.name; foreach (string sKey in dictionaryOverrideColumns.Keys) { Type zType = typeof(ProjectLayoutElement); PropertyInfo zProperty = zType.GetProperty(sKey); if (null != zProperty && zProperty.CanWrite) { MethodInfo zMethod = zProperty.GetSetMethod(); int nOverrideValueColumnIdx = dictionaryOverrideColumns[sKey]; if (arrayLine.Count <= nOverrideValueColumnIdx) { continue; } string sValue = arrayLine[nOverrideValueColumnIdx].Trim(); // Note: TranslateString maintains an element name based cache, the key is critical to make this translation unique sValue = TranslateString(sValue, nCardIndex, zDeckLine, zOverrideElement, sKey).String; if (!string.IsNullOrEmpty(sValue)) { if (zProperty.PropertyType == typeof(string)) { zMethod.Invoke(zOverrideElement, new object[] { sValue }); } else if (zProperty.PropertyType == typeof(float)) { float fValue; if (float.TryParse(sValue, out fValue)) { zMethod.Invoke(zOverrideElement, new object[] { fValue }); } } else if (zProperty.PropertyType == typeof(bool)) { bool bValue; if (bool.TryParse(sValue, out bValue)) { zMethod.Invoke(zOverrideElement, new object[] { bValue }); } } else if (zProperty.PropertyType == typeof(Int32)) { int nValue; if (int.TryParse(sValue, out nValue)) { zMethod.Invoke(zOverrideElement, new object[] { nValue }); } } } } } zOverrideElement.InitializeCache(); // any cached items must be recached return(zOverrideElement); }