Содержание
- 2. Basic of configuration files Extended features AGENDA
- 3. BASIC CONFIGURATION FILES
- 4. CONFIGURATION FILE STRUCTURE type="Sample.SimpleConfigurationSection, Sample"/> Section definition Section Element Property Collection Key property
- 5. COMMON CLASSES
- 6. ELEMENTS public class WorkTimeElement : ConfigurationElement { [ConfigurationProperty("start")] public DateTime StartTime { get { return (DateTime)this["start"];
- 7. COLLECTIONS public class FileElement : ConfigurationElement { [ConfigurationProperty("name", IsKey = true)] public string FileName { get
- 8. SECTIONS public class SimpleConfigurationSection : ConfigurationSection { [ConfigurationProperty("appName")] public string ApplicationName { get { return (string)base["appName"];
- 9. USAGE var s = (SimpleConfigurationSection) ConfigurationManager.GetSection("simpleSection"); Console.WriteLine("{0} {1} - {2}", s.ApplicationName, s.WorkTime.StartTime.ToLongTimeString(), (s.WorkTime.StartTime + s.WorkTime.Duration).ToLongTimeString()); foreach
- 10. EXTENDED CONFIGURATION FILES
- 11. PROPERTIES AND COLLECTIONS [ConfigurationProperty("size", IsRequired = false, DefaultValue = 0)] public int FileSize { get {
- 12. VALIDATORS [ConfigurationProperty("size", IsRequired = false, DefaultValue = 0)] [IntegerValidator(MinValue = 0, MaxValue = 1000000)] public int
- 13. %SYSTEMROOT%\Microsoft.NET\Framework\ \CONFIG machine.config web.config CONFIGURATION HIERARCHY
- 14. CONFIGURATION FILE MODULARIZATION type="Sample.SimpleConfigurationSection, Sample"/> App.config User.config
- 15. PREDEFINED SECTIONS Console.WriteLine( ConfigurationManager.ConnectionStrings["myDB"].ConnectionString); Console.WriteLine( ConfigurationManager.AppSettings["Key2"]);
- 16. Deep Dive into .Net Configurationn Unraveling the Mysteries of .NET 2.0 Configuration Decoding the Mysteries of
- 18. Скачать презентацию