private static Guid GetContainer(string mappingTable, ICustomAttributeProvider attributeProvider)
        {
            ProjectMappingRoleAttribute roleAttrib =
                ReflectionHelper.GetAttribute <ProjectMappingRoleAttribute>(attributeProvider, true);

            ServiceFactoryRoleType roleType = roleAttrib.RoleType;

            List <Role> roles = new List <Role>();

            roles.Add(new Role(roleType.ToString()));

            ReadOnlyCollection <Guid> projectGuids = ProjectMappingManager.Instance.GetProjectsInRoles(
                mappingTable,
                roles);

            if (projectGuids.Count == 0)
            {
                throw new InvalidOperationException(string.Format(CultureInfo.CurrentUICulture,
                                                                  Properties.Resources.ZeroProjectWithRole, roleType.ToString()));
            }
            else if (projectGuids.Count > 1)
            {
                throw new InvalidOperationException(string.Format(CultureInfo.CurrentUICulture,
                                                                  Properties.Resources.MoreThanOneProjectWithSameRole, roleType.ToString()));
            }

            return(projectGuids[0]);
        }
示例#2
0
        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));
        }
 public ProjectMappingRoleAttribute(ServiceFactoryRoleType roleType)
 {
     this.roleType = roleType;
 }
		public ProjectMappingRoleAttribute(ServiceFactoryRoleType roleType)
		{
			this.roleType = roleType;
		}