Esempio n. 1
0
        /// <summary>
        /// Interaktionslogik für invalide Eingaben
        /// </summary>
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (SourceAddressBox.Text == "")
                {
                    throw new Exception("Bitte eine IP-Adresse eintragen!");
                }
                if (AddresCountBox.Text.Length == 0)
                {
                    throw new Exception("Bitte Größe eintragen!");
                }

                var address    = new IPv4Address(SourceAddressBox.Text);
                var newNetwork = new IPv4Network(address, IPv4SubnetMask.ByAddressCount(int.Parse(AddresCountBox.Text)));
                newNetwork.Description = this.DescriptionBox.Text;

                if (network is not null)
                {
                    this.network.AddSubnet(newNetwork);
                }
                else
                {
                    AppStore.Instance.MainNetwork = newNetwork;
                }

                AppStore.Instance.Refresh();
                this.Close();
            }
            catch (Exception exception)
            {
                Exception_TextBlock.Text = exception.Message.ToString();
            }
        }
Esempio n. 2
0
        public void CreatesByAddressCountCorrectly(int addressCount, string expected)
        {
            var mask = IPv4SubnetMask.ByAddressCount(addressCount);

            Assert.Equal(expected, mask.ToString());
        }