/// <summary> /// Ends the current custom method. /// </summary> public override void EndCustomMethod() { this.EnsureInBlock(BlockType.Method); this.currentVariation = null; this.currentBlock = null; }
/// <summary> /// Begins new synchronous variation. /// </summary> /// <param name="name">The name of the variation (will be the name of the method in the generated code).</param> public override void BeginVariation(string name) { this.EnsureNotInBlock(); this.nextVariableSuffix.Clear(); this.currentVariation = this.currentBlock = new BlockInformation(name, BlockType.Method, new CodeStatementCollection(), false); }
public HookBase( string name, IDataflowBlock block, DataflowVisitor visitor, Color?color = null) { #region Validation if (visitor == null) { throw new ArgumentNullException("visitor cannot be null"); } if (block == null) { throw new ArgumentNullException("_block cannot be null"); } #endregion // Validation _block = block; color = color ?? Colors.DarkGray; _visitor = visitor; BlockInfo = new BlockInformation(name, _block.IsImplements(typeof(ISourceBlock <>)), _block.IsImplements(typeof(ITargetBlock <>)), color.ToString()); _visitor.AddBlock(BlockInfo); LifeTimeWatcher(); }
void removeObj(int i, BlockInformation go, List <BlockInformation> k) { if (i == _myIndex) { if (k.Contains(go)) { if (go) { if (go.SPCharBeTouched.Count > 0) { Vector2 touched = go.SPCharBeTouched [indexInBlockInfo]; if (i == 0) { go.SPCharBeTouched [indexInBlockInfo] = new Vector2(0, touched.y); } if (i == 1) { go.SPCharBeTouched [indexInBlockInfo] = new Vector2(touched.x, 0); } } } k.Remove(go); } } }
/// <summary>Parse XML of Software Block</summary> /// <returns>XmlInformation</returns> private XmlInformation ParseSoftwareBlock() { var blockInfo = new BlockInformation(); blockInfo.XmlType = TiaXmlType.Block; blockInfo.Name = GetMetaInformation(XPathConstants.Xpathblockname); blockInfo.BlockNumber = GetMetaInformation(XPathConstants.Xpathblocknumber); blockInfo.BlockLanguage = GetMetaInformation(XPathConstants.Xpathblocklanguage); blockInfo.BlockType = GetMetaInformation(XPathConstants.Xpathblocktype); blockInfo.BlockMemoryLayout = GetMetaInformation(XPathConstants.Xpathblockmemorylayout); blockInfo.BlockAutoNumber = GetMetaInformation(XPathConstants.XpathAutonumber); blockInfo.BlockEnableTagReadback = GetMetaInformation(XPathConstants.XpathEnabletagreadback); blockInfo.BlockEnableTagReadbackBlockProperties = GetMetaInformation(XPathConstants.XpathEnabletagreadbackblockproperties); blockInfo.BlockIsIecCheckEnabled = GetMetaInformation(XPathConstants.XpathIsieccheckenabled); blockInfo.BlockAuthor = GetMetaInformation(XPathConstants.Xpathblockauthor); blockInfo.BlockTitle = GetBlockTitleOrComment(XPathConstants.Xpathblocktitle); blockInfo.BlockComment = GetBlockTitleOrComment(XPathConstants.Xpathblockcomment); blockInfo.BlockFamily = GetMetaInformation(XPathConstants.Xpathblockfamily); blockInfo.BlockVersion = GetMetaInformation(XPathConstants.Xpathblockversion); blockInfo.BlockUserId = GetMetaInformation(XPathConstants.Xpathblockuserid); blockInfo.BlockInterface = GetBlockInterfaceInformation(); blockInfo.BlockNetworks = GetBlockNetworkInformation(); return(blockInfo); }
// the Update loop contains a very simple example of moving the character around and controlling the animation void touchOfObjects() { touch3dObj = null; iHitObject = false; Vector2 touchBoth = new Vector2(1, 1); foreach (BlockInformation go in pXYhitObj) { if (go != null && go.SPCharBeTouched.Count > 0) { if (go.SPCharBeTouched [indexInBlockInfo] == touchBoth) { touch3dObj = go; iHitObject = true; } } } foreach (BlockInformation go in pZYhitObj) { if (go != null) { if (go.SPCharBeTouched.Count > 0 && go.SPCharBeTouched [indexInBlockInfo] == touchBoth) { touch3dObj = go; iHitObject = true; } } } }
/// <summary> /// Ends current variation. /// </summary> public override void EndVariation() { this.EnsureInBlock(BlockType.Method); this.variations.Add(this.currentVariation); this.currentVariation = null; this.currentBlock = null; }
void addBottomObjects(int i, BlockInformation go, List <BlockInformation> k, int n) { if (i == _myIndex) { if (!k.Contains(go)) { k.Add(go); } if (go) { if (go.SPCharBeTouched.Count > 0) { Vector2 touched = go.SPCharBeTouched [indexInBlockInfo]; if (i == 0) { go.SPCharBeTouched [indexInBlockInfo] = new Vector2(1, touched.y); } if (i == 1) { go.SPCharBeTouched [indexInBlockInfo] = new Vector2(touched.x, 1); } } } } }
private bool BlockIsNull(BlockInformation blockInfo) { if (blockInfo == null) { return(true); } return(false); }
/// <summary> /// Adds the conditional statement to the current scope and enters "then" scope. /// </summary> /// <param name="condition">The conditional expression.</param> public override void If(CodeExpression condition) { var statement = new CodeConditionStatement(condition); this.Add(statement); this.blockStack.Push(this.currentBlock); this.blockStack.Push(new BlockInformation(null, BlockType.Else, statement.FalseStatements, false)); this.currentBlock = new BlockInformation(null, BlockType.If, statement.TrueStatements, false); }
/// <summary> /// Ends current conditional statement scope ("then" or "else") and moves back to the previous scope. /// </summary> public override void EndIf() { this.EnsureInBlock(BlockType.If, BlockType.Else); this.currentBlock = this.blockStack.Pop(); if (this.currentBlock.BlockType == BlockType.Else) { this.currentBlock = this.blockStack.Pop(); } }
/// <summary> /// Begins the asynchronous variation. /// </summary> /// <param name="name">The name of the variation (will be the name of the method in the generated code).</param> /// <returns> /// CodeDom <see cref="CodeExpression"/> which can be used to refer to asynchronous continuation parameter in the generated code. /// </returns> public override CodeExpression BeginAsyncVariation(string name) { this.EnsureNotInBlock(); this.nextVariableSuffix.Clear(); this.currentVariation = this.currentBlock = new BlockInformation(name, BlockType.Method, new CodeStatementCollection(), true); return(Code.Argument("continuation")); }
void birdMeetsBearZY(BlockInformation bk, GameObject bd, Vector3 bp) { Vector3 nextPos = bp; Color nextColor = Color.white; if (bk.SPCharBeTouched [meetSPCharIndex].y == 1) //if bearZY touches the block, play bird flying away { nextPos = bp + new Vector3(0, 20, 0); nextColor = new Color(0, 0, 0, 0); } birdMoves(bd, nextPos, nextColor); }
private static XlsxTransactionInputOutput Create(BitcoinAddress address, ICoin source, BlockInformation block, uint256 transactionHash, IDictionary <string, IAssetDefinition> assetDictionary, int index, Network network, CoinType coinType) { string coloredAddress = null; try { coloredAddress = address?.ToColoredAddress()?.ToWif(); } catch { } var result = new XlsxTransactionInputOutput { Address = address?.ToString(), ColoredAddress = coloredAddress, TransactionHash = transactionHash.ToString(), Index = index, CoinType = coinType, }; if (block != null) { result.BlockDate = block.BlockTime.UtcDateTime; result.BlockHash = block.BlockId.ToString(); } if (source is ColoredCoin colored) { var assetId = colored.AssetId.GetWif(network).ToString(); var asset = assetDictionary.ContainsKey(assetId) ? assetDictionary[assetId] : null; var divisibility = asset?.Divisibility ?? 0; result.ColouredAssetValue = BitcoinUtils.CalculateColoredAssetQuantity(colored.Amount.Quantity, divisibility); result.BtcValue = BitcoinUtils.SatoshiToBtc(colored.Bearer.Amount.Satoshi); result.ColouredAssetName = asset != null ? asset.Name : assetId; } if (source is Coin uncolored) { result.BtcValue = BitcoinUtils.SatoshiToBtc(uncolored.Amount.Satoshi); } return(result); }
public void GetBlockHash() { var wtx = GenerateWalletTransaction(); var blockInfo = new BlockInformation(); blockInfo.Header = _block.Header; wtx.BlockInformation = blockInfo; ITransaction tx = new JetTransactionModel(wtx); var expected = BLOCK_HASH; Assert.AreEqual(expected, tx.BlockHash); }
public void DateFromBlock() { var wtx = GenerateWalletTransaction(); var blockInfo = new BlockInformation(); blockInfo.Header = _block.Header; wtx.BlockInformation = blockInfo; ITransaction tx = new JetTransactionModel(wtx); var expected = blockInfo.Header.BlockTime.Date; Assert.AreEqual(expected, tx.Date); }
/// <summary> /// Adds new custom method to the current code. /// </summary> /// <param name="methodName">Name of the method.</param> /// <returns> /// CodeDOM <see cref="CodeMemberMethod"/> which can be used to customize generated method. /// </returns> public override CodeMemberMethod BeginCustomMethod(string methodName) { this.EnsureNotInBlock(); CodeMemberMethod method = new CodeMemberMethod(); method.Name = methodName; this.customMembers.Add(method); this.nextVariableSuffix.Clear(); this.currentVariation = this.currentBlock = new BlockInformation(methodName, BlockType.Method, method.Statements, false); return(method); }
public async Task <int> ProcessBlock(BlockInformation blockInfo) { if (blockInfo == null) { throw new ArgumentNullException(nameof(blockInfo)); } if (blockInfo.AdditionalInformation.Confirmations < _trackingSettings.ConfirmationLimit) { await _log.WriteWarningAsync(nameof(ProcessBlock), $"Network: {_network.Name}, Block: {blockInfo.AdditionalInformation.ToJson()}", $"Insufficient confirmation count for block {blockInfo.AdditionalInformation.Height}, therefore skipped"); return(0); } var block = Block.Parse(blockInfo.Block); var blockTransactions = block.Transactions .SelectMany(tx => tx.Outputs.AsCoins() .Select(coin => new { coin, address = coin.ScriptPubKey.GetDestinationAddress(_network) }) .Where(x => x.coin.ScriptPubKey.IsValid && x.coin.Amount.Satoshi > 0) .Where(x => x.address != null)) .Select(x => new TransactionModel() { Amount = x.coin.Amount.ToDecimal(MoneyUnit.BTC), BlockId = blockInfo.AdditionalInformation.BlockId, CreatedUtc = blockInfo.AdditionalInformation.BlockTime.UtcDateTime, Currency = CurrencyType.Btc, PayInAddress = x.address.ToString(), TransactionId = x.coin.Outpoint.Hash.ToString(), UniqueId = x.coin.Outpoint.ToString() }) .ToList(); var count = 0; if (blockTransactions.Any()) { foreach (var batch in blockTransactions.Batch(100)) { count += await _commonServiceClient.HandleTransactionsAsync(batch.ToList()); } } await _log.WriteInfoAsync(nameof(ProcessBlock), $"Network: {_network.Name}, Block: {blockInfo.AdditionalInformation.ToJson()}, Investments: {count}", $"Block {blockInfo.AdditionalInformation.Height} processed"); return(count); }
public void ConfirmationsOK() { var wtx = GenerateWalletTransaction(); var blockInfo = new BlockInformation(); blockInfo.Header = _block.Header; blockInfo.Confirmations = 1000; wtx.BlockInformation = blockInfo; ITransaction tx = new JetTransactionModel(wtx); var greaterThan = 0; Assert.Greater(tx.Confirmations, greaterThan); }
public void AwaitingState() { var wtx = GenerateWalletTransaction(); var blockInfo = new BlockInformation(); var notEnoughConfirmations = 1; blockInfo.Confirmations = notEnoughConfirmations; wtx.BlockInformation = blockInfo; ITransaction tx = new JetTransactionModel(wtx); var expected = TxState.Awaiting; Assert.AreEqual(expected, tx.State); }
public void ConfirmedState() { var wtx = GenerateWalletTransaction(); var blockInfo = new BlockInformation(); var enoughConfirmations = 8; // >= 6 is enough blockInfo.Confirmations = enoughConfirmations; wtx.BlockInformation = blockInfo; ITransaction tx = new JetTransactionModel(wtx); var expected = TxState.Confirmed; Assert.AreEqual(expected, tx.State); }
void Start() { _blockInfo = GetComponent <BlockInformation> (); originalPos = transform.position; nextPos = transform.position; previousPos = transform.position; velocity = (nextPos - previousPos).normalized * speed; lastSqrMag = Mathf.Infinity; path = GetComponent <LineRenderer> (); path.SetPosition(0, originalPos); path.SetPosition(1, _anotherPoint.position); path.SetWidth(0.15F, 0.15F); path.enabled = true; }
private static BlockInformation[] GetBlocksInternal() { var blocks = UnicodeInfo.GetBlocks(); var blockViewModel = new BlockInformation[blocks.Length]; for (int i = 0; i < blocks.Length; i++) { var block = blocks[i]; blockViewModel[i] = new BlockInformation(block.Name, BlockMetadata.GetDescription(block.Name), new CodePointRange(block.CodePointRange.FirstCodePoint, block.CodePointRange.LastCodePoint)); } return(blockViewModel); }
private bool TryToMoveTo(Vector3 moveVector, GameTime gameTime) { // Build a "test vector" that is a little longer than the move vector. float moveLength = moveVector.Length(); Vector3 testVector = moveVector; testVector.Normalize(); testVector = testVector * (moveLength + 0.3f); // Apply this test vector. Vector3 movePosition = player.position + testVector; Vector3 midBodyPoint = movePosition + new Vector3(0, -0.7f, 0); Vector3 lowerBodyPoint = movePosition + new Vector3(0, -1.4f, 0); if (!BlockInformation.IsSolidBlock(player.world.BlockAt(movePosition).Type) && !BlockInformation.IsSolidBlock(player.world.BlockAt(lowerBodyPoint).Type) && !BlockInformation.IsSolidBlock(player.world.BlockAt(midBodyPoint).Type)) { player.position = player.position + moveVector; if (moveVector != Vector3.Zero) { player.headBob += 0.2; } return(true); } // It's solid there, so while we can't move we have officially collided with it. BlockType lowerBlock = player.world.BlockAt(lowerBodyPoint).Type; BlockType midBlock = player.world.BlockAt(midBodyPoint).Type; BlockType upperBlock = player.world.BlockAt(movePosition).Type; // It's solid there, so see if it's a lava block. If so, touching it will kill us! //if (upperBlock == BlockType.Lava || lowerBlock == BlockType.Lava || midBlock == BlockType.Lava) //{ // _P.KillPlayer(Defines.deathByLava); // return true; //} // If it's a ladder, move up. //if (upperBlock == BlockType.Ladder || lowerBlock == BlockType.Ladder || midBlock == BlockType.Ladder) //{ // _P.playerVelocity.Y = CLIMBVELOCITY; // Vector3 footPosition = _P.playerPosition + new Vector3(0f, -1.5f, 0f); // if (_P.blockEngine.SolidAtPointForPlayer(footPosition)) // _P.playerPosition.Y += 0.1f; // return true; //} return(false); }
/// <summary> /// Resets the state of the code builder and prepares for new code to be built. /// </summary> public override void Reset() { this.variations.Clear(); this.currentVariation = null; this.blockStack.Clear(); this.currentBlock = null; this.compiledAssembly = null; this.compiledActions = null; this.namespaceImports.Clear(); this.referenceAssemblies.Clear(); this.customMembers.Clear(); this.externalProperties.Clear(); }
public async Task <int> ProcessBlock(BlockInformation blockInfo) { if (blockInfo == null) { throw new ArgumentNullException(nameof(blockInfo)); } // check if there is any transaction within block if (blockInfo.IsEmpty) { await _log.WriteInfoAsync(nameof(ProcessBlock), $"Network: {_network}, Block: {blockInfo.ToJson()}", $"Block {blockInfo.Height} is empty, therefore skipped"); return(0); } // but even non-empty block can contain zero payment transactions var transactions = await _blockchainReader.GetBlockTransactionsAsync(blockInfo.Height, paymentsOnly : true); var transactionModels = transactions .Select(tx => new TransactionModel() { Amount = UnitConversion.Convert.FromWei(tx.Action.Value.Value), // WEI to ETH BlockId = tx.BlockHash, CreatedUtc = blockInfo.Timestamp.UtcDateTime, Currency = CurrencyType.Eth, PayInAddress = _addressUtil.ConvertToChecksumAddress(tx.Action.To), // lower-case to checksum representation TransactionId = tx.TransactionHash, UniqueId = tx.TransactionHash }) .ToList(); var count = 0; if (transactionModels.Any()) { count = await _commonServiceClient.HandleTransactionsAsync(transactionModels); } await _log.WriteInfoAsync(nameof(ProcessBlock), $"Investments: {count}, Network: {_network}, Block: {blockInfo.ToJson()}", $"Block {blockInfo.Height} processed"); return(count); }
private static XlsxTransactionInputOutput CreateFees(Money fees, BlockInformation block, uint256 transactionHash, int index) { var result = new XlsxTransactionInputOutput { TransactionHash = transactionHash.ToString(), Index = index, CoinType = CoinType.Fees, BtcValue = BitcoinUtils.SatoshiToBtc(fees.Satoshi) }; if (block != null) { result.BlockDate = block.BlockTime.UtcDateTime; result.BlockHash = block.BlockId.ToString(); } return(result); }
// private float YPosition { // get { return (_playerxyTransform.position.y + _playerzyTransform.position.y)/2f; } // } public void Rotate(float direction) { if (_isRotating) { return; } RaycastHit[] hitInfo = new RaycastHit[4]; bool[] didHit = new bool[4]; float maxDistance = Mathf.Infinity; Collider hitCollider = null; Vector3 pivot = SnappingMath.SnapToRoundedOffset(_transform.position, _pivotGridPrecision); didHit [0] = Physics.Raycast(pivot + Vector3.up * _raycastEpsilon + Vector3.right * _playerxyCollider.size.x / 2f, -Vector3.up, out hitInfo [0]); didHit [1] = Physics.Raycast(pivot + Vector3.up * _raycastEpsilon + Vector3.left * _playerxyCollider.size.x / 2f, -Vector3.up, out hitInfo [1]); didHit [2] = Physics.Raycast(pivot + Vector3.up * _raycastEpsilon + Vector3.forward * _playerzyCollider.size.x / 2f, -Vector3.up, out hitInfo [2]); didHit [3] = Physics.Raycast(pivot + Vector3.up * _raycastEpsilon + Vector3.back * _playerzyCollider.size.x / 2f, -Vector3.up, out hitInfo [3]); for (int i = 0; i < 4; i++) { float currDistance = hitInfo [i].distance; if (didHit [i] && currDistance < maxDistance) { maxDistance = currDistance; hitCollider = hitInfo [i].collider; } } if (hitCollider == null) { Debug.LogError("HIT NOTHING!"); } else { BlockInformation blockInfo = hitCollider.GetComponent <BlockInformation> (); if (hitCollider.transform.parent.name != "Planes" && blockInfo != null && blockInfo.CanRotate) { _activeRotator = blockInfo.MyRotatable; _activeRotator.CharacterDriveRotation(direction, _activeRotator.transform.position, _rotationDuration); _isRotating = true; } } }
public LinkHook( ISourceHook <T> source, ITargetBlock <T> target, DataflowLinkOptions linkOptions, DataflowVisitor visitor, Predicate <T> predicate = null, LinkCandidateInformation <T> candidate = null) { _target = target; var targetHook = target as ITargetHook <T>; if (targetHook != null) { _targetName = targetHook.BlockInfo.Name; _targetInfo = targetHook.BlockInfo; } _source = source; _candidate = candidate; if (candidate != null) { LinkInfo = new LinkToInformation(candidate.Connector, linkOptions, UnLink); } if (predicate == null) { _disposal = _source.InternalSource.LinkTo(this, linkOptions); } else { _disposal = DataflowBlock.LinkTo(_source.InternalSource, this, linkOptions, predicate); } _visitor = visitor; }
/// <summary> /// Adds new custom method to the current code. /// </summary> /// <param name="methodName">Name of the method.</param> /// <returns> /// CodeDOM <see cref="CodeMemberMethod"/> which can be used to customize generated method. /// </returns> public override CodeMemberMethod BeginCustomMethod(string methodName) { this.EnsureNotInBlock(); CodeMemberMethod method = new CodeMemberMethod(); method.Name = methodName; this.customMembers.Add(method); this.nextVariableSuffix.Clear(); this.currentVariation = this.currentBlock = new BlockInformation(methodName, BlockType.Method, method.Statements, false); return method; }
/// <summary> /// Begins the asynchronous variation. /// </summary> /// <param name="name">The name of the variation (will be the name of the method in the generated code).</param> /// <returns> /// CodeDom <see cref="CodeExpression"/> which can be used to refer to asynchronous continuation parameter in the generated code. /// </returns> public override CodeExpression BeginAsyncVariation(string name) { this.EnsureNotInBlock(); this.nextVariableSuffix.Clear(); this.currentVariation = this.currentBlock = new BlockInformation(name, BlockType.Method, new CodeStatementCollection(), true); return Code.Argument("continuation"); }
/// <summary> /// Ends the lambda scope. /// </summary> public override void EndLambda() { this.EnsureInBlock(BlockType.Lambda); this.currentBlock = this.blockStack.Pop(); }
/// <summary> /// Gets the block information for a user or IP address on a wiki. /// </summary> /// <param name="userName">Name of the user.</param> /// <param name="channel">The channel the command was requested in.</param> /// <returns></returns> public BlockInformation getBlockInformation(string userName, string channel) { IPAddress ip; string baseWiki = Configuration.singleton()["baseWiki",channel]; DAL.Select q = new DAL.Select("site_api"); q.setFrom("site"); q.addWhere(new DAL.WhereConds("site_id", baseWiki)); string api = DAL.singleton().executeScalarSelect(q); string apiParams = "?action=query&list=blocks&bk"; if (IPAddress.TryParse(userName, out ip)) { apiParams += "ip"; } else { apiParams += "users"; } apiParams += "=" + userName + "&format=xml"; XmlTextReader creader = new XmlTextReader(HttpRequest.get(api + apiParams)); while (creader.Name != "blocks") { creader.Read(); } creader.Read(); if ( creader.Name != "block" ) return new BlockInformation( ); BlockInformation bi = new BlockInformation { id = creader.GetAttribute( "id" ), target = creader.GetAttribute( "user" ), blockedBy = creader.GetAttribute( "by" ), start = creader.GetAttribute( "timestamp" ), expiry = creader.GetAttribute( "expiry" ), blockReason = creader.GetAttribute( "reason" ), autoblock = creader.GetAttribute( "autoblock" ) == "" ? true : false, nocreate = creader.GetAttribute( "nocreate" ) == "" ? true : false, noemail = creader.GetAttribute( "noemail" ) == "" ? true : false, allowusertalk = creader.GetAttribute( "allowusertalk" ) == "" ? true : false }; return bi; }
void Start() { _charInfo = this.GetComponent <BlockInformation> (); }
/// <summary> /// Exits current "then" scope and enters the "else" scope of current conditional statement. /// </summary> public override void Else() { this.EnsureInBlock(BlockType.If); this.currentBlock = this.blockStack.Pop(); }
/// <summary> /// Begins the new scope which will add statements to given lambda body. /// </summary> /// <param name="lambda">The lambda.</param> public override void BeginLambda(CodeLambdaExpression lambda) { this.blockStack.Push(this.currentBlock); this.currentBlock = new BlockInformation(null, BlockType.Lambda, lambda.BodyStatements, false); }