public void ConvertSection() { Section section = new Section { TypeName = typeof (SimpleSection).AssemblyQualifiedName, ModelBinder = null, }; var strPropParam = new Parameter { Name = "StrProp", Values = new List<ParameterValue> { new ParameterValue{Value = "aa"} }, }; var intPropParam = new Parameter { Name = "IntProp", Values = new List<ParameterValue> { new ParameterValue { Value = "11" } }, }; section.Parameters.Add(strPropParam.Name, strPropParam); section.Parameters.Add(intPropParam.Name, intPropParam); var sectionProvider = new SectionToProviderConverter().Convert(section, new NConfigSettings()); var sectionInstance = sectionProvider.Get(new Dictionary<string, string>()); Assert.IsInstanceOf<SimpleSection>(sectionInstance); Assert.AreEqual(11, ((SimpleSection)sectionInstance).IntProp); Assert.AreEqual("aa", ((SimpleSection)sectionInstance).StrProp); }
public IDictionary<string, ISectionProvider> Get() { IDictionary<string, ISectionProvider> result = new Dictionary<string, ISectionProvider>(); var converter = new SectionToProviderConverter(); foreach (var section in this.GetMehtod()) { try { Type sectionType = Type.GetType(section.TypeName, false); if (sectionType != null) { result.Add(sectionType.FullName, converter.Convert(section, this.Settings)); } } catch (Exception e) { throw new ConvertSectionException(section,e); } } return result; }