public INodeSkin GetSkin(INodeTypeProxy nodeTypeProxy, string skinName) { //Dictionary<INodeTypeProxy, Dictionary<string, INodeSkin>> nodeTypes = _themes[_currentThemeName]; //Dictionary<string, INodeSkin> nodeSkins = nodeTypes[nodeTypeProxy]; foreach (ThemeSkin skin in _themes2[_currentThemeName].Skin) { if (skin.Name == skinName && skin.NodeType == nodeTypeProxy.Name) { object skinObject = Assembly.GetExecutingAssembly().CreateInstance(skin.Class); if (skinObject is INodeSkin) { INodeSkin skinObj = skinObject as INodeSkin; foreach (ThemeSkinProperty skinProperty in skin.Property) { skinObj.SkinProperties[skinProperty.Name] = skinProperty.Value; } return(skinObj); } } } return(null); //INodeSkin nodeSkin = nodeSkins[skinName]; // return nodeSkin; }
private void LoadXml(XmlReader xmlReader) { while (xmlReader.ReadToFollowing("Theme")) { string themeName = xmlReader.GetAttribute("Name"); string themeAssembly = xmlReader.GetAttribute("Assembly"); Dictionary <INodeTypeProxy, Dictionary <string, INodeSkin> > theme; if (_themes.ContainsKey(themeName)) { theme = _themes[themeName]; } else { theme = new Dictionary <INodeTypeProxy, Dictionary <string, INodeSkin> >(); _themes.Add(themeName, theme); } while (!(xmlReader.Name == "Theme" && xmlReader.NodeType == XmlNodeType.EndElement) && xmlReader.Read()) { if (xmlReader.Name == "Skin" && xmlReader.NodeType == XmlNodeType.Element) { string skinNameXmlValue = null; string skinClassXmlValue = null; string skinAssemblyXmlValue = null; string skinNodeTypeXmlValue = null; INodeSkin skin = null; if (xmlReader.NodeType == XmlNodeType.Element) { skinNameXmlValue = xmlReader.GetAttribute("Name"); skinClassXmlValue = xmlReader.GetAttribute("Class"); skinAssemblyXmlValue = xmlReader.GetAttribute("Assembly"); skinNodeTypeXmlValue = xmlReader.GetAttribute("NodeType"); } Dictionary <string, INodeSkin> nodeTypes; INodeTypeProxy nodeType = IoC.IoCContainer.GetInjectionInstance().GetInstance <TypeManager>().GetNodeType(skinNodeTypeXmlValue); if (nodeType != null && theme.ContainsKey(nodeType)) { nodeTypes = theme[nodeType]; } else { nodeTypes = new Dictionary <string, INodeSkin>(); theme.Add(nodeType, nodeTypes); } if (!string.IsNullOrEmpty(skinClassXmlValue) && !string.IsNullOrEmpty(skinNodeTypeXmlValue)) { object skinObject = Assembly.GetExecutingAssembly().CreateInstance(skinClassXmlValue); if (skinObject is INodeSkin) { skin = skinObject as INodeSkin; if (!nodeTypes.ContainsKey(skinNameXmlValue)) { nodeTypes.Add(skinNameXmlValue, skin); } } else if (skinObject == null) { throw new NotSupportedException("The provided theme does not exist."); } else { throw new NotSupportedException("The provided theme is not a skin."); } } while (!(xmlReader.Name == "Skin" && xmlReader.NodeType == XmlNodeType.EndElement)) { if (xmlReader.Name == "Property" && xmlReader.NodeType == XmlNodeType.Element) { string stylePropertyName = xmlReader.GetAttribute("Name"); string stylePropertyValue = xmlReader.ReadElementContentAsString(); stylePropertyValue = stylePropertyValue.Trim(); skin.SkinProperties[stylePropertyName] = stylePropertyValue; } else { xmlReader.Read(); } } } else { xmlReader.Read(); } } } }