public void PropertyElement_IsPathValid_ReturnsTrueForValidPath() { var element = new PropertyElement(); var container = GetContainer(); element.SetTarget(container); var path = new PropertyPath(); { path.Clear(); path.PushName(nameof(ComplexUIContainer.FloatField)); Assert.That(element.IsPathValid(path), Is.True); } { path.Clear(); path.PushName(nameof(ComplexUIContainer.IntField)); Assert.That(element.IsPathValid(path), Is.True); } { path.Clear(); path.PushName(nameof(ComplexUIContainer.StringField)); Assert.That(element.IsPathValid(path), Is.True); } { path.Clear(); path.PushName(nameof(ComplexUIContainer.IntListField)); Assert.That(element.IsPathValid(path), Is.True); for (var i = 0; i < container.IntListField.Count; ++i) { path.PushIndex(i); Assert.That(element.IsPathValid(path), Is.True); path.Pop(); } } { path.Clear(); path.PushName(nameof(ComplexUIContainer.IntIntDictionary)); Assert.That(element.IsPathValid(path), Is.True); foreach (var kvp in container.IntIntDictionary.ToList()) { path.PushKey(kvp.Key); Assert.That(element.IsPathValid(path), Is.True); path.PushName("Key"); Assert.That(element.IsPathValid(path), Is.True); path.Pop(); path.PushName("Value"); Assert.That(element.IsPathValid(path), Is.True); path.Pop(); path.Pop(); } } }
void IBinding.Update() { if (!HasInspector) { return; } if (!m_Root.IsPathValid(m_BasePath)) { return; } m_Inspector.Update(); }
public void PropertyElement_IsPathValid_ReturnsFalseForInvalidPath() { var element = new PropertyElement(); var container = GetContainer(); element.SetTarget(container); var path = new PropertyPath(); { path.Clear(); path.PushName("jdhj"); Assert.That(element.IsPathValid(path), Is.False); } { path.Clear(); path.PushName(nameof(ComplexUIContainer.IntListField)); Assert.That(element.IsPathValid(path), Is.True); for (var i = container.IntListField.Count; i < container.IntListField.Count + 10; ++i) { path.PushIndex(i); Assert.That(element.IsPathValid(path), Is.False); path.Pop(); } } { path.Clear(); path.PushName(nameof(ComplexUIContainer.IntIntDictionary)); Assert.That(element.IsPathValid(path), Is.True); foreach (var kvp in container.IntIntDictionary.ToList()) { path.PushName(kvp.Key.ToString()); Assert.That(element.IsPathValid(path), Is.False); } } }
void IBinding.Update() { if (!HasInspector || !m_Root.IsPathValid(m_BasePath)) { return; } try { Inspector.Update(); } catch (Exception exception) { Debug.LogException(exception); } }