public void Setup() { projectId = Guid.NewGuid(); Role role = new Role("FooRole"); Role role1 = new Role("FooRole1"); ProjectMapping.Configuration.ProjectMappingEntry projectMapping = new ProjectMapping.Configuration.ProjectMappingEntry( projectId, @"\", "FooName"); projectMapping.Roles.Add(role); projectMapping.Roles.Add(role1); ProjectMappingTable mappingTable = new ProjectMappingTable("Foo"); mappingTable.ProjectMappings.Add(projectMapping); info = new ProjectMappingInformation("Foo.rolemapping"); info.ProjectMappingTables.Add(mappingTable); }
public static string RoleToString(Role role) { Guard.ArgumentNotNull(role, "role"); return role.Name; }
/// <summary> /// String representation of the project mapping. /// </summary> /// <remarks> /// Added to make debugging output more readable. /// </remarks> /// <returns></returns> public new string ToString() { Role[] roleArray = new Role[Roles.Count]; Roles.CopyTo(roleArray, 0); string[] roleNames = Array.ConvertAll(roleArray, new Converter<Role, string>(Role.RoleToString)); return String.Format(CultureInfo.CurrentUICulture, "{{{0}}} -> {1}", this.projectId, String.Join(",", roleNames)); }
private Collection<Role> BuildRolesCollection(string[] projectRoles) { List<Role> roles = new List<Role>(); foreach (string role in projectRoles) { try { if (!String.IsNullOrEmpty(role)) { ServiceFactoryRoleType roleType = (ServiceFactoryRoleType)Enum.Parse(typeof(ServiceFactoryRoleType), role, true); Role serviceFactoryRole = new Role(roleType.ToString()); if (roles.Find(delegate(Role match) { if (match.Name == roleType.ToString()) { return true; } return false; } ) == null) { roles.Add(serviceFactoryRole); } } } catch (ArgumentException) { //Do Nothing Is not a valid role value } } return (new Collection<Role>(roles)); }