Exemplo n.º 1
0
        public void Load(BinaryReader reader)
        {
            // Clear current storage
            SecurityOptions.Clear();

            // Get number of security option settings
            int count = reader.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                // Get type of sec option
                ESecurityOptionType type = (ESecurityOptionType)reader.ReadInt32();

                ISecurityOption secOption = null;

                // Initialize secOption based on type
                switch (type)
                {
                case ESecurityOptionType.RegistryComboBox:
                    secOption = new RegistryComboBox();
                    break;

                case ESecurityOptionType.RegistryTextRegex:
                    secOption = new RegistryTextRegex();
                    break;

                case ESecurityOptionType.RegistryRange:
                    secOption = new RegistryRange();
                    break;

                case ESecurityOptionType.RegistryMultiLine:
                    secOption = new RegistryMultiLine();
                    break;

                case ESecurityOptionType.SeceditComboBox:
                    secOption = new SeceditComboBox();
                    break;

                case ESecurityOptionType.SeceditTextRegex:
                    secOption = new SeceditTextRegex();
                    break;
                }

                if (secOption == null)
                {
                    // Uh oh.. corrupted file?
                    throw new Exception("Unknown security option type. Possible configuration file corruption.");
                }

                // Parse information based on type
                secOption.Parse(reader);

                // Only store scored options
                if (secOption.IsScored)
                {
                    SecurityOptions.Add(secOption);
                }
            }
        }
Exemplo n.º 2
0
        public void CopyTo(ISecurityOption securityOption)
        {
            // Cast interface to self's type. This function should not be called to other type
            ControlRegistryMultiLine control = securityOption as ControlRegistryMultiLine;

            if (control == null)
            {
                return;
            }

            // We don't want to copy the header in case we update a header
            //control.Header = Header;
            control.IsScored  = IsScored;
            control.Text      = Text;
            control.Key       = Key;
            control.ValueName = ValueName;
        }
Exemplo n.º 3
0
        public void CopyTo(ISecurityOption securityOption)
        {
            // Cast interface to self's type. This function should not be called to other type
            ControlRegistryComboBox control = securityOption as ControlRegistryComboBox;

            if (control == null)
            {
                return;
            }

            // We don't want to copy the header in case we update a header
            //control.Header = Header;
            control.IsScored = IsScored;
            //control.Items = Items;
            control.SelectedIndex = SelectedIndex;
            control.Key           = Key;
            control.ValueName     = ValueName;
        }
Exemplo n.º 4
0
        public void CopyTo(ISecurityOption securityOption)
        {
            // Cast interface to self's type. This function should not be called to other type
            ControlSeceditTextRegex control = securityOption as ControlSeceditTextRegex;

            if (control == null)
            {
                return;
            }

            // We don't want to copy the header in case we update a header
            //control.Header = Header;
            control.IsScored     = IsScored;
            control.Regex        = Regex;
            control.RegexMatches = RegexMatches;
            control.Section      = Section;
            control.Key          = Key;
        }
Exemplo n.º 5
0
        public void CopyTo(ISecurityOption securityOption)
        {
            // Cast interface to self's type. This function should not be called to other type
            ControlRegistryRange control = securityOption as ControlRegistryRange;

            if (control == null)
            {
                return;
            }

            // We don't want to copy the header in case we update a header
            //control.Header = Header;
            control.IsScored = IsScored;
            control.Minimum  = Minimum;
            control.Maximum  = Maximum;
            // We don't want to copy total min/max for same reason as header
            //control.TotalMinimum = TotalMinimum;
            //control.TotalMaximum = TotalMaximum;
            control.Key       = Key;
            control.ValueName = ValueName;
        }
        public void Load(BinaryReader reader)
        {
            // Get number of security option settings
            int count = reader.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                // Get type of sec option
                ESecurityOptionType type = (ESecurityOptionType)reader.ReadInt32();

                ISecurityOption secOption = null;

                // Initialize secOption based on type
                switch (type)
                {
                case ESecurityOptionType.RegistryComboBox:
                    secOption = new ControlRegistryComboBox();
                    break;

                case ESecurityOptionType.RegistryTextRegex:
                    secOption = new ControlRegistryTextRegex();
                    break;

                case ESecurityOptionType.RegistryRange:
                    secOption = new ControlRegistryRange();
                    break;

                case ESecurityOptionType.RegistryMultiLine:
                    secOption = new ControlRegistryMultiLine();
                    break;

                case ESecurityOptionType.SeceditComboBox:
                    secOption = new ControlSeceditComboBox();
                    break;

                case ESecurityOptionType.SeceditTextRegex:
                    secOption = new ControlSeceditTextRegex();
                    break;
                }

                if (secOption == null)
                {
                    // Uh oh.. corrupted file?
                    throw new Exception("Unknown security option type. Possible configuration file corruption.");
                }

                // Parse information based on type
                secOption.Parse(reader);

                string identifier = secOption.Identifier();

                // Search for matching control to copy information to
                foreach (ISecurityOption control in MainWindow.itemsSecurityOptions.Items.OfType <ISecurityOption>())
                {
                    // Check if control is a match
                    if (type == control.Type && identifier == control.Identifier())
                    {
                        // Copy information to displayed control
                        secOption.CopyTo(control);

                        // Found match, stop searching
                        break;
                    }
                }
            }
        }