public void Websocket() { using (var ws = new WebSocket(CommonConstants.CryptoCompareWebsocketUri + CommonConstants.CryptoCompareApiKey) ) { ws.OnMessage += (sender, e) => { CryptoCompareCoin cryptoCompareCoin = JsonConvert.DeserializeObject <CryptoCompareCoin>(e.Data); if (!string.IsNullOrEmpty(cryptoCompareCoin.FROMSYMBOL)) { CommonCoin commonCoin = new CommonCoin() { Symbol = cryptoCompareCoin.FROMSYMBOL, Price = cryptoCompareCoin.PRICE, HighPrice = cryptoCompareCoin.HIGH24HOUR, OpenPrice = cryptoCompareCoin.OPEN24HOUR, CurrencySymbol = cryptoCompareCoin.TOSYMBOL, Timestamp = cryptoCompareCoin.LASTUPDATE }; _cloudFirestoreRepository.CreatOrUpdate(commonCoin, CommonConstants.CryptoCompareCollectionName); } }; ws.Connect(); ws.Send(JsonConvert.SerializeObject(_commonConstants.CryptoCompareCoinRequestParams)); Console.ReadKey(true); } }
public void ReleaseExtraWord(Vector3 aPositionStart, Vector3 aPositionTarget, float aScale, float aDelay = 0f) { CommonCoin commonCoin = UnityEngine.Object.Instantiate(commonCoinPrefab, base.transform); commonCoin.Type = CommonCoin.CoinType.ExtraWord; commonCoin.State = CommonCoin.CoinState.SpreadRadial; commonCoin.PositionStart = aPositionStart; commonCoin.PositionTarget = aPositionTarget; commonCoin.Scale = aScale; commonCoin.Delay = aDelay; commonCoin.IsFullUpdate = false; commonCoin.spreadX = 0.5f; commonCoin.spreadY = 0.5f; commonCoin.particle.gameObject.SetActive(value: true); }
public void ReleaseCoinsRadial(int aNumberOfCoins, Vector3 aPositionStart, Vector3 aPositionTarget, float aScale, float aSpreadX, float aSpreadY, float aDelay, bool aIsFullUpdate, bool aIsWithParticles) { for (int i = 0; i < aNumberOfCoins; i++) { CommonCoin commonCoin = UnityEngine.Object.Instantiate(commonCoinPrefab, base.transform); commonCoin.Type = CommonCoin.CoinType.Coin; commonCoin.State = CommonCoin.CoinState.SpreadRadial; commonCoin.PositionStart = aPositionStart; commonCoin.PositionTarget = aPositionTarget; commonCoin.Scale = aScale; commonCoin.Delay = aDelay; commonCoin.IsFullUpdate = aIsFullUpdate; commonCoin.spreadX = aSpreadX; commonCoin.spreadY = aSpreadY; commonCoin.particle.gameObject.SetActive(aIsWithParticles); } }
public void ReleaseCoinsRadialCustomImage(Sprite aImage, int aNumberOfCoins, Vector3 aPositionStart, Vector3 aPositionTarget, float aScale, float aSpreadX, float aSpreadY, float aDelay) { for (int i = 0; i < aNumberOfCoins; i++) { CommonCoin commonCoin = UnityEngine.Object.Instantiate(commonCoinPrefab, base.transform); commonCoin.Type = CommonCoin.CoinType.Hint; commonCoin.State = CommonCoin.CoinState.SpreadRadial; commonCoin.PositionStart = aPositionStart; commonCoin.PositionTarget = aPositionTarget; commonCoin.Scale = aScale; commonCoin.Delay = aDelay; commonCoin.IsFullUpdate = false; commonCoin.spreadX = aSpreadX; commonCoin.spreadY = aSpreadY; commonCoin.particle.gameObject.SetActive(value: false); commonCoin.coin.sprite = aImage; } }
public void DoesNotPennyContainSilver() { // Arrange string type = "Penny"; string name = ""; string mint = "P"; int year = 1917; bool expected = false; CommonCoin theCoin = new CommonCoin(type, mint, year, name); // ACT ICoinLogic coinLogic = new BusinessLogicCoins(); // ASSERT bool actual = coinLogic.DoesCoinHaveSilver(theCoin); Assert.AreEqual(expected, actual); }
public bool CreatOrUpdate(CommonCoin coin, string collection) { try { DocumentReference document = _firestoreDb.Collection(collection).Document(coin.Symbol); document.SetAsync(coin); Console.WriteLine(collection + ": Updated (" + coin.Symbol + ") success!"); return(true); } catch (Exception e) { Console.WriteLine(e); Console.WriteLine(collection + ": Failed to update (" + coin.Symbol + ")"); return(false); } }
public void SetUp(int n, int f) { var keygen = new TrustedKeyGen(n, f); var shares = keygen.GetPrivateShares().ToArray(); var pubKeys = new PublicKeySet(shares.Select(share => share.GetPublicKeyShare()), f); _deliveryService = new DeliveryService(); _coins = new IConsensusProtocol[n]; _broadcasters = new IConsensusBroadcaster[n]; _resultInterceptors = new ProtocolInvoker <CoinId, CoinResult> [n]; _wallets = new IPrivateConsensusKeySet[n]; _publicKeys = new PublicConsensusKeySet(n, f, null !, pubKeys, Enumerable.Empty <ECDSAPublicKey>()); for (var i = 0; i < n; ++i) { _resultInterceptors[i] = new ProtocolInvoker <CoinId, CoinResult>(); _wallets[i] = new PrivateConsensusKeySet(null !, null !, shares[i]); _broadcasters[i] = new BroadcastSimulator(i, _publicKeys, _wallets[i], _deliveryService, false); _coins[i] = new CommonCoin( new CoinId(0, 0, 0), _publicKeys, shares[i], _broadcasters[i] ); _broadcasters[i].RegisterProtocols(new[] { _coins[i], _resultInterceptors[i] }); } }
public void Websocket() { using (var ws = new WebSocket(CommonConstants.CoinCapUri) ) { ws.OnMessage += (sender, e) => { Dictionary <string, double> coinCapCoin = JsonConvert.DeserializeObject <Dictionary <string, double> >(e.Data); foreach (var valuePair in coinCapCoin) { CommonCoin commonCoin = new CommonCoin() { Price = valuePair.Value, Symbol = _commonConstants.ConvertSymbols(valuePair.Key), CurrencySymbol = CommonConstants.DefaultCurrencySymbol }; _cloudFirestoreRepository.CreatOrUpdate(commonCoin, CommonConstants.CoinCapCollectionName); } }; ws.Connect(); ws.Send(JsonConvert.SerializeObject(null)); Console.ReadKey(true); } }