Exemple #1
0
    ConfigSectionData GetConfigSectionData(ConfigurationSection section)
    {
        ConfigSectionData csd = new ConfigSectionData();

        csd.Name        = section.SectionInformation.Name;
        csd.IsDeclared  = section.SectionInformation.IsDeclared;
        csd.IsProtected = section.SectionInformation.IsProtected;

        switch (section.SectionInformation.AllowDefinition)
        {
        case ConfigurationAllowDefinition.MachineOnly:
            csd.Scope = "Machine";
            break;

        case ConfigurationAllowDefinition.MachineToApplication:
            csd.Scope = "Machine/Application";
            break;

        case ConfigurationAllowDefinition.Everywhere:
            csd.Scope = "Anywhere";
            break;

        default:
            csd.Scope = "Unknown";
            break;
        }
        return(csd);
    }
Exemple #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ArrayList     list   = new ArrayList(16);
        Configuration config = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);

        // Create "Root Sections" entry
        ConfigSectionData csd1 = new ConfigSectionData();

        csd1.Name = "__root";
        list.Add(csd1);

        // Create <appSettings> entry
        ConfigurationSection section = config.GetSection("appSettings");

        list.Add(GetConfigSectionData(section));

        // Create <connectionStrings> entry
        section = config.GetSection("connectionStrings");
        list.Add(GetConfigSectionData(section));

        // Create "Root Sections" entry
        ConfigSectionData csd2 = new ConfigSectionData();

        csd2.Name = "__system";
        list.Add(csd2);

        // Create <system.web> entries
        //ConfigurationSectionGroup group = config.SectionGroups["system.web"];
        //for (int i = 0; i < group.Sections.Count; i++)
        //{
        //    section = group.Sections[i];
        //    if (!section.SectionInformation.IsLocked)
        //        list.Add(GetConfigSectionData(section));
        //}

        // Display the results
        GridView1.DataSource = list;
        GridView1.DataBind();
    }