Exemple #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);
                }
            }
        }
        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;
                    }
                }
            }
        }