public void DeleteGeometry(LevelGeometry geometry) { Assure.NotNull(geometry); lock (instanceMutationLock) { Assure.True(this.geometry.Contains(geometry)); levelGeometryEntities.RemoveWhere(e => e.Geometry == geometry); this.geometry.Remove(geometry); } }
private void ViewModel_OnPresenterNeedsToClearBackStack(object sender, EventArgs e) { foreach (var viewController in MyNavigationController.ViewControllers.Where(i => i != MyNavigationController.TopViewController)) { viewController.WillMoveToParentViewController(null); viewController.View.RemoveFromSuperview(); viewController.RemoveFromParentViewController(); _liveViews.RemoveWhere(i => i.Item2 == viewController); } }
public static void RemoveFrameServerVideoEffect(MediaPlayer mediaPlayer) { frameServerHandlers.RemoveWhere(h => { if (h.Player == mediaPlayer) { h.Dispose(); return(true); } return(false); }); }
public static void Update() { List <AnimationParticle> removed = new List <AnimationParticle>(); foreach (AnimationParticle p in Particles) { p.frames_left--; if (p.frames_left <= 0) { removed.Add(p); } else { if (p.dy != null) { p.row += p.dy.GetValue(); } if (p.dx != null) { p.col += p.dx.GetValue(); } } } foreach (AnimationParticle p in removed) { Particles.Remove(p); } Generators.RemoveWhere(g => !g.Update(Particles)); //GLGame.particle_surface.Disabled = false; Game.gl.UpdateParticles(GLGame.particle_surface, Particles); //Game.gl.Render(); //Thread.Sleep(20); //GLGame.particle_surface.Disabled = true; //GLGame.particle_surface.NumElements = 0; }
private T MakeRequest <T>(Uri url) { var now = DateTime.Now; if (_requestTimes.Count >= _maxRequestsPer10Min) { var firstTime = _requestTimes[0]; var elapsed = now - firstTime; if (elapsed <= _10Min) { throw new InvalidOperationException(LocalizedStrings.Str3310Params .Put(elapsed.TotalMinutes, _requestTimes.Count)); } _requestTimes.RemoveWhere(t => t < (now - _10Min)); } _requestTimes.Add(now); using (var client = new WebClient()) { var txt = client.DownloadString(url); this.AddDebugLog("Request '{0}' Response '{1}'.", url, txt); return(txt.IsEmpty() ? default(T) : JsonConvert.DeserializeObject <T>(txt)); } }
//移除实物整编结点 public JsonResult RemoveReorganizeNode(string nodeID, string ReorganizeID) { string spaceID = GetQueryString("SpaceID"); var space = FormulaHelper.GetEntities <DocConfigEntities>().S_DOC_Space.FirstOrDefault(a => a.ID == spaceID); List <S_R_Reorganize_DocumentList> fileDetailList = entities.Set <S_R_Reorganize_DocumentList>().Where(a => a.S_R_ReorganizeID == ReorganizeID && a.ReorganizeFullID.Contains(nodeID)).ToList(); if (fileDetailList.Count > 0) { throw new Formula.Exceptions.BusinessException("有归档文件,不可移除"); } S_R_Reorganize PhysicalData = entities.Set <S_R_Reorganize>().FirstOrDefault(a => a.ID == ReorganizeID); List <string> nodeIDs = PhysicalData.SelectNodeIDs.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList <string>();//全部路径ID string fullIDSql = "select FullPathID from S_NodeInfo where ID='" + nodeID + "'"; SQLHelper sqlHelper = SQLHelper.CreateSqlHelper(space.SpaceKey, space.ConnectString); string fullID = sqlHelper.ExecuteScalar(fullIDSql).ToString(); //得到移除节点的全路径 string sql = @"select ID from S_NodeInfo where FullPathID like '" + fullID + "%'"; //得到移除节点及子节点ID DataRowCollection rows = sqlHelper.ExecuteDataTable(sql).Rows; List <string> listIDs = new List <string>(); foreach (DataRow row in rows) { listIDs.Add(row["ID"].ToString()); } nodeIDs.RemoveWhere(a => listIDs.Contains(a.ToString())); PhysicalData.SelectNodeIDs = string.Join(",", nodeIDs); entities.SaveChanges(); return(Json("")); }
public void Remove(ErrorMessageType type) { lock (_errorMessages) { _errorMessages.RemoveWhere(e => e.Type == type); UpdateInfoBarItem(_errorMessages.Count > 0 ? _errorMessages[0].Message : null); } }
/// <summary> /// Recalculates the entire routing table on a separate thread. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CalculateRoutingTable(object sender, EventArgs <ScheduledTaskRunningReason> e) { lock (m_syncRoot) { //Some other thread won on the race condition. if (RoutingTablesValid) { return; } var subscribers = new List <LogSubscriberInternal>(m_subscribers.Count); m_subscribers.RemoveWhere(x => { LogSubscriberInternal subscriber = (LogSubscriberInternal)x.Target; if (subscriber != null) { subscribers.Add(subscriber); return(false); } return(true); }); foreach (var pub in m_allPublishers) { CalculateRoutingTableForPublisherSync(subscribers, pub); } RoutingTablesValid = true; } }
public void RemoveWhere() { var list = new List <string> { "hello", "world", "this", "is", "another", "test" }; list.RemoveWhere(x => x.Contains('i')) .Should() .BeTrue("there is an item that contains the letter 'i'"); list.Should() .NotContain("this", "that was the first item that contains an 'i'") .And .NotContain("is", "that was the other item that contains an 'i'") .And .HaveCount(4, "two items should be removed"); list = new List <string> { "hello", "world", "this", "is", "another", "test" }; list.RemoveWhere(x => x == "doesn't exist") .Should() .BeFalse("there is no item that is 'doesn't exist'"); list.Should() .HaveCount(6); }
public static IPolygon GetConcaveHull(List <Coordinate> points, double concavity, double maxLenght) { //создаем convexhull var hull = (new ConvexHull(points.ToArray(), NetTopologySuite.Geometries.GeometryFactory.Default)).GetConvexHull(); List <Coordinate> coords = hull.Coordinates.ToList(); //удаляем первую точку для того что бы получить кольцо из точек coords.RemoveAt(0); foreach (var c in coords) { points.RemoveWhere(x => x.X == c.X && x.Y == c.Y); } var factory = NetTopologySuite.Geometries.Geometry.DefaultFactory; for (int i = 0; i < coords.Count; i++) { ClearLines(coords); var line = factory.CreateLineString(new Coordinate[] { GetElement(coords, i), GetElement(coords, i + 1) }); if (line.Length <= maxLenght) { continue; } //берем левого и правого соседа отрезка var leftLine = factory.CreateLineString(new Coordinate[] { GetElement(coords, i - 1), GetElement(coords, i) }); var rightLine = factory.CreateLineString(new Coordinate[] { GetElement(coords, i + 1), GetElement(coords, i + 2) }); //находим ближайшую точку от центра отрезка, но что бы соседнии линии не были к ней ближе var nearestPoint = GetNearestPoint(points, line, leftLine, rightLine); if (nearestPoint.Item1 == null) { continue; } var eh = line.Length; var dd = nearestPoint.Item2; //находм соотножение отрезка к расстоянию до точки и проверяем не будут ли новые отрезки пересекать область if ((eh / dd) > concavity && !IsIntersectsLines(line, nearestPoint.Item1, coords)) { //добавляем новую точку между точками основного отрезка coords.Insert((i + 1) % points.Count, nearestPoint.Item1); //удаляем из точек ближайшую точку для избежания повторной привязки к ней points.RemoveWhere(x => x.X == nearestPoint.Item1.X && x.Y == nearestPoint.Item1.Y); i = -1; } } //замыкаем коллекцию точек для конвертации в полигон coords.Add(coords.First()); return(factory.CreatePolygon(coords.ToArray())); }
public void WhenSourceIsEmpty_ThenRemoveNothing() { ICollection <int> sut = new List <int>(); sut.RemoveWhere(x => x == 1); Assert.That(sut, Is.Empty); }
public void WhenPredicateIsNull_ThenThrowException() { ICollection <int> sut = new List <int> { 1, 2, 3 }; Assert.Throws <ArgumentNullException>(() => sut.RemoveWhere(null)); }
void RemoveUnauthorizedItems(List <MenuItemViewModel> root) { root.RemoveWhere(_ => !_.IsAuthorized(User)); foreach (var childs in root) { RemoveUnauthorizedItems(childs.Childs); } }
public static List <pos> SharedNeighbors(this pos p, pos other, bool return_origins_if_adjacent) { List <pos> result = p.PositionsWithinDistance(1, !return_origins_if_adjacent, true); List <pos> others = other.PositionsWithinDistance(1, !return_origins_if_adjacent, true); result.RemoveWhere(x => !others.Contains(x)); return(result); }
public void ThrowsOnRemoveWhereNullItems() { var tested = new List <string> { "one" }; Assert.Throws <ArgumentNullException>("predicate", () => tested.RemoveWhere(null)); }
public void UnregisterValueChangedHander(DependencyProperty property, EventHandler handler) { handlers.RemoveWhere(x => x.Item1 == property && x.Item2 == handler); if (handlerRegistered) { DetachHandler(property, handler); } }
public void Remove(ErrorMessageType type) { lock (_errorMessages) { _errorMessages.RemoveWhere(e => e.Type == type); _viewModel.FirstError = _errorMessages.Count > 0 ? _errorMessages[0].Message : null; _viewModel.HasMultipleErrors = _errorMessages.Count > 1; } }
private void Strokes_PointsChanged(object sender, SwarmObjectiveStrokes.PointsChangedArgs e) { try { switch (e.ChangeType) { case SwarmObjectiveStrokes.PointChangeType.AddingPointsToStroke: // Just draw the points in a simple way break; case SwarmObjectiveStrokes.PointChangeType.AddNewStroke: case SwarmObjectiveStrokes.PointChangeType.ConvertStroke_Add: #region add stroke if (e.Points == null || e.Points.Length == 0) { throw new ArgumentException("Added stroke is empty"); } else if (e.StrokeToken == null) { throw new ArgumentException("Expected token to be populated for a new stroke"); } foreach (Visual3D visual in GetStrokeVisual(e.Points)) { _strokeVisuals.Add(Tuple.Create(e.StrokeToken.Value, visual)); _viewport.Children.Add(visual); } #endregion break; case SwarmObjectiveStrokes.PointChangeType.ConvertStroke_Remove: case SwarmObjectiveStrokes.PointChangeType.RemoveStroke_Clear: case SwarmObjectiveStrokes.PointChangeType.RemoveStroke_Remove: case SwarmObjectiveStrokes.PointChangeType.RemoveStroke_Timeout: if (e.StrokeToken == null) { // Remove the pre stroke } else { // Remove the full stroke _viewport.Children.RemoveAll( _strokeVisuals.RemoveWhere(o => o.Item1 == e.StrokeToken.Value). Select(o => o.Item2)); } break; default: throw new ApplicationException("Unknown SwarmObjectiveStrokes.PointChangeType: " + e.ChangeType.ToString()); } } catch (Exception ex) { MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error); } }
public void RemoveWhere() { List <int> list = new List <int> { -2, 3, -5, 1, 5, -10 }; list.RemoveWhere(x => x < 0); CollectionAssert.AreEqual(new[] { 3, 1, 5 }, list); }
public void RemoveWhere_Method_Should_Throw_ArgumentNullException_When_Passed_Collection_Is_Null() { // Arrange ICollection <int> collection = new List <int>(); // Act // Assert Assert.Throws <ArgumentNullException>(() => collection.RemoveWhere(null)); }
public void WhereMatchesCondition_ThenRemoveElements() { ICollection <int> sut = new List <int> { 1, 2, 3, 1, 2 }; sut.RemoveWhere(x => x == 1 || x == 2); Assert.That(sut.Single(), Is.EqualTo(3)); }
public void RemoveWhere() { var @this = new List <string> { "zA", "zB", "C" }; @this.RemoveWhere(x => x.StartsWith("z")); Assert.AreEqual(1, @this.Count); }
private void RemoveClass(ViewItemClass c) { if (TrackChanges) { _addedClasses.RemoveWhere(i => i == c); base.StopObservingCollection(c.Schedules); c.PropertyChanged -= _classPropertyChangedEventHandler; } IListExtensions.RemoveWhere(this, i => i.Class == c); }
/// <summary> /// Closes any listening connections if exists and removes handler for hello command. /// </summary> public void Close() { NetworkComms.RemoveGlobalIncomingPacketHandler("Discover"); __listeners.ToList().ForEach(@base => { try { Connection.StopListening(@base); } catch (Exception) {} }); __listeners.RemoveWhere(@base => [email protected]); }
public void RemoveWhere_ForList_ProvidesCorrectIndex() { var list = new List <int> { 0, 1, 2, 3 }; list.RemoveWhere((item, index) => { Assert.Equal(item, index); return(false); }); }
static void Main(string[] args) { var genericList = new List <String>() { "a", "b" }; var listImplementation = new MyList(); var resultGeneric = genericList.RemoveWhere(x => x.Contains("s")); var resultImplemented = listImplementation.RemoveWhere(x => x.Equals(1)); }
public void RemoveWhere_Method_Should_Remove_Null_Empty_Or_Only_White_Spaces_Strings_From_The_Collection(IEnumerable <string> inittialItems, IEnumerable <string> expectedResult) { // Arrange ICollection <string> collection = new List <string>(inittialItems); // Act collection.RemoveWhere(s => string.IsNullOrWhiteSpace(s)); // Assert Assert.Equal(expectedResult, collection); }
public void RemoveWhere() { var testValue = new List <int> { 1, 2, 4, 5, 7, 8 }; testValue.RemoveWhere(n => (n & 1) == 1); var expected = new[] { 2, 4, 8 }; Assert.IsTrue(testValue.SequenceEqual(expected)); }
public void CanRemoveWhere() { var tested = new List <string> { "one", "two" }; tested.RemoveWhere(x => x == "one"); Assert.Single(tested); Assert.Contains("two", tested); }
/// <inheritdoc /> public MethodDef GetRuntimeDecompressor(ModuleDef module, Action <ISDnlibDef> init) { Tuple <MethodDef, List <ISDnlibDef> > decompressor = context.Annotations.GetOrCreate(module, Decompressor, m => { var rt = context.Registry.GetService <IRuntimeService>(); List <ISDnlibDef> members = InjectHelper.Inject(rt.GetRuntimeType("Confuser.Runtime.Lzma"), module.GlobalType, module).ToList(); MethodDef decomp = null; foreach (ISDnlibDef member in members) { if (member is MethodDef) { var method = (MethodDef)member; if (method.Access == MethodAttributes.Public) { method.Access = MethodAttributes.Assembly; } if (!method.IsConstructor) { method.IsSpecialName = false; } if (method.Name == "Decompress") { decomp = method; } } else if (member is FieldDef) { var field = (FieldDef)member; if (field.Access == FieldAttributes.Public) { field.Access = FieldAttributes.Assembly; } if (field.IsLiteral) { field.DeclaringType.Fields.Remove(field); } } } members.RemoveWhere(def => def is FieldDef && ((FieldDef)def).IsLiteral); Debug.Assert(decomp != null); return(Tuple.Create(decomp, members)); }); foreach (ISDnlibDef member in decompressor.Item2) { init(member); } return(decompressor.Item1); }
public static List<AnimationParticle> Particles = new List<AnimationParticle>(); //todo: move animations to their own file. Let generators chain into other generators for complex and repeating effects. #endregion Fields #region Methods public static void DoStuffTodoRename(int num_per_frame_todo,int duration_todo,int num_frames_todo) { GLGame.particle_surface.Disabled = false; List<AnimationParticle> l = new List<AnimationParticle>(); float player_row = (float)Actor.player.row - 0.325f; float player_col; { int graphics_mode_first_col = Screen.screen_center_col - 16; int graphics_mode_last_col = Screen.screen_center_col + 16; if(graphics_mode_first_col < 0){ graphics_mode_last_col -= graphics_mode_first_col; graphics_mode_first_col = 0; } else{ if(graphics_mode_last_col >= Global.COLS){ int diff = graphics_mode_last_col - (Global.COLS-1); graphics_mode_first_col -= diff; graphics_mode_last_col = Global.COLS-1; } } player_col = (float)(Actor.player.col - graphics_mode_first_col) + 0.4375f; } float dx = 0.1f; float dy = 0.1f; for(int time=0;time<num_frames_todo + duration_todo - 1;++time){ for(int num=0;num<num_per_frame_todo;++num){ l.Add(new AnimationParticle(time+duration_todo,player_row + (float)(R.Between(-100,100)) / 10,player_col + (float)(R.Between(-100,100)) / 10,0,0,5,3,Color4.Magenta,Color4.Yellow)); //l.Add(new AnimationParticle(time+duration_todo,player_col,player_row,0,0,5,3,Color4.DarkRed,Color4.Cyan)); //todo } l.RemoveWhere(p => time >= p.frames_left); foreach(AnimationParticle p in l){ p.col += dx; p.row += dy; } Game.gl.UpdateParticles(GLGame.particle_surface,l); Game.gl.Render(); //todo: update or render? Thread.Sleep(20); } GLGame.particle_surface.Disabled = true; GLGame.particle_surface.NumElements = 0; }
public void SmoothCorners(int percent_chance) { List<pos> corners = new List<pos>(); for(int i=1;i<H-1;++i){ for(int j=1;j<W-1;++j){ if(IsCornerFloor(i,j)){ corners.Add(new pos(i,j)); } } } while(corners.Count > 0){ pos p = corners.RemoveRandom(); corners.RemoveWhere(x=>x.DistanceFrom(p) <= 1); if(R.PercentChance(percent_chance)){ map[p] = CellType.Wall; } } }