public EntityObject(EntityType entityType, IEntityIdGenerator entityIdGenerator, IEntityChanged entityChanged) { _entityChanged = entityChanged; EntityType = entityType; if (entityType == null) { throw new ArgumentNullException(); } _fieldsKeyValue["id"] = entityIdGenerator.GetNextId(entityType.Name); }
public static void RegisterEntityChangedListener(string entityName, EntityEvent entityEvent, IEntityChanged entityChanged) { if (entityChanged == null) { throw new ArgumentNullException("entityChanged", "Behavior is null"); } if (string.IsNullOrWhiteSpace(entityName)) { throw new ArgumentNullException("entityName", "Entity name invalid"); } if (entitiesChangedListeners.Any(c => c.Key == entityName && c.Value == entityChanged)) { throw new InvalidOperationException("This event listener is already attach to this entity: " + entityName); } entitiesChangedListeners.Add(new KeyValuePair <string, IEntityChanged>(entityName, entityChanged)); }