public static void RefreshChildrenProperties(IProperty property) { property.Children.Clear(); var val = property.Value.Value; if (val == null) { return; } var objType = val.GetType(); if (objType.GetTypeInfo().GetCustomAttribute <PropertyFolderAttribute>(true) != null) { var props = getProperties(objType); foreach (var childProp in props) { InspectorCategory dummyCat = null; var childProperty = AddProperty(val, property.Component, property, childProp, ref dummyCat); if (childProperty == null) { continue; } property.Children.Add(childProperty); } } }
public Dictionary <InspectorCategory, List <IProperty> > GetProperties() { InspectorCategory cat = new InspectorCategory("General"); AddProperties(cat, _obj, _props); return(_props); }
public static InspectorProperty AddProperty(object obj, IComponent component, IProperty parent, PropertyInfo prop, ref InspectorCategory cat) { var attr = prop.GetCustomAttribute <PropertyAttribute>(); Trace.Assert(prop.PropertyType.FullName != null, $"prop.PropertyType.FullName was null for {prop.PropertyType}"); if (attr == null && prop.PropertyType.FullName.StartsWith("AGS.API.IEvent", StringComparison.Ordinal)) { return(null); //filtering all events from the inspector by default } if (attr == null && prop.PropertyType.FullName.StartsWith("AGS.API.IBlockingEvent", StringComparison.Ordinal)) { return(null); //filtering all events from the inspector by default } string name = prop.Name; string displayName = null; bool forceReadonly = false; if (attr != null) { if (!attr.Browsable) { return(null); } if (attr.Category != null) { cat = new InspectorCategory(attr.Category, attr.CategoryZ, attr.CategoryExpand); } displayName = attr.DisplayName; forceReadonly = attr.ForceReadonly; } InspectorProperty property = new InspectorProperty(component, obj, parent, name, prop, displayName, forceReadonly); RefreshChildrenProperties(property); return(property); }
public static InspectorProperty AddProperty(object obj, PropertyInfo prop, ref InspectorCategory cat) { var attr = prop.GetCustomAttribute <PropertyAttribute>(); if (attr == null && prop.PropertyType.FullName.StartsWith("AGS.API.IEvent", StringComparison.Ordinal)) { return(null); //filtering all events from the inspector by default } if (attr == null && prop.PropertyType.FullName.StartsWith("AGS.API.IBlockingEvent", StringComparison.Ordinal)) { return(null); //filtering all events from the inspector by default } string name = prop.Name; if (attr != null) { if (!attr.Browsable) { return(null); } if (attr.Category != null) { cat = new InspectorCategory(attr.Category, attr.CategoryZ, attr.CategoryExpand); } if (attr.DisplayName != null) { name = attr.DisplayName; } } InspectorProperty property = new InspectorProperty(obj, name, prop); RefreshChildrenProperties(property); return(property); }
public Dictionary <InspectorCategory, List <IProperty> > GetProperties() { var parameters = _method.GetParameters(); if (parameters.Length == 0) { return(_props); } InspectorCategory cat = new InspectorCategory("General"); _props[cat] = new List <IProperty>(); foreach (var parameter in parameters) { if (_hideProperties.Contains(parameter.Name)) { continue; } _overrideDefaults.TryGetValue(parameter.Name, out var overrideDefault); var param = new MethodParam(parameter, null, overrideDefault); _props[cat].Add(param); ObjectTypeDescriptor.RefreshChildrenProperties(param); } return(_props); }
public Dictionary <InspectorCategory, List <IProperty> > GetProperties() { foreach (var component in _entity) { InspectorCategory cat = new InspectorCategory(component.Name.Humanize()); ObjectTypeDescriptor.AddProperties(cat, component, _props); } addEntityProps(_entity); return(_props); }
private void addEntityProps(IEntity entity) { InspectorCategory cat = new InspectorCategory("Hotspot"); var prop = entity.GetType().GetProperty(nameof(IEntity.DisplayName)); InspectorProperty property = ObjectTypeDescriptor.AddProperty(entity, null, null, prop, ref cat); if (property == null) { return; } _props.GetOrAdd(cat, () => new List <IProperty>()).Add(property); }
public static void AddProperties(InspectorCategory defaultCategory, object obj, Dictionary <InspectorCategory, List <IProperty> > properties) { var props = getProperties(obj.GetType()); foreach (var prop in props) { var cat = defaultCategory; InspectorProperty property = AddProperty(obj, obj as IComponent, null, prop, ref cat); if (property == null) { continue; } properties.GetOrAdd(cat, () => new List <IProperty>(props.Length)).Add(property); } }