If collections null then create them

This commit is contained in:
Jaex 2017-09-03 03:13:07 +03:00
parent 60ccc8d76c
commit c105cead67
2 changed files with 20 additions and 7 deletions

View file

@ -3329,7 +3329,11 @@ private void btnCustomUploaderArgAdd_Click(object sender, EventArgs e)
txtCustomUploaderArgName.Focus();
CustomUploaderItem uploader = CustomUploaderGetSelected();
if (uploader != null) uploader.Arguments.Add(name, value);
if (uploader != null)
{
if (uploader.Arguments == null) uploader.Arguments = new Dictionary<string, string>();
uploader.Arguments.Add(name, value);
}
}
}
@ -3389,7 +3393,11 @@ private void btnCustomUploaderHeaderAdd_Click(object sender, EventArgs e)
txtCustomUploaderHeaderName.Focus();
CustomUploaderItem uploader = CustomUploaderGetSelected();
if (uploader != null) uploader.Headers.Add(name, value);
if (uploader != null)
{
if (uploader.Headers == null) uploader.Headers = new Dictionary<string, string>();
uploader.Headers.Add(name, value);
}
}
}
@ -3498,7 +3506,11 @@ private void btnCustomUploaderRegexpAdd_Click(object sender, EventArgs e)
txtCustomUploaderRegexp.Focus();
CustomUploaderItem uploader = CustomUploaderGetSelected();
if (uploader != null) uploader.RegexList.Add(regexp);
if (uploader != null)
{
if (uploader.RegexList == null) uploader.RegexList = new List<string>();
uploader.RegexList.Add(regexp);
}
}
}

View file

@ -36,15 +36,15 @@ namespace ShareX.UploadersLib
{
public class CustomUploaderItem
{
public string Name { get; set; } = "example.com";
public string Name { get; set; }
public CustomUploaderDestinationType DestinationType { get; set; }
public CustomUploaderRequestType RequestType { get; set; }
public string RequestURL { get; set; }
public string FileFormName { get; set; }
public Dictionary<string, string> Arguments { get; set; } = new Dictionary<string, string>();
public Dictionary<string, string> Headers { get; set; } = new Dictionary<string, string>();
public Dictionary<string, string> Arguments { get; set; }
public Dictionary<string, string> Headers { get; set; }
public ResponseType ResponseType { get; set; }
public List<string> RegexList { get; set; } = new List<string>();
public List<string> RegexList { get; set; }
public string URL { get; set; }
public string ThumbnailURL { get; set; }
public string DeletionURL { get; set; }
@ -54,6 +54,7 @@ public class CustomUploaderItem
public CustomUploaderItem()
{
Name = "example.com";
}
public CustomUploaderItem(string name)