本文整理汇总了C#中CardMaker.XML.ProjectLayoutElement.InitializeCache方法的典型用法代码示例。如果您正苦于以下问题:C# ProjectLayoutElement.InitializeCache方法的具体用法?C# ProjectLayoutElement.InitializeCache怎么用?C# ProjectLayoutElement.InitializeCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CardMaker.XML.ProjectLayoutElement
的用法示例。
在下文中一共展示了ProjectLayoutElement.InitializeCache方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetOverrideElement
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;
}