示例#1
0
        private bool RemoveConfiguredPort(PortInfo portInfo,  bool writeToDisk = true)
        {
            
            //we always lock configuredPorts even if unconfiguredPorts is being touched
            lock (unconfiguredPorts)
            {

                lock (configuredPorts)
                {
                    bool result = configuredPorts.Remove(portInfo);
                    configuredPortNames.Remove(portInfo.GetFriendlyName());
                    
                    //portInfo.SetLocation(parentLocation);
                    //parentLocation.AddChildPort(portInfo);

                    allLocations[portInfo.GetLocation().Name()].RemoveChildPort(portInfo);
                    
                    
                    // if "configured roles in home" list contains any roles from this port
                    // rebuild the configured roles in home list from the "new" configured ports list (i.e., after removing this port)
                    configuredRolesInHome.Clear();
                    foreach (PortInfo port in configuredPorts.Values) // rebuilding the configuredRolesInHome list again
                    {
                        foreach (VRole role in port.GetRoles())
                        {
                            if (!configuredRolesInHome.ContainsKey(role)) // avoiding duplicates
                                configuredRolesInHome[role] = true;
                        }
                    }

                    if (writeToDisk)
                        WriteServicesList();

                    return result;

                }
            }

        }
示例#2
0
        public void AddConfiguredPort(PortInfo portInfo, bool writeToDisk=true)
        {

            //we always lock configuredPorts even if unconfiguredPorts is being touched

            lock (configuredPorts)
            {
                //remove from uncofigured list first if it exists there

                if (unconfiguredPorts.ContainsKey(portInfo))
                    unconfiguredPorts.Remove(portInfo);

                configuredPorts.Add(portInfo, portInfo);
                configuredPortNames.Add(portInfo.GetFriendlyName(), portInfo);

                foreach (VRole role in portInfo.GetRoles())
                {
                    if (!configuredRolesInHome.ContainsKey(role))
                        configuredRolesInHome[role] = true;
                }

                if (writeToDisk) 
                    WriteServicesList();
            }

        }