public ApiModel(MainWindowModel mainWindow, ApiCollectionModel parent, Api api) : base(mainWindow, parent, api) { Inputs = new RxList <ApiInputModel>(); Outputs = new RxList <ApiOutputModel>(); Headers = new RxList <ApiHeaderModel>(); SubscribeForInputs(this.ObservePropertyChange(x => x.Model.Url), () => Model.Url, ApiInputType.Url); SubscribeForInputs(this.ObservePropertyChange(x => x.Model.Body).Where(x => ContentTypes.IsText(ContentType)), () => Model.Body, ApiInputType.Body); SubscribeForInputs(this.ObservePropertyChange(x => x.Headers).SelectMany(x => x.ObserveElementProperty(y => y.Name)).Merge(this.ObservePropertyChange(x => x.Headers).SelectMany(x => x.ObserveElementProperty(y => y.Value))), () => string.Join("\n", Headers.Select(x => x.Name + "=" + x.Value)), ApiInputType.Header); Model = api; if (api.Inputs != null) { Inputs.AddRange(api.Inputs.Select(x => new ApiInputModel { Id = x.Id, Name = x.Name, DefaultValue = x.DefaultValue, InputType = x.InputType })); } if (api.Outputs != null) { Outputs.AddRange(api.Outputs.Select(x => new ApiOutputModel { Id = x.Id, Name = x.Name, Expression = x.Expression, Type = x.Type })); } if (api.Headers != null) { Headers.AddRange(api.Headers.Select(x => new ApiHeaderModel { Id = x.Id, Name = x.Name, Value = x.Value })); } Send = RxCommand.CreateAsync(OnSend); Reset = RxCommand.Create(OnReset); Inputs.SetUpSync( MainWindow.Repository, Model.Inputs, x => new ApiInput { Name = x.Name, DefaultValue = "", InputType = x.InputType }); Outputs.SetUpSync( MainWindow.Repository, Model.Outputs, x => new ApiOutput { Name = x.Name, Expression = "" }); Headers.SetUpSync( MainWindow.Repository, Model.Headers, _ => new ApiHeader { Name = "", Value = "" }); }