-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAmazonConfigurerEditor.cs
60 lines (54 loc) · 2.44 KB
/
AmazonConfigurerEditor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using System.Linq;
using System.Web.UI.WebControls;
using Amazon;
using Inedo.BuildMaster.Extensibility.Configurers.Extension;
using Inedo.BuildMaster.Web.Controls.Extensions;
using Inedo.Web.Controls;
namespace Inedo.BuildMasterExtensions.Amazon
{
internal sealed class AmazonConfigurerEditor : ExtensionConfigurerEditorBase
{
private ValidatingTextBox txtKeyId;
private ValidatingTextBox txtSecretKey;
private ValidatingTextBox txtPartSize;
private DropDownList ddlRegionEndpoint;
protected override void CreateChildControls()
{
this.txtKeyId = new ValidatingTextBox { Required = true, Width = 300 };
this.txtSecretKey = new PasswordTextBox { Required = true, Width = 250 };
this.txtPartSize = new ValidatingTextBox { Type = ValidationDataType.Integer, Text = "5" };
this.ddlRegionEndpoint = new DropDownList { ID = "ddlRegionEndpoint" };
this.ddlRegionEndpoint.Items.AddRange(RegionEndpoint.EnumerableAllRegions.Select(r => new ListItem(r.DisplayName, r.SystemName)));
this.Controls.Add(
new SlimFormField("Access key ID:", this.txtKeyId),
new SlimFormField("Secret access key:", this.txtSecretKey),
new SlimFormField("S3 part size:", this.txtPartSize),
new SlimFormField("Endpoint:", this.ddlRegionEndpoint)
);
}
public override void BindToForm(ExtensionConfigurerBase extension)
{
this.EnsureChildControls();
var cfg = (AmazonConfigurer)extension;
this.txtKeyId.Text = cfg.AccessKeyId;
this.txtSecretKey.Text = cfg.SecretAccessKey;
this.txtPartSize.Text = cfg.S3PartSize.ToString();
this.ddlRegionEndpoint.SelectedValue = cfg.RegionEndpoint;
}
public override ExtensionConfigurerBase CreateFromForm()
{
this.EnsureChildControls();
return new AmazonConfigurer
{
AccessKeyId = this.txtKeyId.Text,
SecretAccessKey = this.txtSecretKey.Text,
S3PartSize = int.Parse(this.txtPartSize.Text),
RegionEndpoint = this.ddlRegionEndpoint.SelectedValue
};
}
public override void InitializeDefaultValues()
{
this.BindToForm(new AmazonConfigurer());
}
}
}