Code quality changes

This commit is contained in:
Robin 2016-09-22 20:40:13 +02:00
parent f07ed83722
commit 610f45d082
189 changed files with 4609 additions and 5203 deletions

View file

@ -57,15 +57,17 @@ namespace GreenshotFlickrPlugin {
/// <param name="filename"></param>
/// <returns>url to image</returns>
public static string UploadToFlickr(ISurface surfaceToUpload, SurfaceOutputSettings outputSettings, string title, string filename) {
OAuthSession oAuth = new OAuthSession(FlickrCredentials.ConsumerKey, FlickrCredentials.ConsumerSecret);
oAuth.BrowserSize = new Size(520, 800);
oAuth.CheckVerifier = false;
oAuth.AccessTokenUrl = FLICKR_ACCESS_TOKEN_URL;
oAuth.AuthorizeUrl = FLICKR_AUTHORIZE_URL;
oAuth.RequestTokenUrl = FLICKR_REQUEST_TOKEN_URL;
oAuth.LoginTitle = "Flickr authorization";
oAuth.Token = config.FlickrToken;
oAuth.TokenSecret = config.FlickrTokenSecret;
var oAuth = new OAuthSession(FlickrCredentials.ConsumerKey, FlickrCredentials.ConsumerSecret)
{
BrowserSize = new Size(520, 800),
CheckVerifier = false,
AccessTokenUrl = FLICKR_ACCESS_TOKEN_URL,
AuthorizeUrl = FLICKR_AUTHORIZE_URL,
RequestTokenUrl = FLICKR_REQUEST_TOKEN_URL,
LoginTitle = "Flickr authorization",
Token = config.FlickrToken,
TokenSecret = config.FlickrTokenSecret
};
if (string.IsNullOrEmpty(oAuth.Token)) {
if (!oAuth.Authorize()) {
return null;
@ -85,7 +87,7 @@ namespace GreenshotFlickrPlugin {
signedParameters.Add("is_public", config.IsPublic ? "1" : "0");
signedParameters.Add("is_friend", config.IsFriend ? "1" : "0");
signedParameters.Add("is_family", config.IsFamily ? "1" : "0");
signedParameters.Add("safety_level", string.Format("{0}", (int)config.SafetyLevel));
signedParameters.Add("safety_level", $"{(int) config.SafetyLevel}");
signedParameters.Add("hidden", config.HiddenFromSearch ? "1" : "2");
IDictionary<string, object> otherParameters = new Dictionary<string, object>();
otherParameters.Add("photo", new SurfaceContainer(surfaceToUpload, outputSettings, filename));
@ -125,16 +127,13 @@ namespace GreenshotFlickrPlugin {
XmlNodeList nodes = doc.GetElementsByTagName("photo");
if (nodes.Count > 0) {
var item = nodes.Item(0);
if (item != null) {
if (item.Attributes != null) {
string farmId = item.Attributes["farm"].Value;
string serverId = item.Attributes["server"].Value;
string photoId = item.Attributes["id"].Value;
string secret = item.Attributes["secret"].Value;
return string.Format(FLICKR_FARM_URL, farmId, serverId, photoId, secret);
}
if (item?.Attributes != null) {
string farmId = item.Attributes["farm"].Value;
string serverId = item.Attributes["server"].Value;
string photoId = item.Attributes["id"].Value;
string secret = item.Attributes["secret"].Value;
return string.Format(FLICKR_FARM_URL, farmId, serverId, photoId, secret);
}
}
}
} catch (Exception ex) {