public void ICVF_Remove() { EntitySet <City> entitySet; EntityCollection <City> entityCollection = this.CreateEntityCollection(out entitySet); IEditableCollectionView view = this.GetIECV(entityCollection); City city = (City)view.AddNew(); city.Name = "Des Moines"; city.CountyName = "King"; city.StateName = "WA"; view.CommitNew(); entityCollection.Add(this.CreateLocalCity("Normandy Park")); entityCollection.Add(this.CreateLocalCity("SeaTac")); // This one was added through the view and will be removed from both view.Remove(city); Assert.IsFalse(entityCollection.Contains(city), "EntityCollection should no longer contain the first entity."); Assert.IsFalse(entitySet.Contains(city), "EntitySet should no longer contain the first entity."); // This one was added directly and will only be removed for the collection city = entityCollection.ElementAt(1); view.Remove(city); Assert.IsFalse(entityCollection.Contains(city), "EntityCollection should no longer contain the entity at index 1."); Assert.IsTrue(entitySet.Contains(city), "EntitySet should still contain the entity at index 1."); }
public virtual bool Contains(TInterface item) { if (item == null) { return(underlyingCollection.Contains(null)); } if (ctx != item.Context) { throw new WrongZetboxContextException(); } return(underlyingCollection.Contains((TImpl)item)); }
private void Entities_BeforeAddItem(EntityCollection sender, EntityCollectionEventArgs e) { // null items, entities already owned by another Block, attribute definitions and attributes are not allowed in the entities list. if (e.Item == null) { e.Cancel = true; } else if (entities.Contains(e.Item)) { e.Cancel = true; } else if (Flags.HasFlag(BlockTypeFlags.ExternallyDependent)) { e.Cancel = true; } else if (e.Item.Owner != null) { // if the block does not belong to a document, all entities which owner is not null will be rejected if (Record.Owner == null) { e.Cancel = true; } // if the block belongs to a document, the entity will be added to the block only if both, the block and the entity document, are the same // this is handled by the BlocksRecordCollection } else { e.Cancel = false; } }
/// <summary> /// Updates the entity location data, to the given chunk and it's tile indices /// </summary> /// <param name="entityMember">An entity component.</param> /// <param name="chunk">Chunk to place entity.</param> /// <param name="tileIndices">Tile indices in chunk to place entity.</param> /// <returns></returns> internal bool Place(EntityMember entityMember, Chunk chunk, IntegerPair tileIndices) { if (entityMember && chunk != null) { if (!IsOccupied(new Coordinates(chunk, tileIndices), entityMember.Type)) { entityMember.SetLocation(chunk, tileIndices); if (entityMember.Type == "Player" && !playerCollection.Contains(entityMember)) { playerCollection.Add(entityMember); } else if (entityMember.Type == "Mob" && !mobCollection.Contains(entityMember)) { mobCollection.Add(entityMember); } //else if other types entityMember.Placed = true; return(true); } } return(false); }
public void EntityEventsOnIndirectUpdate() { EntitySet <City> entitySet; EntityCollection <City> entityCollection = this.CreateEntityCollection(out entitySet); EntityCollectionChangedEventArgs <City> eventArgs = null; EventHandler <EntityCollectionChangedEventArgs <City> > handler = (sender, e) => { Assert.IsNull(eventArgs, "Only a single event should have occurred."); eventArgs = e; }; entityCollection.EntityAdded += handler; entityCollection.EntityRemoved += handler; // Add eventArgs = null; City city = this.CreateLocalCity("Enumclaw"); entitySet.Attach(city); Assert.IsTrue(entityCollection.Contains(city), "EntityCollection should contain entity after add."); Assert.IsNotNull(eventArgs, "Event should not be null after adding an entity."); Assert.AreEqual(city, eventArgs.Entity, "Entities should be equal after adding."); // Remove eventArgs = null; city = this.CreateLocalCity("Duvall"); entitySet.Attach(city); Assert.IsTrue(entityCollection.Contains(city), "EntityCollection should contain entity after second add."); eventArgs = null; entitySet.Detach(city); Assert.IsFalse(entityCollection.Contains(city), "EntityCollection should not contain entity after remove."); Assert.IsNotNull(eventArgs, "Event should not be null after removing an entity."); Assert.AreEqual(city, eventArgs.Entity, "Entities shoudl be equal after removing."); }
public void UpdateWatchedNpcs() { foreach (var npc in _npcSpatialMap.GetObjectsInProximityLazy(_location, 16)) { if (!watchedNpcs.Contains(npc) || watchedNpcs.Removing(npc)) { watchedNpcs.Add(npc); } } }
public void UpdateWatchedObjects() { foreach (var obj in _objectSpatialMap.GetObjectsInProximityLazy(_location, 21)) { if (obj.Active && !watchedObjects.Contains(obj)) { watchedObjects.Add(obj); } } }
public void ICVF_CancelNew() { EntitySet <City> entitySet; EntityCollection <City> entityCollection = this.CreateEntityCollection(out entitySet); IEditableCollectionView view = this.GetIECV(entityCollection); City city = (City)view.AddNew(); Assert.IsTrue(entityCollection.Contains(city), "EntityCollection should contain the second entity after AddNew."); Assert.IsTrue(entitySet.Contains(city), "EntitySet should contain the second entity after AddNew."); view.CancelNew(); Assert.IsFalse(entityCollection.Contains(city), "EntityCollection should no longer contain the second entity after CancelNew."); Assert.IsFalse(entitySet.Contains(city), "EntitySet should no longer contain the second entity after CancelNew."); }
public void ContainsReturnsTrueWhenAddedListContainsEntity() { var player = Container.Resolve <IPlayer>(); var entities = new EntityCollection <IPlayer>(); entities.Add(player); var addedListContains = entities.Contains(player); Assert.True(addedListContains); }
private void LoadRepairCardInfo(RepairCard repairCard) { this.repairCardIdLbl.Text = repairCard.CardId.ToString(); this.operatorLbl.Text = repairCard.aspnet_Users.UserName; List <Automobile> automobiles = new List <Automobile>(); automobiles.Add(repairCard.Automobile); var customAutomobileFormat = from auto in automobiles select new { AutomobileId = auto.AutomobileId, AutomobileRepresentation = auto.Vin + " / " + auto.ChassisNumber }; this.automobileDropDown.DataSource = customAutomobileFormat; this.automobileDropDown.DataBind(); this.sparePartsPrice.Text = repairCard.PartPrice.ToString(); this.repairPrice.Text = repairCard.CardPrice.ToString(); CultureInfo englishCultureInfo = new CultureInfo(CarServiceConstants.ENGLISH_CULTURE_INFO); this.startRepairDate.SelectedDate = repairCard.StartRepair.ToString(CarServiceConstants.DATE_FORMAT, englishCultureInfo); DateTime?finishRepairDate = repairCard.FinishRepair; if (finishRepairDate.HasValue) { this.finishRepairDate.SelectedDate = finishRepairDate.Value.ToString(CarServiceConstants.DATE_FORMAT, englishCultureInfo); DisableAllInputControls(); } else { this.finishRepairDate.Enabled = true; } EntityCollection <SparePart> selectedParts = repairCard.SpareParts; List <SparePart> unselectedParts = new List <SparePart>(); IQueryable <SparePart> activeSpareParts = this.persister.GetActiveSpareParts(); foreach (SparePart part in activeSpareParts) { if (selectedParts.Contains(part) == false) { unselectedParts.Add(part); } } object customUnselectedSpareParts = CarServicePresentationUtility.GetSparePartsFormatForListBox(unselectedParts); object customSelectedSpareParts = CarServicePresentationUtility.GetSparePartsFormatForListBox(selectedParts); CarServicePresentationUtility.BindListBox(this.unselectedSpareParts, customUnselectedSpareParts); CarServicePresentationUtility.BindListBox(this.selectedSpareParts, customSelectedSpareParts); this.repairCardDescription.Text = repairCard.Description; }
public void ICVF_AddNew() { EntitySet <City> entitySet; EntityCollection <City> entityCollection = this.CreateEntityCollection(out entitySet); IEditableCollectionView view = this.GetIECV(entityCollection); City city = (City)view.AddNew(); Assert.IsTrue(entityCollection.Contains(city), "EntityCollection should contain the first entity after AddNew."); Assert.IsTrue(entitySet.Contains(city), "EntitySet should contain the first entity after AddNew."); city.Name = "Burien"; city.CountyName = "King"; city.StateName = "WA"; view.CommitNew(); Assert.IsTrue(entityCollection.Contains(city), "EntityCollection should contain the first entity after CommitNew."); Assert.IsTrue(entitySet.Contains(city), "EntitySet should contain the first entity after CommitNew."); }
public void ContainsExactEntity() { var entityCollection = new EntityCollection <EntityCollectionModel>(); var entity = new EntityCollectionModel { Id = "ABC" }; entityCollection.Add(entity); Assert.IsTrue(entityCollection.Contains(entity)); }
public static void Add(string key, IEntity entity) { if (entity == null || entity.Deleted) { return; } EntityCollection col = GetCollection(key); if (col != null && !col.Contains(entity)) { col.Add(entity); } }
public void ContainsReturnsTrueWhenKnownListContainsEntity() { var player = Container.Resolve <IPlayer>(); var entities = new EntityCollection <IPlayer>(); entities.Add(player); entities.Update(); // Verify that player is no longer in the 'added' list. Assert.False(entities.AddedReadOnly.Contains(player)); var knownListContains = entities.Contains(player); Assert.True(knownListContains); }
private void Entities_BeforeAddItem(EntityCollection sender, EntityCollectionEventArgs e) { // null or duplicate items are not allowed in the entities list. if (e.Item == null) { e.Cancel = true; } else if (entities.Contains(e.Item)) { e.Cancel = true; } else { e.Cancel = false; } }
public void AllChildrenAddedWhenEntityIsAdded() { var entity0 = new Entity(new VariableCollection()); var entity1 = new Entity(new VariableCollection()); var entity2 = new Entity(new VariableCollection()); var entity3 = new Entity(new VariableCollection()); entity1.Parent = entity0; entity2.Parent = entity0; entity3.Parent = entity1; collection.Add(entity0); Assert.IsTrue(collection.Contains(entity0)); Assert.IsTrue(collection.Contains(entity1)); Assert.IsTrue(collection.Contains(entity2)); Assert.IsTrue(collection.Contains(entity3)); }
public void ContainsEntityById() { var entityCollection = new EntityCollection <EntityCollectionModel>(); var entity = new EntityCollectionModel { Id = "ABC", Title = "1" }; entityCollection.Add(entity); var idMatchingEntity = new EntityCollectionModel { Id = "ABC" }; Assert.IsTrue(entityCollection.Contains(idMatchingEntity)); }
public void ShouldDeleteEntity() { Entity entity = new Entity(); if (plugin == null) { plugin = new PersistencePlugin(); plugin.Initialize(); } World.Instance.Add(entity); World.Instance.Remove(entity); if (!plugin.GlobalSession.IsOpen) { plugin.GlobalSession = plugin.SessionFactory.OpenSession(); } plugin.RetrieveEntitiesFromDatabase(); Assert.False(entityRegistry.Contains(entity)); }
public void Contains_ID_ReturnsFalseForEmptyCollection() { EntityCollection <IOsmGeometry> target = new EntityCollection <IOsmGeometry>(); Assert.False(target.Contains(_data[0].ID)); }
public bool Contains(object value) { return(collection.Contains((T)value)); }
/// <exception cref="InstanceNotFoundException"/> private bool checkMatchLabels(List<string> list, EntityCollection<Label> labels) { foreach (string str in list) { Label l = labelDao.findByName(StrNormalize.strNormalize(str));//labelDao.findByName(StrRegression.removeAccents(str).ToLower()); if (!labels.Contains(l)) return false; } return true; }
public void Contains_ID_ReturnsTrueIfCollectionContainsEntity() { EntityCollection <IOsmGeometry> target = new EntityCollection <IOsmGeometry>(_data); Assert.True(target.Contains(_data[0].ID)); }
public void Contains_ID_ReturnsFalseIfCollectionDoesNotContainEntity() { EntityCollection <IOsmGeometry> target = new EntityCollection <IOsmGeometry>(_data.Skip(1)); Assert.False(target.Contains(_data[0].ID)); }
public void Contains_IOsmGeometry_ReturnsFalseForNull() { EntityCollection <IOsmGeometry> target = new EntityCollection <IOsmGeometry>(); Assert.False(target.Contains(null)); }