protected override ISimpleControl CreateEditorControl() { var selected = HttpContextThatWorksOnLinux.Current?.Request?.Form?["raft-type"]; this.RaftType = selected == null ? null : Internals.RaftTypes.Select(rt => rt.type).FirstOrDefault(t => t.FullName + "," + t.Assembly.GetName().Name == selected); this.RaftType = this.RaftType ?? Internals.RaftTypes.FirstOrDefault().type; this.RaftEditor = null; if (this.RaftType != null) { this.RaftEditor = RaftRepositoryEditor.GetEditor(this.RaftType, this.EnvironmentId); this.RaftEditor.BindToInstance(Activator.CreateInstance(this.RaftType)); } return this.Form; }
public override void BindToInstance(object instance) { var credential = (RaftCredentials)instance; this.EnvironmentId = credential.EnvironmentId; using (var raft = credential.Raft) { this.RaftType = raft?.GetType(); if (this.RaftType == null) { this.RaftName.Text = ""; this.RaftEditor = null; } else { this.RaftName.Text = credential.RaftName; this.RaftEditor = RaftRepositoryEditor.GetEditor(this.RaftType, this.EnvironmentId); this.RaftEditor.BindToInstance(raft); } } this.ResetForm(); }