public PropertyAction(IProperty property, ValueModel value, StateModel model) { _model = model; _timestamp = DateTime.Now; Property = property; Value = value; _actionDisplayName = $"{property.Object?.ToString() ?? "Null"}.{property.Name} = {value?.ToString() ?? "Null"}"; }
public MethodParam(ParameterInfo parameter, API.IComponent component, object obj, IProperty parent, object overrideDefault = null) { _param = parameter; DisplayName = Name.Humanize(); Object = obj; Component = component; Parent = parent; Children = new List <IProperty>(); Value = new ValueModel(overrideDefault ?? (parameter.HasDefaultValue ? parameter.DefaultValue : GetDefaultValue(PropertyType)), type: PropertyType); }
private async Task <(object result, MethodModel model, MethodWizardAttribute attr)> run(object factory, Type factoryType, string methodName) { var(method, methodAttribute) = getMethod(factoryType, methodName); HashSet <string> hideProperties = new HashSet <string>(); Dictionary <string, object> overrideDefaults = new Dictionary <string, object>(); foreach (var param in method.GetParameters()) { var attr = param.GetCustomAttribute <MethodParamAttribute>(); if (attr == null) { continue; } if (!attr.Browsable) { hideProperties.Add(param.Name); } if (attr.DefaultProvider != null) { var resolver = _editor.GameResolver; var provider = factoryType.GetMethod(attr.DefaultProvider); if (provider == null) { throw new NullReferenceException($"Failed to find method with name: {attr.DefaultProvider ?? "null"}"); } overrideDefaults[param.Name] = provider.Invoke(null, new object[] { resolver }); } else if (attr.Default != null) { overrideDefaults[param.Name] = attr.Default; } } _setDefaults?.Invoke(overrideDefaults); var wizard = new MethodWizard(_parentForm, _title, method, hideProperties, overrideDefaults, _addUiExternal, _editor, _validate); wizard.Load(); var parameters = await wizard.ShowAsync(); if (parameters == null) { return(null, null, null); } foreach (var param in overrideDefaults.Keys) { if (!parameters.ContainsKey(param)) { parameters[param] = new ValueModel(overrideDefaults[param]); } } (object result, MethodModel model) = runMethod(method, factory, parameters); return(result, model, methodAttribute); }
protected override void ExecuteCore() { OldValue = Property.Value; execute(); }
public ReturnValue(ValueModel value, bool shouldCancel) { Value = value; ShouldCancel = shouldCancel; }