/// <summary> /// 1. Use <see cref="MatchingAlgorithm"/> to find a match from <see cref="RecordedRequests"/>. /// <para /> /// 2. Use either <see cref="RecordedResultResponseBuilder"/> or <see cref="RequestNotFoundResponseBuilder"/> /// to build a <see cref="HttpWebResponse"/>. /// <para /> /// 3. Fire <see cref="OnMatch"/> /// <para /> /// 4. Honor <see cref="AllowReplayingRecordedRequestsMultipleTimes"/> and remove the matched /// <see cref="RecordedRequest"/> from <see cref="RecordedRequests"/> /// <para /> /// 5. Return the <see cref="HttpWebResponse"/>. aka Profit! /// </summary> public HttpWebResponse BuildResponse(InterceptedRequest intercepted) { lock (_buildResponseLock) { var matchedRecordedRequest = RecordedRequests .FirstOrDefault(recorded => MatchingAlgorithm(intercepted, recorded)); try { var response = null != matchedRecordedRequest ? RecordedResultResponseBuilder(matchedRecordedRequest, intercepted) : RequestNotFoundResponseBuilder(intercepted); OnMatch?.Invoke(matchedRecordedRequest, intercepted, response, null); return(response); } catch (Exception e) { OnMatch?.Invoke(matchedRecordedRequest, intercepted, null, e); throw; } finally { if (!AllowReplayingRecordedRequestsMultipleTimes && null != matchedRecordedRequest) { RecordedRequests.Remove(matchedRecordedRequest); } } } }
public override void Update(float delta) { if (_thrust != null && _turning != null) { var deltaV = TargetVelocity - Entity.Velocity; if (length(deltaV) < TargetThreshold) { OnMatch?.Invoke(); } _turning.Axis = TurningInput(deltaV); _thrust.Axis = ThrustInput(deltaV); } }
internal string Process(string text, OnMatch onMatch) { var startIndex = 0; var buf = new StringBuilder(); while (true) { var m = pattern.Match(text, startIndex); if (!m.Success) { break; } buf.Append(text[startIndex..m.Index]);
public void AddTest(string declaringType, string methodPrefix, OnMatch func) { AddTest(new NamedStackFrame(declaringType, methodPrefix, func)); }
public NamedStackFrame(string declaringType, string methodPrefix, OnMatch func) : base(methodPrefix, func) { mDeclaringType = declaringType; }
public StackFrameBase(string methodPrefix, OnMatch func) { mFunc = func; mMethodPrefix = methodPrefix; }
void ColorsMatch(Part.PartFlashing flashing) { Log.Message("Совпадение цветов части и сферы!"); flashing.Flash(true); OnMatch?.Invoke(); }
internal void DispatchTrade(Match trade) { OnMatch?.Invoke(trade); }
internal void DispatchTrade(Match match) { OnMatch?.Invoke(match); }
private IEnumerator ValidateBoard(UnityAction callback) { // Check for Matches int removedTileCount = 0; for (int x = 0; x < tilesDimesions.x; x++) { for (int y = 0; y < tilesDimesions.y; y++) { Vector2Int coordinate = new Vector2Int(x, y); if (ValidateMatch(coordinate, out List <Vector2Int> matchList)) { float duration = 0f; // --- Clean Matches --- for (int i = 0; i < matchList.Count; i++) { duration = tiles[matchList[i].x, matchList[i].y].Despawn(); tiles[matchList[i].x, matchList[i].y] = null; ++removedTileCount; } // Event if (OnMatch != null) { OnMatch.Invoke(matchList.Count); } if (removedTileCount > 0) { yield return(new WaitForSeconds(tweenMatchTileDelay)); } } } } // --- Shifting/Refill --- if (removedTileCount > 0) { Vector3 startPosition = boardOriginPosition; for (int x = 0; x < tilesDimesions.x; x++) { for (int y = tilesDimesions.y - 1; y >= 0; y--) { if (tiles[x, y] == null) { bool found = false; for (int y2 = y; y2 >= 0; y2--) { if (tiles[x, y2] != null) { Vector3 position = new Vector3(startPosition.x + (tileSize.x * 0.5f) + (tileSize.x * x), startPosition.y - (tileSize.y * 0.5f) - (tileSize.y * y), 0); tiles[x, y2].SetPosition(position); tiles[x, y] = tiles[x, y2]; tiles[x, y2] = null; found = true; break; } } // Refill if (!found) { // -- Create Tileset -- BoardTile[] tilesetLibrary = boardProfile.tilePack.boardTiles; // TileSet //int tileIndex = possibleBoardTiles[Random.Range(0, possibleBoardTiles.Count)]; BoardTile prefab = tilesetLibrary[Random.Range(0, tilesetLibrary.Length)]; Vector3 position = new Vector3(startPosition.x + (prefab.size.x * 0.5f) + (prefab.size.x * x), startPosition.y - (prefab.size.y * 0.5f) - (prefab.size.y * y), 0); BoardTile newTile = Instantiate(prefab, position + new Vector3(0f, 10f), prefab.transform.rotation, boardOrigin); tiles[x, y] = newTile; tiles[x, y].SetPosition(position); } } } yield return(new WaitForSeconds(tweenRefillRowDelay)); } // Event if (OnRefill != null) { OnRefill.Invoke(); } // --- Revalidate Board --- StartCoroutine(ValidateBoard(callback)); } else { if (OnNoMatch != null) { OnNoMatch.Invoke(); } callback?.Invoke(); } }
public void Match(IPattern parent) { OnMatch?.Invoke(parent); }
public settings_entry(string id, OnMatch match) { this.id = id; this.match = match; }
public void AddTest(string declaringType, string methodPrefix, OnMatch func) { AddTest(new NamedStackFrame(declaringType, methodPrefix, func)); }
public NamedStackFrame(string declaringType, string methodPrefix, OnMatch func) : base(methodPrefix, func) { mDeclaringType = declaringType; }
public StackFrameBase(string methodPrefix, OnMatch func) { mFunc = func; mMethodPrefix = methodPrefix; }
public MasterControllerFrame(OnMatch func) : base("", func) { }