public IEnumerable <string> GetConfig() { Configuration config = WebConfigurationManager.OpenWebConfiguration(Request.Path); UserAndPlaceSectionGroup group = (UserAndPlaceSectionGroup)config.SectionGroups["customDefaults"]; PlacesSection places = group.Places; Place defaultPlace = places.Places[places.Default]; yield return(string.Format("The default is: {0} (City: {1}, Country: {2})", places.Default, defaultPlace.City, defaultPlace.Country)); foreach (Place p in places.Places) { yield return(string.Format("{0} {1}", p.City, p.Country)); } }
public IEnumerable <string> GetConfig() { //foreach (string key in WebConfigurationManager.AppSettings) //{ // yield return string.Format("{0} = {1}", // key, WebConfigurationManager.AppSettings[key]); //} //foreach (ConnectionStringSettings con in // WebConfigurationManager.ConnectionStrings) //{ // yield return string.Format("name: {0}, connectionString: {1}", // con.Name, con.ConnectionString); //} //string csName = WebConfigurationManager.AppSettings["dbConnectionString"]; //ConnectionStringSettings conString = // WebConfigurationManager.ConnectionStrings[csName]; //DbConnection dbConn = DbProviderFactories // .GetFactory(conString.ProviderName).CreateConnection(); //dbConn.ConnectionString = conString.ConnectionString; //dbConn.Open(); //DbCommand dbCommand = dbConn.CreateCommand(); //dbCommand.CommandText = "SELECT UserName from Users"; //dbCommand.CommandType = System.Data.CommandType.Text; //DbDataReader reader = dbCommand.ExecuteReader(); //while (reader.Read()) //{ // yield return reader[0].ToString(); //} //dbConn.Close(); //object configObject = WebConfigurationManager // .GetWebApplicationSection("system.web/compilation"); //CompilationSection sectionHandler = configObject as CompilationSection; //if (sectionHandler != null) //{ // yield return string.Format("debug = {0}", sectionHandler.Debug); // yield return string.Format("targetFramework = {0}", sectionHandler.TargetFramework); // yield return string.Format("batch = {0}", sectionHandler.Batch); //} //else //{ // yield return string.Format("unexpected object type = {0}", // sectionHandler.GetType()); //} Configuration config = WebConfigurationManager.OpenWebConfiguration(Request.Path); //PlacesSection places = (PlacesSection)config.Sections["places"]; UserAndPlaceSectionGroup group = (UserAndPlaceSectionGroup)config.SectionGroups["customDefaults"]; PlacesSection places = group.Places; Place defaultPlace = places.Places[places.Default]; yield return(string.Format("the default is: {0} (City: {1}, Country: {2})", places.Default, defaultPlace.City, defaultPlace.Country)); foreach (Place p in places.Places) { yield return(string.Format("{0} {1}", p.City, p.Country)); } //newUserDefaultsSection section = // (newUserDefaultsSection)config.Sections["newUserDefaults"]; //yield return string.Format("city = {0}", section.City); //yield return string.Format("country = {0}", section.Country); //yield return string.Format("language = {0}", section.Language); //yield return string.Format("region = {0}", section.Region); //foreach (ConfigurationSectionGroup group in config.SectionGroups) //{ // foreach (string str in processSectionGroup(group)) // { // yield return str; // } //} //SystemWebSectionGroup group = // (SystemWebSectionGroup)config.SectionGroups["system.web"]; //CompilationSection section = group.Compilation; //yield return string.Format("debug = {0}", group.Compilation.Debug); //yield return string.Format("targetframework = {0}", group.Compilation.TargetFramework); //yield return string.Format("batch = {0}", group.Compilation.Batch); }
public IEnumerable <String> GetConfig() { Configuration config = WebConfigurationManager.OpenWebConfiguration(Request.Path); UserAndPlaceSectionGroup group = (UserAndPlaceSectionGroup)config.SectionGroups["customDefaults"]; PlaceSection place = group.Places; Place defaultPlace = place.Places[place.Default]; yield return($"The default is {place.Default} (City{defaultPlace.City},Country:{defaultPlace.Country})"); foreach (Place p in place.Places) { yield return($"{p.City},{p.Country}"); } #region //PlaceSection places = (PlaceSection)config.Sections["places"]; //Place defaultPlace = places.Places[places.Default]; //yield return $"The default is : {places.Default}(City:{defaultPlace.City},Country:{defaultPlace.Country})"; //foreach (Place p in places.Places) //{ // yield return $"{p.City} {p.Country}"; //} //Configuration config = WebConfigurationManager.OpenWebConfiguration(Request.Path); //NewUserDefaultsSection section = (NewUserDefaultsSection)config.Sections["newUserDefaults"]; //yield return $"city:{section.City}"; //yield return $"country:{section.Country}"; //yield return $"language:{section.Language}"; //yield return $"regionCode:{section.RegionCode}"; //foreach (ConfigurationSectionGroup group in config.SectionGroups) //{ // foreach (String str in processSectionGroup(group)) // { // yield return str; // } //} //Configuration config = WebConfigurationManager.OpenWebConfiguration(Request.Path); //SystemWebSectionGroup group = config.SectionGroups["system.web"] as SystemWebSectionGroup; //yield return $"debug = { group.Compilation.Debug}"; //yield return $"targetFramework = {group.Compilation.TargetFramework}"; //yield return $"batch = {group.Compilation.Batch}"; //if (DebugEnabled) //{ // yield return "Debug is enabled."; //} //else //{ // yield return "Debug is disabled."; //} //Object configObject = WebConfigurationManager.GetWebApplicationSection("system.web/compilation"); //CompilationSection sectionHandler = configObject as CompilationSection; //if (sectionHandler != null) //{ // yield return $"Debug = {sectionHandler.Debug}"; // yield return $"targetFramework = {sectionHandler.TargetFramework}"; // yield return $"batch = {sectionHandler.Batch}"; //} //else //{ // yield return $"Unexpected object type:{configObject.GetType()}"; //} //String csName = WebConfigurationManager.AppSettings["dbConnectionString"]; //ConnectionStringSettings conString = WebConfigurationManager.ConnectionStrings[csName]; //DbConnection dbConnect = DbProviderFactories.GetFactory(conString.ProviderName).CreateConnection(); //dbConnect.ConnectionString = conString.ConnectionString; //dbConnect.Open(); //DbCommand dbCommand = dbConnect.CreateCommand(); //dbCommand.CommandText = "select UserName from Users"; //dbCommand.CommandType = System.Data.CommandType.Text; //DbDataReader reader = dbCommand.ExecuteReader(); //while (reader.Read()) //{ // yield return reader[0].ToString(); //} //dbConnect.Close(); //foreach (ConnectionStringSettings connect in WebConfigurationManager.ConnectionStrings) //{ // yield return $"name:{connect.Name},connectionString:{connect.ConnectionString}"; //} //foreach (var key in WebConfigurationManager.AppSettings.AllKeys) //{ // yield return $"{key} = {WebConfigurationManager.AppSettings[key]}"; //} // yield return "This is a placeholder."; #endregion }