public async Task <IValue> SetProperty(string name, string value, string?valueType, string?ownerType) { var query = new SetPropertyRequest { ElementId = Id, Name = name, Value = value, ValueType = valueType, OwnerType = ownerType ?? "" }; LogMessage?.Invoke($"{nameof(SetProperty)}({name},{value},{valueType},{ownerType})"); if (await Client.SetPropertyAsync(query) is { } reply) { if (reply.ErrorMessages.Any()) { throw new Exception(string.Join(Environment.NewLine, reply.ErrorMessages)); } if (reply.PropertyType is { } propertyType) { return(new Property(propertyType, reply.ValueType, reply.Value)); } throw new Exception("Property reply does not have a type specified"); } throw new Exception("Failed to receive a reply"); }
public void SetProperty(SetPropertyRequest request) { IApplication application = Application.Find(request.ApplicationId); if (application != null) { application.SetProperty(request.Key, request.Value); } }
protected override void OnExecute(XenMessageContext ctx) { _req = ctx.Get <SetPropertyRequest>(); if (_req == null) { return; } SetPropertyValue(_req.WidgetId, _req.Path, _req.Value, _req.IsBase64, _req.IsAttachedProperty); }
private async void propertyGrid_PropertyValueChanged(object sender, Xceed.Wpf.Toolkit.PropertyGrid.PropertyValueChangedEventArgs e) { PropertyItem item = e.OriginalSource as PropertyItem; //PropertyGrid嵌套PropertyGrid的情况,父PropertyGrid也会收到changed消息 //这里过滤子PropertyGrid的情况 MyPropertyDescriptor itemPropertyDescriptor = item.PropertyDescriptor as MyPropertyDescriptor; if (itemPropertyDescriptor == null) { return; } Type propertyType = item.PropertyType; object propertyValue = item.Value; var request = new SetPropertyRequest(); request.Path = VisualTree.SelectItemPath; request.PropertyID = itemPropertyDescriptor.MetaPropertyDescriptor.CppTypeID; request.PropertyType = itemPropertyDescriptor.MetaPropertyDescriptor.CppTypeName; request.PropertyValue = ValueToString(propertyValue); try { var s = Rpc._channel.State; var reply = await Rpc.NodeClient.SetPropertyAsync(request); if (!reply.Success) { ViewModel.LogData.Add(LogLevel.Error, reply.Msg); } } catch (Exception ex) { ViewModel.LogData.Add(LogLevel.Error, ex.Message); } ViewModel.LogData.Add(LogLevel.Info, "{0} changed to {1}", itemPropertyDescriptor.DisplayName, propertyValue); }