internal APGenSection GetSectionInstance(SectionInfo sectionInfo, bool createDefaultInstance) { object data = _elementData[sectionInfo]; APGenSection section = data as APGenSection; if (section != null || !createDefaultInstance) { return(section); } object sectionObj = sectionInfo.CreateInstance(); section = sectionObj as APGenSection; if (section == null) { APGenDefaultSection defaultSection = new APGenDefaultSection(); defaultSection.SectionHandler = sectionObj as IAPGenSectionHandler; section = defaultSection; } if (data != null) { string xml = data as string; section.RawXml = xml; using (XmlTextReader reader = new XmlTextReader(new StringReader(xml))) { section.DeserializeSection(reader); } } _elementData[sectionInfo] = section; return(section); }
internal APGenSection GetSectionInstance(SectionInfo sectionInfo, bool createDefaultInstance) { object data = _elementData[sectionInfo]; APGenSection section = data as APGenSection; if (section != null || !createDefaultInstance) return section; object sectionObj = sectionInfo.CreateInstance(); section = sectionObj as APGenSection; if (section == null) { APGenDefaultSection defaultSection = new APGenDefaultSection(); defaultSection.SectionHandler = sectionObj as IAPGenSectionHandler; section = defaultSection; } if (data != null) { string xml = data as string; section.RawXml = xml; using (XmlTextReader reader = new XmlTextReader(new StringReader(xml))) { section.DeserializeSection(reader); } } _elementData[sectionInfo] = section; return section; }