Ejemplo n.º 1
0
        public void SetMetadata(Dictionary <PhysicalAddress, List <IPAddress> > metadata)
        {
            foreach (KeyValuePair <PhysicalAddress, List <IPAddress> > entry in metadata)
            {
                List <IPAddress> addresses   = entry.Value;
                PhysicalAddress  mac         = entry.Key;
                string           registryKey = mac.ToString();

                List <string>    registryKeys         = registryWriter.GetMultiStringValue(registryKey);
                List <IPAddress> registryForwardedIps = registryKeys.ConvertAll <IPAddress>(ConvertStringToIpAddress);
                List <IPAddress> addressesConfigured  = AddressSystemReader.GetAddresses();
                List <IPAddress> toAdd                = new List <IPAddress>(addresses.Except(addressesConfigured));
                List <IPAddress> toRemove             = new List <IPAddress>(registryForwardedIps.Except(addresses));
                List <string>    metadataStrings      = addresses.ConvertAll <string>(ip => ip.ToString());
                List <string>    toRemoveFromRegistry = new List <string>(registryKeys.Except(metadataStrings));
                List <string>    toAddToRegistry      = new List <string>(metadataStrings.Except(registryKeys));
                LogForwardedIpsChanges(mac, addressesConfigured, addresses, toAdd, toRemove);
                AddAddresses(toAdd, mac);
                RemoveAddresses(toRemove, mac);
                registryWriter.RemoveMultiStringValues(registryKey, toRemoveFromRegistry);
                foreach (string address in toAddToRegistry)
                {
                    registryWriter.AddMultiStringValue(mac.ToString(), address.ToString());
                }
            }
        }
        public void SetMetadata(List <WindowsKey> metadata)
        {
            List <string>     registryKeys        = registryWriter.GetMultiStringValue(RegistryKey);
            List <WindowsKey> registryWindowsKeys = registryKeys
                                                    .ConvertAll <WindowsKey>(WindowsKey.DeserializeWindowsKey);
            List <WindowsKey> toAdd                = new List <WindowsKey>(metadata.Except(registryWindowsKeys));
            List <string>     metadataStrings      = metadata.ConvertAll <string>(user => user.ToString());
            List <string>     toRemoveFromRegistry = new List <string>(registryKeys.Except(metadataStrings));

            AddUserAccounts(toAdd);
            registryWriter.RemoveMultiStringValues(RegistryKey, toRemoveFromRegistry);
        }
        public void SetMetadata(List <IPAddress> metadata)
        {
            List <string>    registryKeys         = registryWriter.GetMultiStringValue(RegistryKey);
            List <IPAddress> registryForwardedIps = registryKeys.ConvertAll <IPAddress>(ConvertStringToIpAddress);
            List <IPAddress> addressesConfigured  = AddressSystemReader.GetAddresses();
            List <IPAddress> toAdd                = new List <IPAddress>(metadata.Except(addressesConfigured));
            List <IPAddress> toRemove             = new List <IPAddress>(registryForwardedIps.Except(metadata));
            List <string>    metadataStrings      = metadata.ConvertAll <string>(ip => ip.ToString());
            List <string>    toRemoveFromRegistry = new List <string>(registryKeys.Except(metadataStrings));

            LogForwardedIpsChanges(addressesConfigured, metadata, toAdd, toRemove);
            AddAddresses(toAdd);
            RemoveAddresses(toRemove);
            registryWriter.RemoveMultiStringValues(RegistryKey, toRemoveFromRegistry);
        }
Ejemplo n.º 4
0
        private void RegistryKeysCompareTest(List <string> expected, RegistryWriter registryWriter, string registryKey)
        {
            List <string> actual = registryWriter.GetMultiStringValue(registryKey);

            Assert.Equal <List <string> >(expected: expected, actual: actual);
        }