Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert to conditional expression #1916

Merged
merged 2 commits into from Jul 17, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory;
using System;
using System.Collections.Generic;
@@ -39,12 +39,9 @@ public async Task<IActionResult> GetExchangeRatesAsync()
{
IEnumerable<ExchangeRate> exchangeRates = await GetExchangeRatesCollectionAsync();

if (!exchangeRates.Any())
{
return NotFound("Exchange rates are not available.");
}

return Ok(exchangeRates);
return !exchangeRates.Any()
? NotFound("Exchange rates are not available.")
: (IActionResult)Ok(exchangeRates);
This conversation was marked as resolved by yahiheb

This comment has been minimized.

Copy link
@nopara73

nopara73 Jul 16, 2019

Collaborator

This adds more friction with IActionResult casting.

}

internal async Task<IEnumerable<ExchangeRate>> GetExchangeRatesCollectionAsync()
@@ -1,4 +1,4 @@
using Avalonia;
using Avalonia;
using Avalonia.Data.Converters;
using Avalonia.Media;
using System;
@@ -20,12 +20,9 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
}
}

if (Application.Current.Resources.TryGetResource("ApplicationAccentBrushLow", out object brush))
{
return brush;
}

return null;
return Application.Current.Resources.TryGetResource("ApplicationAccentBrushLow", out object brush)
? brush :
null;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
@@ -248,14 +248,10 @@ public void SetLoadButtonText()
}
else
{
if (SelectedWallet?.HardwareWalletInfo != null && !SelectedWallet.HardwareWalletInfo.Initialized) // If the hardware wallet was not initialized, then make the button say Setup, not Load.
{
LoadButtonText = "Setup Wallet";
}
else
{
LoadButtonText = "Load Wallet";
}
// If the hardware wallet was not initialized, then make the button say Setup, not Load.
LoadButtonText = SelectedWallet?.HardwareWalletInfo != null && !SelectedWallet.HardwareWalletInfo.Initialized
? "Setup Wallet"
: "Load Wallet";
This conversation was marked as resolved by yahiheb

This comment has been minimized.

Copy link
@nopara73

nopara73 Jul 16, 2019

Collaborator

ACK.

}
}

@@ -9,14 +9,9 @@ public static class ExceptionExtensions
public static string ToTypeMessageString(this Exception ex)
{
var trimmed = Guard.Correct(ex.Message);
if (trimmed == "")
{
return ex.GetType().Name;
}
else
{
return $"{ex.GetType().Name}: {ex.Message}";
}
return trimmed == ""
? ex.GetType().Name
: $"{ex.GetType().Name}: {ex.Message}";
This conversation was marked as resolved by yahiheb

This comment has been minimized.

Copy link
@nopara73

nopara73 Jul 16, 2019

Collaborator

ACK

}

public static Dictionary<string, string> BitcoinCoreTranslations { get; } = new Dictionary<string, string>
@@ -85,6 +85,7 @@ public static async Task<string> ReadHeadersAsync(Stream stream, CancellationTok

builder.Append(header + CRLF); // CRLF is part of the headerstring
}

headers = builder.ToString();
if (string.IsNullOrEmpty(headers))
{
@@ -117,12 +118,10 @@ private static async Task<string> ReadCRLFLineAsync(Stream stream, Encoding enco
}
bab.Append((byte)ch);
}
if (bab.Length > 0)
{
return bab.ToString(encoding);
}

return null;
return bab.Length > 0
? bab.ToString(encoding)
: null;
This conversation was marked as resolved by nopara73

This comment has been minimized.

Copy link
@nopara73

nopara73 Jul 16, 2019

Collaborator

I don't like it.

This comment has been minimized.

Copy link
@yahiheb

yahiheb Jul 16, 2019

Author Collaborator

Should it be inlined or should it be removed?

This comment has been minimized.

Copy link
@nopara73

nopara73 Jul 17, 2019

Collaborator

IDK, @molnard likes it so, I guess I merge with this.

}

public static byte[] HandleGzipCompression(HttpContentHeaders contentHeaders, byte[] decodedBodyArray)
@@ -56,6 +56,7 @@ public bool TryRemoveFromBroadcastStore(uint256 transactionHash, out Transaction
{
var found = BroadcastStore.FirstOrDefault(x => x.TransactionId == transactionHash);
entry = found;

if (found is null)
{
return false;
@@ -75,14 +76,7 @@ public bool TryGetFromBroadcastStore(uint256 transactionHash, out TransactionBro
var found = BroadcastStore.FirstOrDefault(x => x.TransactionId == transactionHash);
entry = found;

if (found is null)
{
return false;
}
else
{
return true;
}
return !(found is null);
This conversation was marked as resolved by yahiheb

This comment has been minimized.

Copy link
@nopara73

nopara73 Jul 16, 2019

Collaborator

This is screaming for a mistake. For someone "to optimize it out" with a !=.

}
}

@@ -1,4 +1,4 @@
using NBitcoin;
using NBitcoin;
using Newtonsoft.Json;
using Nito.AsyncEx;
using System;
@@ -20,14 +20,10 @@ public class BlockCypherClient : IDisposable
public BlockCypherClient(Network network, HttpMessageHandler handler = null, bool disposeHandler = false)
{
Network = network ?? throw new ArgumentNullException(nameof(network));
if (handler != null)
{
HttpClient = new HttpClient(handler, disposeHandler);
}
else
{
HttpClient = new HttpClient();
}
HttpClient = handler != null
? new HttpClient(handler, disposeHandler)
: new HttpClient();
This conversation was marked as resolved by yahiheb

This comment has been minimized.

Copy link
@nopara73

nopara73 Jul 16, 2019

Collaborator

ACK


if (network == Network.Main)
{
HttpClient.BaseAddress = new Uri("https://api.blockcypher.com/v1/btc/main");
@@ -1,4 +1,4 @@
using NBitcoin;
using NBitcoin;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Nito.AsyncEx;
@@ -23,14 +23,10 @@ public class SmartBitClient : IDisposable
public SmartBitClient(Network network, HttpMessageHandler handler = null, bool disposeHandler = false)
{
Network = network ?? throw new ArgumentNullException(nameof(network));
if (handler != null)
{
HttpClient = new HttpClient(handler, disposeHandler);
}
else
{
HttpClient = new HttpClient();
}
HttpClient = handler != null
? new HttpClient(handler, disposeHandler)
: new HttpClient();
This conversation was marked as resolved by yahiheb

This comment has been minimized.

Copy link
@nopara73

nopara73 Jul 16, 2019

Collaborator

ACK


if (network == Network.Main)
{
HttpClient.BaseAddress = new Uri("https://api.smartbit.com.au/v1/");
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.