public void MethodCallResultFilter_HandleReturnObject_NotHandledID() { var resultFilter = new MethodCallResultFilter("11"); var message = new Result() { Id = "10" }; var updated = new Updated() { Methods = new[] { "10" } }; var resultReturnedObject = new ReturnedObject("result", JObject.FromObject(message), JsonConvert.SerializeObject(message)); var updatedReturnedObject = new ReturnedObject("updated", JObject.FromObject(updated), JsonConvert.SerializeObject(updated)); resultFilter.HandleReturnObject(updatedReturnedObject); Assert.IsFalse(resultFilter.IsCompleted()); resultFilter.HandleReturnObject(resultReturnedObject); Assert.IsFalse(resultFilter.IsCompleted()); Assert.IsNull(resultFilter.GetReturnedObject()); }
protected void OnUpdate(DispatcherBase sender, UpdateEventArgs args) { Session.ResponseCallbacks.Add(args.CorrelationId, args.Data.OnDispatherResponseReceived); Updated?.Invoke(sender, args); }
private void OnUpdated() { Updated?.Invoke(this, EventArgs.Empty); }
public void FindAndAnalyzeCodeFiles(string filePattern, string directoriesToIgnore, IEnumerable <string> filesToCheck) { var extensions = LinqExtensions.ToHashSet(filePattern.Replace("*", "").Split(';'), StringComparer.InvariantCultureIgnoreCase); var directoryFilter = directoriesToIgnore.Split(';'); var lastUpdate = DateTime.Now; var timer = TimeSpan.FromMilliseconds(500); foreach (var file in GetFiles()) { if (DirectoryIsFiltered(file.Directory, directoryFilter)) { continue; } AddFile(file); if (DateTime.Now - lastUpdate > timer) { lastUpdate = DateTime.Now; Updated?.Invoke(this, EventArgs.Empty); } } return; bool DirectoryIsFiltered(FileSystemInfo dir, IEnumerable <string> directoryFilters) { return(directoryFilters.Any( filter => dir.FullName.EndsWith(filter, StringComparison.InvariantCultureIgnoreCase))); } IEnumerable <FileInfo> GetFiles() { foreach (var file in filesToCheck) { if (extensions.Contains(PathUtil.GetExtension(file))) { FileInfo fileInfo; try { fileInfo = new FileInfo(file); } catch { continue; } yield return(fileInfo); } } } void AddFile(FileInfo file) { if (!file.Exists) { return; } var codeFile = CodeFile.Parse(file); TotalLineCount += codeFile.TotalLineCount; BlankLineCount += codeFile.BlankLineCount; CommentLineCount += codeFile.CommentLineCount; DesignerLineCount += codeFile.DesignerLineCount; var extension = file.Extension.ToLower(); LinesOfCodePerExtension.TryGetValue(extension, out var linesForExtensions); LinesOfCodePerExtension[extension] = linesForExtensions + codeFile.CodeLineCount; CodeLineCount += codeFile.CodeLineCount; if (codeFile.IsTestFile || file.Directory?.FullName.Contains("test", StringComparison.OrdinalIgnoreCase) == true) { TestCodeLineCount += codeFile.CodeLineCount; } } }
protected void RaiseEventsAndNotify(AtmosphericConditionChangeResult changeResult) { Updated?.Invoke(this, changeResult); base.NotifyObservers(changeResult); }
public async Task <ICommandResult <TReply> > UpdateAsync(TReply reply) { // Validate if (reply == null) { throw new ArgumentNullException(nameof(reply)); } if (reply.Id <= 0) { throw new ArgumentOutOfRangeException(nameof(reply.Id)); } if (reply.EntityId <= 0) { throw new ArgumentOutOfRangeException(nameof(reply.EntityId)); } if (String.IsNullOrWhiteSpace(reply.Message)) { throw new ArgumentNullException(nameof(reply.Message)); } //if (reply.ModifiedUserId <= 0) //{ // throw new ArgumentOutOfRangeException(nameof(reply.ModifiedUserId)); //} //if (reply.ModifiedDate == null) //{ // throw new ArgumentNullException(nameof(reply.ModifiedDate)); //} var result = new CommandResult <TReply>(); // Ensure entity exists var entity = await _entityStore.GetByIdAsync(reply.EntityId); if (entity == null) { return(result.Failed(new CommandError($"An entity with the Id '{reply.EntityId}' could not be found"))); } // Parse Html and message abstract reply.Html = await ParseEntityHtml(reply.Message); reply.Abstract = await ParseEntityAbstract(reply.Message); reply.Urls = await ParseEntityUrls(reply.Html); // Raise updating event Updating?.Invoke(this, new EntityReplyEventArgs <TReply>(entity, reply)); // Invoke EntityReplyUpdating subscriptions foreach (var handler in _broker.Pub <TReply>(this, "EntityReplyUpdating")) { reply = await handler.Invoke(new Message <TReply>(reply, this)); } var updatedReply = await _entityReplyStore.UpdateAsync(reply); if (updatedReply != null) { // Raise Updated event Updated?.Invoke(this, new EntityReplyEventArgs <TReply>(entity, updatedReply)); // Invoke EntityReplyUpdated subscriptions foreach (var handler in _broker.Pub <TReply>(this, "EntityReplyUpdated")) { updatedReply = await handler.Invoke(new Message <TReply>(updatedReply, this)); } return(result.Success(updatedReply)); } return(result.Failed(new CommandError("An unknown error occurred whilst attempting to update the reply."))); }
public void Add(GitRevision revision, RevisionNodeFlags flags) { var parentIds = revision.ParentIds; // If we haven't seen this node yet, create a new junction. // We process revisions in reverse order. // For each revision we create a node for the revision and its parents. // Most of the time we will have a node for this revision, created for // a parent of revision processed beforehand. if (!GetOrCreateNode(revision.ObjectId, out var node) && (parentIds == null || parentIds.Count == 0)) { // The revision has not been seen yet -- it must be a leaf node. // Create a junction for it. _junctions.Add(new Junction(node)); } Count++; node.Revision = revision; node.Flags = flags; node.Index = _nodes.Count; _nodes.Add(node); var isCheckedOut = flags.HasFlag(RevisionNodeFlags.CheckedOut); foreach (var parentId in parentIds ?? Array.Empty <ObjectId>()) { GetOrCreateNode(parentId, out var parent); if (parent.Index < node.Index) { // TODO: We might be able to recover from this with some work, but // since we build the graph async it might be tough to figure out. Debug.WriteLine("The nodes must be added such that all children are added before their parents"); continue; } if (node.Descendants.Count == 1 && node.Ancestors.Count <= 1 && node.Descendants[0].Oldest == node && parent.Ancestors.Count == 0 && // If this is true, the current revision is in the middle of a branch // and is about to start a new branch. This will also mean that the last // revisions are non-relative. Make sure a new junction is added and this // is the start of a new branch (and color!) !isCheckedOut) { // The node isn't a junction point. Just the parent to the node's // (only) ancestor junction. node.Descendants[0].Add(parent); } else if (node.Ancestors.Count == 1 && node.Ancestors[0].Youngest != node) { // The node is in the middle of a junction. We need to split it. _junctions.Add(node.Ancestors[0].SplitIntoJunctionWith(node)); // The node is a junction point. We are a new junction _junctions.Add(new Junction(node, parent)); } else if (parent.Descendants.Count == 1 && parent.Descendants[0].Oldest != parent) { // The parent is in the middle of a junction. We need to split it. _junctions.Add(parent.Descendants[0].SplitIntoJunctionWith(parent)); // The node is a junction point. We are a new junction _junctions.Add(new Junction(node, parent)); } else { // The node is a junction point. We are a new junction _junctions.Add(new Junction(node, parent)); } } var isRelative = isCheckedOut || node.Descendants.Any(d => d.IsRelative); var needsRebuild = false; foreach (var ancestor in node.Ancestors) { ancestor.IsRelative |= isRelative; // Uh, oh, we've already processed this lane. We'll have to update some rows. var parent = ancestor.TryGetParent(node); if (parent != null && parent.InLane != int.MaxValue) { Debug.WriteLine("We have to start over at lane {0} because of {1}", ancestor.Oldest.Descendants.Aggregate(ancestor.Oldest.InLane, (current, dd) => Math.Min(current, dd.Youngest.InLane)), node); needsRebuild = true; break; } } if (needsRebuild) { // TODO: It would be nice if we didn't have to start completely over...but it wouldn't // be easy since we don't keep around all of the necessary lane state for each step. var lastLaneIndex = Count - 1; ClearLanes(); CacheTo(lastLaneIndex); // We need to redraw everything Updated?.Invoke(); } else { Update(node); } bool GetOrCreateNode(ObjectId objectId, out Node n) { if (!_nodeByObjectId.TryGetValue(objectId, out n)) { n = new Node(objectId); _nodeByObjectId.Add(objectId, n); return(false); } return(true); } }
/// <summary> /// Update the workflow settings /// </summary> /// <param name="settings"></param> /// <returns></returns> public void UpdateSettings(WorkflowSettingsPoco settings) { _repo.UpdateSettings(settings); Updated?.Invoke(this, new SettingsEventArgs(settings)); }
private void OnUpdated() { Updated?.Invoke(this); }
/// <summary> /// Clears search results</summary> public void ClearSearch() { m_patternTextBox.Text = string.Empty; m_patternTextRegex = string.Empty; Updated.Raise(this, EventArgs.Empty); }
protected void OnUpdated() { Updated?.Invoke(this, EventArgs.Empty); }
/// <summary> /// /// </summary> /// <param name="poco"></param> /// <returns></returns> public void UpdateTask(WorkflowTaskInstancePoco poco) { _tasksRepo.UpdateTask(poco); Updated?.Invoke(this, new TaskEventArgs(poco)); }
public void SetTimes() { UpdatedTime = Updated .FromUnix() .ConvertTimeFromCoordinates(Latitude, Longitude); }
private void update_no_validate() => Updated?.Invoke(this, new EventArgs());
public void Add(string aId, string[] aParentIds, DataType aType, GitRevision aData) { // If we haven't seen this node yet, create a new junction. if (!GetNode(aId, out var node) && (aParentIds == null || aParentIds.Length == 0)) { var newJunction = new Junction(node, node); _junctions.Add(newJunction); } _nodeCount++; node.Data = aData; node.DataType = aType; node.Index = AddedNodes.Count; AddedNodes.Add(node); foreach (string parentId in aParentIds) { GetNode(parentId, out var parent); if (parent.Index < node.Index) { // TODO: We might be able to recover from this with some work, but // since we build the graph async it might be tough to figure out. Debug.WriteLine("The nodes must be added such that all children are added before their parents"); continue; } if (node.Descendants.Count == 1 && node.Ancestors.Count <= 1 && node.Descendants[0].Oldest == node && parent.Ancestors.Count == 0 // If this is true, the current revision is in the middle of a branch // and is about to start a new branch. This will also mean that the last // revisions are non-relative. Make sure a new junction is added and this // is the start of a new branch (and color!) && (aType & DataType.Active) != DataType.Active) { // The node isn't a junction point. Just the parent to the node's // (only) ancestor junction. node.Descendants[0].Add(parent); } else if (node.Ancestors.Count == 1 && node.Ancestors[0].Youngest != node) { // The node is in the middle of a junction. We need to split it. Junction splitNode = node.Ancestors[0].Split(node); _junctions.Add(splitNode); // The node is a junction point. We are a new junction var junction = new Junction(node, parent); _junctions.Add(junction); } else if (parent.Descendants.Count == 1 && parent.Descendants[0].Oldest != parent) { // The parent is in the middle of a junction. We need to split it. Junction splitNode = parent.Descendants[0].Split(parent); _junctions.Add(splitNode); // The node is a junction point. We are a new junction var junction = new Junction(node, parent); _junctions.Add(junction); } else { // The node is a junction point. We are a new junction var junction = new Junction(node, parent); _junctions.Add(junction); } } bool isRelative = (aType & DataType.Active) == DataType.Active; if (!isRelative && node.Descendants.Any(d => d.IsRelative)) { isRelative = true; } bool isRebuild = false; foreach (Junction d in node.Ancestors) { d.IsRelative = isRelative || d.IsRelative; // Uh, oh, we've already processed this lane. We'll have to update some rows. var parent = d.TryGetParent(node); if (parent != null && parent.InLane != int.MaxValue) { int resetTo = d.Oldest.Descendants.Aggregate(d.Oldest.InLane, (current, dd) => Math.Min(current, dd.Youngest.InLane)); Debug.WriteLine("We have to start over at lane {0} because of {1}", resetTo, node); isRebuild = true; break; } } if (isRebuild) { // TODO: It would be nice if we didn't have to start completely over...but it wouldn't // be easy since we don't keep around all of the necessary lane state for each step. int lastLane = _lanes.Count - 1; _lanes.Clear(); _lanes.CacheTo(lastLane); // We need to signal the DvcsGraph object that it needs to redraw everything. Updated?.Invoke(this); } else { _lanes.Update(node); } }
public void ReplyMessageHandler_HandleMessage_HandlesUpdated() { var connectionMock = new Mock<IDdpConnectionSender>(); var collectionMock = new Mock<ICollectionManager>(); var resultHandlerMock = new Mock<IResultHandler>(); var updated = new Updated(); var handler = new ReplyMessageHandler(); handler.HandleMessage(connectionMock.Object, collectionMock.Object, resultHandlerMock.Object, JsonConvert.SerializeObject(updated)); Assert.IsTrue(handler.CanHandle(updated.MessageType)); resultHandlerMock.Verify(resultHandler => resultHandler.AddResult(It.IsAny<ReturnedObject>())); }
protected void OnUpdate(DispatcherBase sender, UpdateEventArgs args) { Updated?.Invoke(sender, args); }
protected virtual void OnUpdated(EventArgs e) { // Checks to see if there are any subscribers to Updated, if so, it invokes the event. Updated?.Invoke(this, e); }
public TEntity Update <TEntity>(TEntity entity) { Updated?.Invoke(entity); return(entity); }
public void Update(LoadBalancerName loadBalancerPolicyName) { LoadBalancerPolicyName = loadBalancerPolicyName; Updated?.Invoke(this, EventArgs.Empty); }
protected void RaiseChangedAndNotify(AccelerationConditionChangeResult changeResult) { Updated?.Invoke(this, changeResult); base.NotifyObservers(changeResult); }
private void DoUpdate(GameTime gameTime) { Updated?.Invoke(gameTime); }
// <-- Constructor. /// <summary> /// Triggers all subscribers of the event. /// </summary> public void OnUpdated(object sender, EventArgs e) { Updated?.Invoke(sender, e); }
public void Update <T>(T entity) where T : class { Updated.Add(entity); }
protected override void Update(GameTime gameTime) { Updated?.Invoke(); base.Update(gameTime); }
public void UpdatePreferences(UpdatedPreferencesEventArgs args) { SavePreferences(); Updated.Invoke(this, args); }
internal static void InvokeUpdated() { Updated?.Invoke(null, EventArgs.Empty); }
private void LoginListener() { while (!Init()) { Thread.Sleep(5000); } while (true) { try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://passport.bilibili.com/qrcode/getLoginInfo"); byte[] data = Encoding.UTF8.GetBytes("oauthKey=" + oauthKey); request.Method = "POST"; request.ContentLength = data.Length; request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8"; request.CookieContainer = new CookieContainer(); using (Stream postStream = request.GetRequestStream()) postStream.Write(data, 0, data.Length); string result; CookieCollection cookieCollection; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { cookieCollection = response.Cookies; using (Stream stream = response.GetResponseStream()) using (StreamReader reader = new StreamReader(stream)) result = reader.ReadToEnd(); } Json.Value loginInfo = Json.Parser.Parse(result); if (loginInfo["status"]) { uint uid = 0; foreach (Cookie cookie in cookieCollection) { if (cookie.Name == "DedeUserID") { uid = uint.Parse(cookie.Value); } } LoggedIn?.Invoke(this, cookieCollection, uid); break; } switch ((int)loginInfo["data"]) { case -2: if (!isTimeout) { isTimeout = true; Timeout?.Invoke(this); Stop(); } break; } Updated?.Invoke(this); } catch (WebException ex) { ConnectionFailed?.Invoke(this, ex); } Thread.Sleep(1000); } }
/// <summary> /// Event invocator for the Updated event /// </summary> /// <param name="consolidated">This is the new piece of data produced by this indicator</param> protected virtual void OnUpdated(IndicatorDataPoint consolidated) { Updated?.Invoke(this, consolidated); }
private void update(object sender = null, EventArgs e = null) => Updated?.Invoke(this, new EventArgs());
protected void RaiseChangedAndNotify(FloatChangeResult changeResult) { Updated?.Invoke(this, changeResult); base.NotifyObservers(changeResult); }
public void RaisePropertyChanged() { Updated?.Invoke(this, null); }