private void InitializeEntities() { Entity userEntity = ProjectUtilities.FindByEntityType(_project, EntityType.User); Entity claimEntity = ProjectUtilities.FindByEntityType(_project, EntityType.Claim); Entity loginEntity = ProjectUtilities.FindByEntityType(_project, EntityType.Login); Entity roleEntity = ProjectUtilities.FindByEntityType(_project, EntityType.Role); Entity userRoleEntity = ProjectUtilities.FindByEntityType(_project, EntityType.UserRole); var entity = userEntity ?? claimEntity ?? loginEntity ?? roleEntity ?? userRoleEntity; Property emailProperty = userEntity == null ? null : ProjectUtilities.FindByPropertyType(userEntity, PropertyType.Email); Property phoneNumberProperty = userEntity == null ? null : ProjectUtilities.FindByPropertyType(userEntity, PropertyType.PhoneNumber); foreach (Namespace ns in _project.AllNamespaces) { comboBoxNamespace.Items.Add(ns.FullName); } // Set namespace if (entity != null) { comboBoxNamespace.Text = entity.Namespace; } else { comboBoxNamespace.Text = _project.DefaultNamespace; } // initialize checkbox checkBoxClaims.Checked = claimEntity != null; checkBoxExternalLogins.Checked = loginEntity != null; checkBoxRole.Checked = roleEntity != null; //checkBoxUserRole.Checked = userRoleEntity != null; checkBoxEmailUnique.Checked = emailProperty != null && emailProperty.IsUnique; checkBoxPhoneNumberUnique.Checked = phoneNumberProperty != null && phoneNumberProperty.IsUnique; }
public override void Initialize(Project project, Producer producer) { base.Initialize(project, producer); _codeDomProducer = project.Producers.GetProducerInstance <CodeDomProducer>(); if (_codeDomProducer == null) { return; } if (string.IsNullOrWhiteSpace(EditorTargetDirectory)) { EditorTargetDirectory = _codeDomProducer.EditorTargetDirectory; } _codeDomProducer.CodeDomProduction += CodeDomProducer_CodeDomProduction; Entity userEntity = ProjectUtilities.FindByEntityType(project, EntityType.User); if (userEntity != null) { _identityUser = new IdentityUser(userEntity); } Entity roleEntity = ProjectUtilities.FindByEntityType(project, EntityType.Role); if (roleEntity != null) { _identityRole = new IdentityRole(roleEntity); } Entity loginEntity = ProjectUtilities.FindByEntityType(project, EntityType.Login); if (loginEntity != null) { _identityLogin = new IdentityLogin(loginEntity); } Entity claimEntity = ProjectUtilities.FindByEntityType(project, EntityType.Claim); if (claimEntity != null) { _identityClaim = new IdentityClaim(claimEntity); } if (_identityUser != null) { _userStoreProducer = new UserStoreProducer(_codeDomProducer, this, _identityUser, _identityRole, _identityLogin, _identityClaim); } if (_identityRole != null) { _roleStoreProducer = new RoleStoreProducer(_codeDomProducer, this, _identityRole); } }
private Entity GetOrCreateEntity(EntityType entityType, string entityName, string @namespace) { Entity entity = _project.Entities.Find(entityName); if (entity == null) { entity = ProjectUtilities.FindByEntityType(_project, entityType); if (entity != null) { entity.Name = entityName; // Rename } } if (entity == null) { entity = new Entity(); entity.Name = entityName; entity.Namespace = @namespace; entity.SetAttributeValue("", "entityType", Constants.NamespaceUri, entityType); _project.Entities.Add(entity); } return(entity); }
public override void Initialize(Project project, Producer producer) { base.Initialize(project, producer); if (InputProducer == null) { return; } if (string.IsNullOrWhiteSpace(EditorTargetDirectory)) { EditorTargetDirectory = InputProducer.EditorTargetDirectory; } InputProducer.CodeDomProduction += CodeDomProducer_CodeDomProduction; Entity userEntity = ProjectUtilities.FindByEntityType(project, EntityType.User); if (userEntity != null) { _identityUser = new IdentityUser(userEntity); } Entity roleEntity = ProjectUtilities.FindByEntityType(project, EntityType.Role); if (roleEntity != null) { _identityRole = new IdentityRole(roleEntity); } Entity loginEntity = ProjectUtilities.FindByEntityType(project, EntityType.UserLogin); if (loginEntity != null) { _identityUserLogin = new IdentityUserLogin(loginEntity); } Entity claimEntity = ProjectUtilities.FindByEntityType(project, EntityType.UserClaim); if (claimEntity != null) { _identityUserClaim = new IdentityUserClaim(claimEntity); } Entity roleClaimEntity = ProjectUtilities.FindByEntityType(project, EntityType.RoleClaim); if (roleClaimEntity != null) { _identityRoleClaim = new IdentityRoleClaim(roleClaimEntity); } ProjectMessages projectMessages = new ProjectMessages(project); if (TargetVersion == AspNetIdentityVersion.Version1 || TargetVersion == AspNetIdentityVersion.Version2) { if (_identityUser != null) { _userStoreProducer = new UserStoreProducer(InputProducer, this, projectMessages, _identityUser, _identityRole, _identityUserLogin, _identityUserClaim); } if (_identityRole != null) { _roleStoreProducer = new RoleStoreProducer(InputProducer, this, _identityRole); } } else if (TargetVersion == AspNetIdentityVersion.Version3) { if (_identityUser != null) { _userStore3Producer = new UserStore3Producer(InputProducer, this, projectMessages, _identityUser, _identityRole, _identityUserLogin, _identityUserClaim); } if (_identityRole != null) { _roleStore3Producer = new RoleStore3Producer(InputProducer, this, _identityRole, _identityRoleClaim); } } }