Exemple #1
0
 public void SetManifest(Manifest manifest)
 {
     this.manifest = manifest;
 }
        private Manifest ReadManifest(XmlElement xmlModule, IDictionary<string, Role> roleDb)
        {
            Manifest manifest = new Manifest();

            foreach (XmlElement xmlChild in xmlModule.ChildNodes)
            {
                if (xmlChild.Name.Equals("RoleList"))
                {
                    RoleList roleList = new RoleList();

                    foreach (XmlElement xmlRole in xmlChild.ChildNodes)
                    {
                        if (!xmlRole.Name.Equals("Role"))
                            throw new Exception("child of RoleList shouldn't be " + xmlRole.Name);

                        string roleName = xmlRole.GetAttribute("Name");

                        if (!roleDb.ContainsKey(roleName.ToLower()))
                            throw new Exception("unknown role name: " + roleName);

                        roleList.AddRole(roleDb[roleName.ToLower()]);
                    }

                    string optional = xmlChild.GetAttribute("Optional");
                    roleList.Optional = (optional.ToLower().Equals("true"));
                    manifest.AddRoleList(roleList);
                }
            }

            return manifest;
        }
        public List<PortInfo> GetCompatiblePorts(Manifest manifest)
        {
            var roleCompatiblePorts = new List<PortInfo>();

            lock (configuredPorts)
            {
                foreach (PortInfo pInfo in configuredPorts.Values)
                {
                    foreach (VRole role in pInfo.GetRoles())
                    {
                        if (manifest.IsCompatibleWithRole(role))
                        {
                            //add to the list if it is not already there
                            if (!roleCompatiblePorts.Contains(pInfo))
                                roleCompatiblePorts.Add(pInfo);

                            continue;
                        }
                    }
                }
            }

            return roleCompatiblePorts;
        }