internal static void GatherInspectorContent( List <Type> propertyDrawerList, VisualElement outputVisualElement, IInspectable inspectable, Action propertyChangeCallback, List <IPropertyDrawer> allPropertyDrawerInstances, IPropertyDrawer propertyDrawerToUse = null) { var dataObject = inspectable.GetObjectToInspect(); if (dataObject == null) { throw new NullReferenceException("DataObject returned by Inspectable is null!"); } var properties = inspectable.GetType().GetProperties(BindingFlags.Default | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (properties == null) { throw new NullReferenceException("PropertyInfos returned by Inspectable is null!"); } foreach (var propertyInfo in properties) { var attribute = propertyInfo.GetCustomAttribute <InspectableAttribute>(); if (attribute == null) { continue; } var propertyType = propertyInfo.GetGetMethod(true).Invoke(inspectable, new object[] { }).GetType(); var propertyDrawerInstance = propertyDrawerToUse; if (propertyDrawerInstance == null) { if (IsPropertyTypeHandled(propertyDrawerList, propertyType, out var propertyDrawerTypeToUse)) { propertyDrawerInstance = (IPropertyDrawer)Activator.CreateInstance(propertyDrawerTypeToUse); } } if (propertyDrawerInstance != null) { // Assign the inspector update delegate so any property drawer can trigger an inspector update if it needs it propertyDrawerInstance.inspectorUpdateDelegate = propertyChangeCallback; // Supply any required data to this particular kind of property drawer inspectable.SupplyDataToPropertyDrawer(propertyDrawerInstance, propertyChangeCallback); var propertyGUI = propertyDrawerInstance.DrawProperty(propertyInfo, dataObject, attribute); outputVisualElement.Add(propertyGUI); if (allPropertyDrawerInstances != null) { allPropertyDrawerInstances.Add(propertyDrawerInstance); } } } }
private static unsafe int GetRuntimeClassName(IntPtr thisPtr, IntPtr *className) { try { InspectableShadow shadow = ToShadow <InspectableShadow>(thisPtr); IInspectable callback = (IInspectable)shadow.Callback; // Use the name of the callback class string name = callback.GetType().FullName; Win32.WinRTStrings.WindowsCreateString(name, (uint)name.Length, out IntPtr str); *className = str; } catch (Exception exception) { return((int)Result.GetResultFromException(exception)); } return(Result.Ok.Code); }