object IConfigurationSectionHandler.Create(object parent, object configContext, XmlNode section) { Dictionary <string, IList <AuthorizedType> > dictionary = new Dictionary <string, IList <AuthorizedType> >(); XmlSerializer serializer = new XmlSerializer(typeof(AuthorizedType)); foreach (XmlNode node in section.ChildNodes) { XmlAttribute namedItem = node.Attributes.GetNamedItem("version") as XmlAttribute; if (namedItem != null) { string str = namedItem.Value; if (!string.IsNullOrEmpty(str)) { IList <AuthorizedType> list; if (!dictionary.TryGetValue(str, out list)) { list = new List <AuthorizedType>(); dictionary.Add(str, list); } foreach (XmlNode node2 in node.ChildNodes) { AuthorizedType item = serializer.Deserialize(new XmlNodeReader(node2)) as AuthorizedType; if (item != null) { list.Add(item); } } } } } return(dictionary); }
object IConfigurationSectionHandler.Create(object parent, object configContext, XmlNode section) { Dictionary <string, IList <AuthorizedType> > authorizedTypes = new Dictionary <string, IList <AuthorizedType> >(); XmlAttributeOverrides authorizedTypeOverrides = new XmlAttributeOverrides(); XmlAttributes authorizedTypeAttributes = new XmlAttributes(); authorizedTypeAttributes.XmlRoot = new XmlRootAttribute("authorizedType"); authorizedTypeOverrides.Add(typeof(AuthorizedType), authorizedTypeAttributes); XmlSerializer xmlSerializer = new XmlSerializer(typeof(AuthorizedType), authorizedTypeOverrides); foreach (XmlNode targetFx in section.ChildNodes) { XmlAttribute versionAttribute = targetFx.Attributes.GetNamedItem(TargetFxVersionAttribute) as XmlAttribute; if (versionAttribute != null) { string version = versionAttribute.Value; if (!string.IsNullOrEmpty(version)) { IList <AuthorizedType> versionTypes; if (!authorizedTypes.TryGetValue(version, out versionTypes)) { versionTypes = new List <AuthorizedType>(); authorizedTypes.Add(version, versionTypes); } foreach (XmlNode authorizedTypeNode in targetFx.ChildNodes) { AuthorizedType authorizedType = xmlSerializer.Deserialize(new XmlNodeReader(authorizedTypeNode)) as AuthorizedType; if (authorizedType != null) { versionTypes.Add(authorizedType); } } } } } return(authorizedTypes); }