private void AddSectionAspectCommand_Execute(object parameter) { AddSectionAspectWindow window = new AddSectionAspectWindow(); if (window.ShowDialog() == true && window.SelectedType != null) { // Get real parent section here and add aspect to that // BUG?: It doesn't work reliably when you write "this.Aspects.Add()"... to be checked! SectionDefinitionViewModel section = (SectionDefinitionViewModel)_parent.SelectedNode; ISectionParser sectionParser = SectionParserCache.Create(window.SelectedType.Type); SectionParserDefinitionViewModel spdvm = new SectionParserDefinitionViewModel(section, sectionParser); section.Aspects.Add(spdvm); } }
/// <summary> /// Loads the parser definition from a file. /// </summary> /// <param name="fileName">The file to load the parser definition from.</param> public void Load(string fileName) { Assertions.AssertNotEmpty(fileName, "fileName"); ControlInformation ci = ControlInformation.Load(fileName); // Clear all data this.Sections.Clear(); this.SelectedNode = null; // Fill in from the control file... this.ParserName = ci.FaxName; foreach (SectionDefinition sd in ci.Sections) { SectionDefinitionViewModel sdvm = new SectionDefinitionViewModel(this); sdvm.Name = sd.SectionString.String; foreach (SectionParserDefinition spd in sd.Parsers) { ISectionParser sectionParser = SectionParserCache.Create(spd.Type); sectionParser.OnLoad(spd.Options); SectionParserDefinitionViewModel spdvm = new SectionParserDefinitionViewModel(sdvm, sectionParser); sdvm.Aspects.Add(spdvm); } foreach (AreaDefinition ad in sd.Areas) { AreaDefinitionViewModel advm = new AreaDefinitionViewModel(sdvm); advm.Name = ad.AreaString.String; advm.MapToPropertyExpression = ad.MapToPropertyExpression; sdvm.Areas.Add(advm); } this.Sections.Add(sdvm); } }