public void Load(BinaryReader reader)
        {
            // Load system's features
            WindowsFeature.GetWindowsFeatures(ConfigurationManager.Features);

            // Get number of features
            int count = reader.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                // Get feature info
                WindowsFeature feature = WindowsFeature.Parse(reader);

                // Search for feature in list
                WindowsFeature match = ConfigurationManager.Features.FirstOrDefault(x => x.Name == feature.Name);

                // If match was found
                if (match != null)
                {
                    // Copy info to shown WindowsFeature
                    match.Installed = feature.Installed;
                    match.IsScored  = feature.IsScored;
                }
                else
                {
                    // Add feature to list
                    ConfigurationManager.Features.Add(feature);
                }
            }
        }
        public SectionDetails GetScore()
        {
            SectionDetails details = new SectionDetails(0, new List <string>(), this);

            // Get windows features on system
            List <WindowsFeature> systemFeatures = WindowsFeature.GetWindowsFeatures();

            // For each configured windows feature
            foreach (WindowsFeature scoredFeature in ScoredFeatures)
            {
                // For each system windows feature
                foreach (WindowsFeature systemFeature in systemFeatures)
                {
                    // If features have the same name (same features)
                    if (scoredFeature.Name == systemFeature.Name)
                    {
                        // If installation statuses are equal, give points
                        if (scoredFeature.Installed == systemFeature.Installed)
                        {
                            details.Points++;

                            if (scoredFeature.Installed)
                            {
                                details.Output.Add(TranslationManager.Translate("WindowsFeatureInstalled", scoredFeature.Name));
                            }
                            else
                            {
                                details.Output.Add(TranslationManager.Translate("WindowsFeatureNotInstalled", scoredFeature.Name));
                            }
                        }

                        // Found match, break loop
                        break;
                    }
                }
            }

            return(details);
        }
예제 #3
0
 public void PopulateFeatures()
 {
     // Get windows features
     WindowsFeature.GetWindowsFeatures(ConfigurationManager.Features);
 }