protected override void VisitDictionary <TContainer, TDictionary, TKey, TValue>( Property <TContainer, TDictionary> property, ref TContainer container, ref TDictionary value) { AddToPath(property); try { var path = GetCurrentPath(); using (var references = VisitorContext.MakeVisitedReferencesScope(this, ref value, path)) { if (references.VisitedOnCurrentBranch) { VisitorContext.Parent.Add(new CircularReferenceElement <TDictionary>(VisitorContext.Root, property, value, path, references.GetReferencePath())); return; } var element = GuiFactory.Foldout <TDictionary, TKey, TValue>(property, path, VisitorContext); VisitorContext.Parent.contentContainer.Add(element); using (VisitorContext.MakeParentScope(element)) { element.Reload(property); } } } finally { RemoveFromPath(property); } }
public void Visit <TContainer, TDictionary, TKey, TValue>( Property <TContainer, TDictionary> property, ref TContainer container, ref TDictionary dictionary) where TDictionary : IDictionary <TKey, TValue> { var path = Context.CopyCurrentPath(); var foldout = GuiFactory.Foldout <TDictionary, TKey, TValue>(property, path, Context); using (Context.MakeParentScope(foldout)) foldout.Reload(property); }
void IListPropertyVisitor.Visit <TContainer, TList, TElement>( Property <TContainer, TList> property, ref TContainer container, ref TList list) { var path = Context.CopyCurrentPath(); var foldout = GuiFactory.Foldout <TList, TElement>(property, path, Context); using (Context.MakeParentScope(foldout)) foldout.Reload(property); }
void ICollectionPropertyVisitor.Visit <TContainer, TCollection, TElement>( Property <TContainer, TCollection> property, ref TContainer container, ref TCollection collection) { var path = Context.CopyCurrentPath(); var foldout = GuiFactory.Foldout <TCollection>(property, path, Context); using (Context.MakeParentScope(foldout)) PropertyContainer.TryAccept(this, ref collection); }
void DefaultDictionaryVisit <TDictionary, TKey, TValue>( IProperty property, ref TDictionary value, PropertyPath path) where TDictionary : IDictionary <TKey, TValue> { var element = GuiFactory.Foldout <TDictionary, TKey, TValue>(property, path, VisitorContext); VisitorContext.Parent.contentContainer.Add(element); using (VisitorContext.MakeParentScope(element)) { element.Reload(property); } }
void DefaultListVisit <TList, TElement>( IProperty property, ref TList value, PropertyPath path) where TList : IList <TElement> { var element = GuiFactory.Foldout <TList, TElement>(property, path, VisitorContext); VisitorContext.Parent.contentContainer.Add(element); using (VisitorContext.MakeParentScope(element)) { element.Reload(property); } }
public void RecurseProperty <TValue>(ref TValue value, IProperty property, PropertyPath path) { if (path.PartsCount > 0) { var foldout = GuiFactory.Foldout <TValue>(property, path, VisitorContext); using (VisitorContext.MakeParentScope(foldout)) { property.Visit(this, ref value); } } else { property.Visit(this, ref value); } }
public void DefaultPropertyVisit <TValue>( IProperty property, ref TValue value, PropertyPath path) { if (path.PartsCount > 0) { if (string.IsNullOrEmpty(GuiFactory.GetDisplayName(property))) { property.Visit(this, ref value); } else { var foldout = GuiFactory.Foldout <TValue>(property, path, VisitorContext); using (VisitorContext.MakeParentScope(foldout)) property.Visit(this, ref value); } } else { property.Visit(this, ref value); } }
void IPropertyVisitor.Visit <TContainer, TValue>( Property <TContainer, TValue> property, ref TContainer container) { if (IsExcluded(property)) { return; } var value = property.GetValue(ref container); var isWrapper = container is PropertyWrapper <TValue>; Context.IsRootObject = isWrapper; // Null values if (RuntimeTypeInfoCache <TValue> .CanBeNull && ShouldBeTreatedAsNull(property, ref container, ref value) && ShouldStayNull(property, ref container, ref value)) { using (Context.MakePathScope(property)) { if (VisitNull(Context, property, ref value, Context.CopyCurrentPath())) { return; } } } foreach (var adapter in m_AdapterOverrides) { if (!(adapter is IInspectorVisit <TValue> partiallyTyped)) { continue; } using (Context.MakePathScope(property)) { if (partiallyTyped.Visit(Context, property, ref value, Context.CopyCurrentPath())) { return; } } } // Primitives if (this is IInspectorVisit <TValue> typed) { using (Context.MakePathScope(property)) { if (typed.Visit(Context, property, ref value, Context.CopyCurrentPath())) { return; } } } // UnityEngine.Object if (this is IInspectorContravariantVisit <TValue> contravariant) { using (Context.MakePathScope(property)) { if (contravariant.Visit(Context, property, value, Context.CopyCurrentPath())) { return; } } } // Enums if (RuntimeTypeInfoCache <TValue> .IsEnum) { using (Context.MakePathScope(property)) { if (VisitEnum(Context, property, ref value, Context.CopyCurrentPath(), isWrapper)) { return; } } } try { // Regular visit if (!isWrapper) { Context.AddToPath(property); } var path = Context.CopyCurrentPath(); using (var references = Context.MakeVisitedReferencesScope(ref value, path)) { if (references.VisitedOnCurrentBranch) { Context.Parent.Add(new CircularReferenceElement <TValue>(Context.Root, property, value, path, references.GetReferencePath())); return; } var inspector = GetCustomInspector(property, ref value, path, isWrapper); if (null != inspector) { var customInspector = new CustomInspectorElement(path, inspector, Context.Root); Context.Parent.contentContainer.Add(customInspector); return; } if (path.PartsCount > 0) { if (string.IsNullOrEmpty(GuiFactory.GetDisplayName(property))) { PropertyContainer.TryAccept(this, ref value); } else { // Give a chance for different property bags to handle themselves if (PropertyBagStore.TryGetPropertyBagForValue(ref value, out var valuePropertyBag)) { switch (valuePropertyBag) { case IDictionaryPropertyAccept <TValue> accept: accept.Accept(this, property, ref container, ref value); break; case IListPropertyAccept <TValue> accept: accept.Accept(this, property, ref container, ref value); break; case ISetPropertyAccept <TValue> accept: accept.Accept(this, property, ref container, ref value); break; case ICollectionPropertyAccept <TValue> accept: accept.Accept(this, property, ref container, ref value); break; default: var foldout = GuiFactory.Foldout <TValue>(property, path, Context); using (Context.MakeParentScope(foldout)) PropertyContainer.TryAccept(this, ref value); break; } } } } else { PropertyContainer.TryAccept(this, ref value); } } } finally { if (!isWrapper) { Context.RemoveFromPath(property); } } }