private void SetProviderPropertyValue(AbstractTemplate pEntry, PropertyInfo pi, WzProperty dataProp, ProviderPropertyAttribute paa) { WzProperty realPropDir = dataProp; var propNameSplit = paa.AttributePath.Split('/'); string attributeName; for (var i = 0; i < propNameSplit.Length - 1; ++i) { attributeName = propNameSplit[i]; if (realPropDir is null) { continue; // cant find path } realPropDir = realPropDir.GetChild(attributeName) as WzProperty; } attributeName = propNameSplit[propNameSplit.Length - 1]; // should always be last of the split if (realPropDir is null) { return; // cant find path } var val = realPropDir.GetImgPropVal(pi.PropertyType, attributeName); if (val.IsNullOrDefault() || val is string s && s.Length <= 0) { foreach (var attrName in paa.AltPaths) { val = realPropDir.GetImgPropVal(pi.PropertyType, attrName); if (!val.IsNullOrDefault() || val is string ss && ss.Length <= 0) { break; } } } pi.SetValue(pEntry, val); }
private static int GetSumDelay(WzProperty wzProp) { if (wzProp is null) { return(-1); } var nDelay = 0; for (var i = 0; ; i++) { var data = wzProp.GetChild(i.ToString()) as WzProperty; if (data is null) { break; } nDelay += data.GetInt32("delay"); } return(nDelay); }