public EntityDataLink(Group @group, int index, EntityTypeData data) { Index = index; Data = data; this.@group = @group; AddedEntities = new ArrayList <Entity>(4); }
internal void OnEntityTypeAdd(EntityTypeData data) { var entityType = data.EntityType; if (IsEntityTypeMatching(ref entityType)) { EntityDataLink link = new EntityDataLink(this, entityTypeDatas.Count, data); if (this is IEntityAddedListener addedListener) { link.addedListener = addedListener; data.addedListeners.Add(link); } if (this is IEntityRemovingListener removingListener) { link.removingListener = removingListener; data.removingListeners.Add(link); } // Call added listener for all existing entities for (int i = 0; i < data.count; i++) { link.OnEntityAdded(data.entityArray[i], null); } entityTypeDatas.Add(link); foreach (var componentArray in componentCollections) { componentArray.AddArray(data); } } }
/// <summary> /// Initialize the Entity /// </summary> /// <param name="Context">The executable context of the entity</param> public virtual void Init(IExecutableContext Context) { mLogger.Info(string.Format("Initializing Entity '{0}'", mName)); mContext = Context; mContext.Entity = this; //Read in the entities components here string path = Context.ConfigManager.FindEntityType(mData.Type); EntityTypeData typeData = DataContractFactory.DeserializeObject <EntityTypeData>(path); foreach (string entry in typeData.Components) { try { mLogger.Info(string.Format("Creating component '{0}' for entity '{1}'", entry, mName)); Type componentType = Type.GetType(entry); Object[] objArray = {}; IComponent component = (IComponent)Activator.CreateInstance(componentType, objArray); component.Init(mContext, mData.DataSet); mComponents.Add(component); } catch (Exception e) { mLogger.Error(string.Format("Failed to create component '{0}' for entity '{1}", entry, mName), e); } } mContext.MessageRouter.RegisterTopic(mName, this); mLogger.Info(string.Format("Finished Initializing Entity '{0}'", mName)); }
} // Map function closer public List <SqlParameter> MapParamsForUpsert(EntityTypeData entity) { var sql_params = new List <SqlParameter>(); sql_params.Add(new SqlParameter("@entity_type_key", entity.EntityTypeKey)); sql_params.Add(new SqlParameter("@entity_type_code", entity.EntityTypeCode)); sql_params.Add(new SqlParameter("@entity_type_name", entity.EntityTypeName)); sql_params.Add(GetOutParam()); return(sql_params); }
public EntityType(EntityTypeData accountTypeData) { EntityTypeKey = accountTypeData.EntityTypeKey; EntityTypeCode = accountTypeData.EntityTypeCode; EntityTypeName = accountTypeData.EntityTypeName; EntityTypeDesc = accountTypeData.EntityTypeDesc; AddedDateTime = accountTypeData.AuditAddDatetime; AddedUserID = accountTypeData.AuditAddUserId; UpdateDateTime = accountTypeData.AuditUpdateDatetime; UpdateUserID = accountTypeData.AuditUpdateUserId; }
public void CreateEntityTypeDataWithMultipleAttributes() { // Arrange EntityTypeData <EntityWithMultipleAttributes> typeData = null; // Act Assert.Throws <InvalidOperationException>(() => { typeData = new EntityTypeData <EntityWithMultipleAttributes>(); }); // Assert Assert.Null(typeData); }
public void CreateEntityTypeDataWithIvalidProperties() { // Arrange EntityTypeData <EntityWithProperties> typeData = null; // Act Assert.Throws <ArgumentException>(() => { typeData = new EntityTypeData <EntityWithProperties>(); }); // Assert Assert.Null(typeData); }
public void CreateEntityTypeDataWithIvalidProperties() { // Arrange EntityTypeData<EntityWithProperties> typeData = null; // Act Assert.Throws<ArgumentException>(() => { typeData = new EntityTypeData<EntityWithProperties>(); }); // Assert Assert.Null(typeData); }
public void CreateEntityTypeDataWithoutCompositeKey() { // Arrange EntityTypeData <EntityWithoutCompositeKey> typeData = null; // Act Assert.Throws <InvalidOperationException>(() => { typeData = new EntityTypeData <EntityWithoutCompositeKey>(); }); // Assert Assert.Null(typeData); }
public EntityType(EntityTypeData entityTypeData) { if (entityTypeData == null) { throw new ArgumentNullException(nameof(entityTypeData)); } EntityTypeId = entityTypeData.EntityTypeId; EntityTypeCode = entityTypeData.EntityTypeCode; EntityTypeName = entityTypeData.EntityTypeName; EntityTypeDesc = entityTypeData.EntityTypeDesc; EntityTypeCategory = entityTypeData.EntityTypeCategory; }
public void CreateEntityTypeDataWithSerializableAttribute() { // Arrange var entityTypeData = new EntityTypeData <EntityWithSerializeAttribute>(); // Assert Assert.NotNull(entityTypeData); Assert.NotNull(entityTypeData.NameChanges); Assert.Equal("PartitionKey", entityTypeData.NameChanges[nameof(EntityWithSerializeAttribute.Pk)]); Assert.Equal("RowKey", entityTypeData.NameChanges[nameof(EntityWithSerializeAttribute.Rk)]); Assert.Equal("NestedSerialized", entityTypeData.NameChanges[nameof(EntityWithSerializeAttribute.Nested)]); }
protected override void Seed(DurandalAuthDbContext context) { var userManager = new UserManager <UserProfile>(new UserStore <UserProfile>(context)); var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(context)); if (!roleManager.RoleExists("Administrator")) { roleManager.Create(new IdentityRole("Administrator")); } if (!roleManager.RoleExists("User")) { roleManager.Create(new IdentityRole("User")); } if (userManager.FindByName("admin") == null) { var user = new UserProfile { UserName = "******", Email = "*****@*****.**", EmailConfirmed = true }; var result = userManager.Create(user, "admin1234"); if (result.Succeeded) { userManager.AddToRole(user.Id, "Administrator"); } } var uow = new DurandalAuthDbContext(); var hasChanges = false; //SetCategoryData(uow); ProvinceData.SetProvinceData(uow, ref hasChanges); GenderData.SetGenderData(uow, ref hasChanges); // EthnicityData.SetEthnicityData(uow, ref hasChanges); //LanguageData.SetLanguageData(uow, ref hasChanges); EmploymentData.SetEmploymentStatus(uow, ref hasChanges); /* PsiraGradeData.SetPsiraGradeData(uow, ref hasChanges); * SecurityTrainingData.SetSecurityTrainingData(uow, ref hasChanges);*/ DecisionData.SetYesNoLookupData(uow, ref hasChanges); //PsiraCategoryData.SetPsiraCategoryLookup(uow, ref hasChanges); //CityData.SetCityNameData(uow, ref hasChanges); AddressData.SetAddressData(uow, ref hasChanges); //MaritalStatusData.SetMaritalStatusData(uow, ref hasChanges); EntityTypeData.SetEntityData(uow, ref hasChanges); TitleData.SetTitleData(uow, ref hasChanges); if (hasChanges) { uow.SaveChanges(); } }
public void GetTableEntityFromNull() { // Arrange var entityTypeData = new EntityTypeData <Entity>(); ITableEntity entity = null; // Act Assert.Throws <ArgumentNullException>(() => { entity = entityTypeData.GetEntity((Entity)null); }); // Assert Assert.Null(entity); }
public void GetPocoEntityFromNull() { // Arrange var entityTypeData = new EntityTypeData<Entity>(); Entity entity = null; // Act Assert.Throws<ArgumentNullException>(() => { entity = entityTypeData.GetEntity((DynamicTableEntity)null); }); // Assert Assert.Null(entity); }
public void CreateEntityTypeDataWithDifferentAccessors() { // Arrange & Act var entityTypeData = new EntityTypeData<Entity>(); // Assert Assert.NotNull(entityTypeData); Assert.NotNull(entityTypeData.NameChanges); Assert.True(entityTypeData.NameChanges.ContainsKey("FirstName")); Assert.Equal(entityTypeData.NameChanges["FirstName"], "PartitionKey"); Assert.True(entityTypeData.NameChanges.ContainsKey("LastName")); Assert.Equal(entityTypeData.NameChanges["LastName"], "RowKey"); }
public void CreateEntityTypeData() { // Arrange & Act var entityTypeData = new EntityTypeData<Country>(); // Assert Assert.NotNull(entityTypeData); Assert.NotNull(entityTypeData.NameChanges); Assert.True(entityTypeData.NameChanges.ContainsKey("Continent")); Assert.Equal(entityTypeData.NameChanges["Continent"], "PartitionKey"); Assert.True(entityTypeData.NameChanges.ContainsKey("Continent")); Assert.Equal(entityTypeData.NameChanges["Name"], "RowKey"); }
public EntityType Map(EntityTypeData entity_type_data) { return(new EntityType() { EntityTypeKey = entity_type_data.EntityTypeKey, EntityTypeCode = entity_type_data.EntityTypeCode, EntityTypeName = entity_type_data.EntityTypeName, AddedUserID = entity_type_data.AuditAddUserId, AddedDateTime = entity_type_data.AuditAddDatetime, UpdateUserID = entity_type_data.AuditUpdateUserId, UpdateDateTime = entity_type_data.AuditUpdateDatetime, }); }
public void CreateEntityTypeData() { // Arrange & Act var entityTypeData = new EntityTypeData <Country>(); // Assert Assert.NotNull(entityTypeData); Assert.NotNull(entityTypeData.NameChanges); Assert.True(entityTypeData.NameChanges.ContainsKey("Continent")); Assert.Equal(entityTypeData.NameChanges["Continent"], "PartitionKey"); Assert.True(entityTypeData.NameChanges.ContainsKey("Continent")); Assert.Equal(entityTypeData.NameChanges["Name"], "RowKey"); }
public void CreateEntityTypeDataWithDifferentAccessors() { // Arrange & Act var entityTypeData = new EntityTypeData <Entity>(); // Assert Assert.NotNull(entityTypeData); Assert.NotNull(entityTypeData.NameChanges); Assert.True(entityTypeData.NameChanges.ContainsKey("FirstName")); Assert.Equal(entityTypeData.NameChanges["FirstName"], "PartitionKey"); Assert.True(entityTypeData.NameChanges.ContainsKey("LastName")); Assert.Equal(entityTypeData.NameChanges["LastName"], "RowKey"); }
public void OnEntityRemoving(Entity entity, EntityTypeData movingTo) { if (movingTo != null) { for (int i = 0; i < @group.entityTypeDatas.Count; i++) { var entityData = @group.entityTypeDatas[i]; if (entityData.Data == movingTo) { return; } } } removingListener.OnEntityRemoving(entity); }
public void OnEntityAdded(Entity entity, EntityTypeData movedFrom) { if (movedFrom != null) { for (int i = 0; i < @group.entityTypeDatas.Count; i++) { var entityData = @group.entityTypeDatas[i]; if (entityData.Data == movedFrom) { return; } } } AddedEntities.Add(entity); }
public void EntityTypeModelTest1() { var data = new EntityTypeData { EntityTypeKey = 1, EntityTypeCode = "TEST", EntityTypeName = "TEST", AuditAddUserId = "TEST", AuditAddDatetime = new System.DateTime(2018, 1, 1), AuditUpdateUserId = "TEST", AuditUpdateDatetime = new System.DateTime(2018, 1, 1), }; var sut = new EntityType(data); Assert.True(sut.EntityTypeKey == 1); Assert.True(sut.EntityTypeCode == "TEST"); Assert.True(sut.EntityTypeName == "TEST"); }
internal abstract void AddArray(EntityTypeData data);
public EntityType Map(EntityTypeData commentData) => new EntityType(commentData);
public void SetEntityType(EntityTypeData entityTypeData) { EntityType = new EntityType(entityTypeData); EntityTypeId = entityTypeData.EntityTypeId; }
public void CreateEntityTypeDataWithoutCompositeKey() { // Arrange EntityTypeData<EntityWithoutCompositeKey> typeData = null; // Act Assert.Throws<InvalidOperationException>(() => { typeData = new EntityTypeData<EntityWithoutCompositeKey>(); }); // Assert Assert.Null(typeData); }
public void CreateEntityTypeDataWithMultipleAttributes() { // Arrange EntityTypeData<EntityWithMultipleAttributes> typeData = null; // Act Assert.Throws<InvalidOperationException>(() => { typeData = new EntityTypeData<EntityWithMultipleAttributes>(); }); // Assert Assert.Null(typeData); }
public List <SqlParameter> MapParamsForDelete(EntityTypeData entity) { return(MapParamsForDelete(entity.EntityTypeKey)); }
public EntityType Map(EntityTypeData ent) { return(new EntityType(ent)); }