public DroneConfiguration() { General = new GeneralSection(); Control = new ControlSection(); Network = new NetworkSection(); Pic = new PicSection(); Video = new VideoSection(); Leds = new LedsSection(); Detect = new DetectSection(); Syslog = new SyslogSection(); Userbox = new UserboxSection(); Gps = new GpsSection(); Custom = new CustomSection(); _items = GetItems(General) .Concat(GetItems(Control)) .Concat(GetItems(Network)) .Concat(GetItems(Pic)) .Concat(GetItems(Video)) .Concat(GetItems(Leds)) .Concat(GetItems(Detect)) .Concat(GetItems(Syslog)) .Concat(GetItems(Userbox)) .Concat(GetItems(Gps)) .Concat(GetItems(Custom)) .ToDictionary(x => x.Key); }
public void Populate(IList <CustomSection> customSections, CustomSection originalTextSection, IList <CustomSection> defaultCustomSections, CustomSection defaultOriginalTextSection, Context context) { _isPopulate = true; this._customSections = customSections; this._originalTextSection = originalTextSection; this._defaultCustomSections = defaultCustomSections; this._defaultOriginalTextSection = defaultOriginalTextSection; this._context = context; customSections[(int)CustomEntryEditor.EditorMode.Text].DecodeText(); defaultCustomSections[(int)CustomEntryEditor.EditorMode.Text].DecodeText(); originalTextSection.DecodeText(); defaultOriginalTextSection.DecodeText(); _customSectionIndex = 0; _editorMode = CustomEntryEditor.EditorMode.Data; cmb_Section.Items.Clear(); cmb_Section.Items.Add("Text"); cmb_Section.Items.Add("Data"); cmb_Section.SelectedIndex = _customSectionIndex; SetSectionIndex(_customSectionIndex); _isPopulate = false; }
static void CreateConfigurationFile() { try { CustomSection customSection = new CustomSection(); } }
public Form1() { backgroundWorker1 = new System.ComponentModel.BackgroundWorker(); backgroundWorker2 = new System.ComponentModel.BackgroundWorker(); backgroundWorker3 = new System.ComponentModel.BackgroundWorker(); backgroundWorker2.WorkerReportsProgress = true; backgroundWorker2.WorkerSupportsCancellation = true; InitializeComponent(); backgroundWorker1.DoWork += new DoWorkEventHandler(backgroundWorker1_DoWork); backgroundWorker1.RunWorkerCompleted += new RunWorkerCompletedEventHandler( backgroundWorker1_RunWorkerCompleted); backgroundWorker1.ProgressChanged += new ProgressChangedEventHandler( backgroundWorker1_ProgressChanged); backgroundWorker2.DoWork += new DoWorkEventHandler(backgroundWorker2_DoWork); backgroundWorker2.RunWorkerCompleted += new RunWorkerCompletedEventHandler( backgroundWorker2_RunWorkerCompleted); backgroundWorker2.ProgressChanged += new ProgressChangedEventHandler( backgroundWorker2_ProgressChanged); customSection = new CustomSection(); try { // Get the current configuration file. config = ConfigurationManager.OpenExeConfiguration( ConfigurationUserLevel.None); // Create the custom section entry // in <configSections> group and the // related target section in <configuration>. if (config.Sections["CustomSection"] == null) { config.Sections.Add("CustomSection", customSection); // Save the configuration file. customSection.SectionInformation.ForceSave = true; config.Save(ConfigurationSaveMode.Full); } customSection = config.GetSection("CustomSection") as CustomSection; userText.Text = customSection.User; passwdText.Text = customSection.Passwd; databaseText.Text = customSection.Database; } catch (ConfigurationErrorsException err) { MessageBox.Show("CreateConfigurationFile: {0}", err.ToString()); } }
//<Snippet2> // Show how to create an instance of the Configuration class // that represents this application configuration file. static void CreateConfigurationFile() { try { // Create a custom configuration section. CustomSection customSection = new CustomSection(); // Get the current configuration file. System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration( ConfigurationUserLevel.None); // Create the custom section entry // in <configSections> group and the // related target section in <configuration>. if (config.Sections["CustomSection"] == null) { config.Sections.Add("CustomSection", customSection); } // Create and add an entry to appSettings section. string conStringname = "LocalSqlServer"; string conString = @"data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"; string providerName = "System.Data.SqlClient"; ConnectionStringSettings connStrSettings = new ConnectionStringSettings(); connStrSettings.Name = conStringname; connStrSettings.ConnectionString = conString; connStrSettings.ProviderName = providerName; config.ConnectionStrings.ConnectionStrings.Add(connStrSettings); // Add an entry to appSettings section. int appStgCnt = ConfigurationManager.AppSettings.Count; string newKey = "NewKey" + appStgCnt.ToString(); string newValue = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString(); config.AppSettings.Settings.Add(newKey, newValue); // Save the configuration file. customSection.SectionInformation.ForceSave = true; config.Save(ConfigurationSaveMode.Full); Console.WriteLine("Created configuration file: {0}", config.FilePath); } catch (ConfigurationErrorsException err) { Console.WriteLine("CreateConfigurationFile: {0}", err.ToString()); } }
public void CustomSection_PrecedingSectionValidity() { var custom = new CustomSection(); foreach (var value in Enum.GetValues(typeof(Section)).Cast <Section>()) { //All values of Section should be accepted. custom.PrecedingSection = value; } Assert.ThrowsException <ArgumentOutOfRangeException>(() => custom.PrecedingSection = (Section)255); }
static void Main(string[] args) { try { Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); CustomSection sect = (CustomSection)config.GetSection("customSection"); Console.WriteLine("longSetting = {0}", sect.LongSetting); } catch (ConfigurationErrorsException e) { Console.WriteLine("ConfigurationErrorsException raised"); } }
static void Main(string[] args) { try { Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); CustomSection sect = (CustomSection)config.GetSection("customSection"); foreach (string key in sect.Settings.AllKeys) { KeyValueConfigurationElement e = sect.Settings[key]; Console.WriteLine("{0} = {1}", e.Key, e.Value); } } catch (Exception e) { Console.WriteLine("Exception raised: {0}\n{1}", e.GetType(), e); } }
public DroneConfiguration() { _items = new Dictionary <string, string>(); _changes = new Queue <KeyValuePair <string, string> >(); DroneHostname = "192.168.1.1"; General = new GeneralSection(this); Control = new ControlSection(this); Network = new NetworkSection(this); Pic = new PicSection(this); Video = new VideoSection(this); Leds = new LedsSection(this); Detect = new DetectSection(this); Syslog = new SyslogSection(this); Userbox = new UserboxSection(this); Gps = new GpsSection(this); Custom = new CustomSection(this); }
public void LoadXmlSections(string filePath, Catalog<Section> cat) { try { XmlDocument doc = new XmlDocument(); doc.Load(filePath); XmlNode sections = doc.SelectSingleNode("//Frame_Section_Properties_01_-_General"); if (sections != null) { XmlNodeList instances = sections.SelectNodes("SectionName"); List<string> knownTemplates = new List<string>(new string[] { "Double Angle", "Channel", "I/Wide Flange", "Box/Tube", "Pipe", "Angle", "Tee" }); if (instances != null && instances.Count > 0) { foreach (XmlNode node in instances) { string temp = CustomSection.readAttribute(node, "Shape", ""); Section sec = null; if (knownTemplates.Contains(temp)) sec = NewSection(Material.MaterialManager.Instance.DefaultSteel, null, LoadXmlVariables(node)); else sec = new CustomSection(node); if (sec != null) cat[sec.Name] = sec; } } } Canguro.Model.Serializer.Deserializer deserializer = new Canguro.Model.Serializer.Deserializer(Model.Instance); XmlNode beams = doc.SelectSingleNode("//Frame_Section_Properties_03_-_Concrete_Beam"); if (beams != null) deserializer.readFrameConcreteBeams(beams, cat); XmlNode columns = doc.SelectSingleNode("//Frame_Section_Properties_02_-_Concrete_Column"); if (columns != null) deserializer.readFrameConcreteColumns(columns, cat); } catch { MessageBox.Show(Culture.Get("WrongXsecFile") + ": " + filePath, Culture.Get("error"), MessageBoxButtons.OK, MessageBoxIcon.Error); } }
// Show how to create an instance of the Configuration class // that represents this application configuration file. static void CreateConfigurationFile() { try { // Create a custom configuration section. CustomSection customSection = new CustomSection(); // Get the current configuration file. System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration( ConfigurationUserLevel.None); // Create the custom section entry // in <configSections> group and the // related target section in <configuration>. if (config.Sections["CustomSection"] == null) { config.Sections.Add("CustomSection", customSection); } // Create and add an entry to appSettings section. //string conStringname = "LocalSqlServer"; //string conString = @"data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"; //string providerName = "System.Data.SqlClient"; //ConnectionStringSettings connStrSettings = new ConnectionStringSettings(); //connStrSettings.Name = conStringname; //connStrSettings.ConnectionString = conString; //connStrSettings.ProviderName = providerName; //config.ConnectionStrings.ConnectionStrings.Add(connStrSettings); //// Add an entry to appSettings section. //int appStgCnt = // ConfigurationManager.AppSettings.Count; //string newKey = "NewKey" + appStgCnt.ToString(); //string newValue = DateTime.Now.ToLongDateString() + // " " + DateTime.Now.ToLongTimeString(); //config.AppSettings.Settings.Add(newKey, newValue); // Save the configuration file. customSection.SectionInformation.ForceSave = true; config.Save(ConfigurationSaveMode.Full); Console.WriteLine("Created configuration file: {0}", config.FilePath); } catch (ConfigurationErrorsException err) { Console.WriteLine("CreateConfigurationFile: {0}", err.ToString()); } }
// strict parse means all sections must come in order public void ParseAsWASM(string filename, bool strict_parse = true) { if (!BitConverter.IsLittleEndian) { throw new NotImplementedException("LEB128 implementation only handles little endian systems"); } using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read)) { BinaryReader reader = new BinaryReader(fs); uint magic = reader.ReadUInt32(); if (magic != MAGIC) { throw new Exception("Not a compiled Web Assembly file."); } uint version = reader.ReadUInt32(); if (version > SUPPORTED_VERSION) { throw new Exception($"Unsupported version. Expected version <= {SUPPORTED_VERSION}, received {version}."); } int last_parsed_module = int.MinValue; /* Read in each module */ while (true) { int id = reader.PeekChar(); // EOF if (id == -1) { break; } if (strict_parse && id < last_parsed_module) { throw new Exception("File contains out of order sections."); } last_parsed_module = id; switch (id) { case (int)WebAssemblyModuleID.Custom: if (strict_parse && custom != null) { throw new Exception("File contains a duplicate custom section."); } custom = new CustomSection(reader); break; case (int)WebAssemblyModuleID.Type: if (strict_parse && type != null) { throw new Exception("File contains a duplicate type section."); } type = new TypeSection(reader); break; case (int)WebAssemblyModuleID.Import: if (strict_parse && import != null) { throw new Exception("File contains a duplicate import section."); } import = new ImportSection(reader); break; case (int)WebAssemblyModuleID.Function: if (strict_parse && function != null) { throw new Exception("File contains a duplicate function section."); } function = new FunctionSection(reader); break; case (int)WebAssemblyModuleID.Table: if (strict_parse && table != null) { throw new Exception("File contains a duplicate table section."); } table = new TableSection(reader); break; case (int)WebAssemblyModuleID.Memory: if (strict_parse && memory != null) { throw new Exception("File contains a duplicate memory section."); } memory = new MemorySection(reader); break; case (int)WebAssemblyModuleID.Global: if (strict_parse && global != null) { throw new Exception("File contains a duplicate global section."); } global = new GlobalSection(reader); break; case (int)WebAssemblyModuleID.Export: if (strict_parse && export != null) { throw new Exception("File contains a duplicate export section."); } export = new ExportSection(reader); break; case (int)WebAssemblyModuleID.Start: if (strict_parse && start != null) { throw new Exception("File contains a duplicate start section."); } start = new StartSection(reader); break; case (int)WebAssemblyModuleID.Element: if (strict_parse && element != null) { throw new Exception("File contains a duplicate element section."); } element = new ElementSection(reader); break; case (int)WebAssemblyModuleID.Code: if (strict_parse && code != null) { throw new Exception("File contains a duplicate code section."); } code = new CodeSection(reader); break; case (int)WebAssemblyModuleID.Data: if (strict_parse && data != null) { throw new Exception("File contains a duplicate data section."); } data = new DataSection(reader); break; // Error default: throw new Exception($"Unknown section {id}."); } } /* Additional validation */ // The lengths of vectors produced by the (possibly empty) function and code section must match up. if ((function != null && code == null) || (function == null && code != null)) { throw new Exception("File corrupt. Must include both function and code sections."); } if (function.types.Length != code.bodies.Length) { throw new Exception("File corrupt. Function and code sections do not match up."); } // TODO: I don't actually check if data overlaps // TODO: Validate everything in this list // https://webassembly.github.io/spec/core/valid/modules.html } }
public void Sample() { ChildElement parentChildElement = this.GetParent<ChildElement>(); CustomSection parentCustomSection = parentChildElement.GetParent<CustomSection>(); // TODO Use the parents ... }