public void Dispose() { Entites.ForEach((t) => { t.Entities = null; }); EntityCreated = null; ContextModifed = null; }
public static void Tick() { GlobalTicks++; Entites.ForEach(x => x.Tick()); Entites.Where(x => x.Position == Player.Position).ToList().ForEach(x => x.OnCollide(Player)); if (Exit.Position == Player.Position) { Exit.OnCollide(Player); } }
internal Context InitailizeRows(EntitiesContext mctx, Dictionary <string, Func <object, object> > ini) { Entites.ForEach((e) => { e.Entities = ini[e.Name](mctx).CastToType <IEnumerable <Entity> >(); IEntityCollection collection = e.Entities as IEntityCollection; if (collection.IsNotNull()) { collection.Context = this; } }); return(this); }
internal Context Copy() { Context ctx = new Context() { Name = this.Name }; Entites.ForEach((t) => { EntityClass entity = new EntityClass() { Name = t.Name, EntityType = t.EntityType, PrimaryKey = t.PrimaryKey, }; entity.Validators.AddRange(t.Validators); entity.Attributes.AddRange(t.Attributes); t.SynchronizedCollection.Keys.ToList().ForEach((s) => { entity.SynchronizedCollection.Add(s, new List <string>(t.SynchronizedCollection[s])); }); ctx.Entites.Add(entity); }); Relations.ForEach((r) => { EntitiesRelation relation = new EntitiesRelation() { Ordinal = r.Ordinal, Name = r.Name, Parent = new EntityRelated() { EntityName = r.Parent.EntityName, Key = r.Parent.Key, Type = r.Parent.Type, Value = r.Parent.Value }, Child = new EntityRelated() { EntityName = r.Child.EntityName, Key = r.Child.Key, Type = r.Child.Type, Value = r.Child.Value }, OnDelete = r.OnDelete }; ctx.Relations.Add(relation); relation.Parent.Entity = ctx.Entites.FirstOrDefault(t => t.Name == r.Parent.EntityName); relation.Child.Entity = ctx.Entites.FirstOrDefault(t => t.Name == r.Child.EntityName); }); ctx.Entites.ForEach((t) => { EntityClass entity = Entites.FirstOrDefault(e => e.Name == t.Name); Debug.Assert(entity.IsNotNull(), "Somthing gone wrrong"); entity.Properties.ForEach((p) => { EntityProperty property = new EntityProperty() { Name = p.Name, PropertyType = p.PropertyType, PrimaryKey = p.PrimaryKey, DefaultValue = p.DefaultValue, Setter = p.Setter, Getter = p.Getter }; if (p.ReletedEntity.IsNotNull()) { property.ReletedEntity = new ReletedEntity() { Related = p.ReletedEntity.Related, RelatedEntity = ctx.Entites.FirstOrDefault(e => e.Name == p.ReletedEntity.RelatedEntityName), RelatedEntityName = p.ReletedEntity.RelatedEntityName, Relation = ctx.Relations.FirstOrDefault(r => r.Ordinal == p.ReletedEntity.Relation.Ordinal), RelationName = p.ReletedEntity.RelationName }; property.ReletedEntity.Discriminators.AddRange(p.ReletedEntity.Discriminators); } property.Validators.AddRange(p.Validators); property.Attibutes.AddRange(p.Attibutes); p.Formatters.Keys.ToList().ForEach((k) => property.Formatters.Add(k, p.Formatters[k])); t.Properties.Add(property); }); if (entity.PrimaryKeyProperty.IsNotNull()) { t.PrimaryKeyProperty = t.Properties.FirstOrDefault(p => p.Name == entity.PrimaryKeyProperty.Name); } if (entity.DynamicProperties.IsNotNull()) { t.DynamicProperties = new DynamicProperties() { CodeProperty = entity.DynamicProperties.CodeProperty, Property = t.Properties.FirstOrDefault(p => p.Name == entity.DynamicProperties.Property.Name) }; entity.DynamicProperties.ValuesProperties.Keys.ToList().ForEach((type) => { t.DynamicProperties.ValuesProperties.Add(type, entity.DynamicProperties.ValuesProperties[type]); }); } }); return(ctx); }