-
sfernandez
Site Admin
- Posts: 3014
- Joined:
Re: Problem with custom "SwitchConverter" and Static Resources
Hi, looking at the code you sent me I see the collection is not initialized:
And I think the implementation of the converter has a bug because you are comparing When and Then properties, shouldn't you be comparing When against the bound value?
Code: Select all
SwitchConverter::SwitchConverter(): m_switchCases(Noesis::MakePtr<SwitchCaseCollection>()) {
ConnectNode(m_switchCases, this);
InitComponent(m_switchCases, true);
}
Code: Select all
bool SwitchConverter::TryConvert(Noesis::BaseComponent* value, const Noesis::Type*,
Noesis::BaseComponent*, Noesis::Ptr<Noesis::BaseComponent>& result) {
int numCases = m_switchCases->Count();
for (int i = 0; i < numCases; ++i) {
auto switchCase = m_switchCases->Get(i);
if (switchCase) {
auto when = switchCase->GetWhen();
if (when) {
if (when->Equals(value)) {
auto then = switchCase->GetThen();
result.Reset(then);
}
}
else {
NS_LOG_WARNING("SwitchConverter: SwitchCase WHEN is null");
}
}
}
return true;
}
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 2 guests