public PluginDocumentationPage(Type pluginType) { PluginType = pluginType; var image = pluginType.GetImage(0).Source; _xml = GetXML(pluginType); var authorAttribut = pluginType.GetPluginAuthorAttribute(); if (authorAttribut != null) { AuthorName = authorAttribut.Author; AuthorEmail = authorAttribut.Email; AuthorInstitute = authorAttribut.Institute; AuthorURL = authorAttribut.URL; } if (pluginType.GetComponentCategoryAttributes().Count() > 0) { Category = pluginType.GetComponentCategoryAttributes().First().Category; } else { Category = ComponentCategory.Undefined; } Settings = GetSettings(pluginType); if (_xml == null || _xml.Name != "documentation") { //entity doesn't have a proper _xml file _xml = null; Localizations.Add("en", CreateLocalizedEntityDocumentationPage(this, pluginType, null, "en", image as BitmapFrame)); } else { foreach (var lang in XMLHelper.GetAvailableLanguagesFromXML(_xml.Elements("language").Select(langElement => langElement.Attribute("culture").Value))) { Localizations.Add(lang, CreateLocalizedEntityDocumentationPage(this, pluginType, _xml, lang, image as BitmapFrame)); } if (!Localizations.ContainsKey("en")) { throw new Exception("Documentation should at least support english language!"); } References = XMLHelper.ReadReferences(_xml); } }
public TemplateDocumentationPage(string templateFile, string relativeTemplateDirectory, TemplateDirectory templateDir) { _relativeTemplateDirectory = relativeTemplateDirectory; TemplateFile = templateFile; TemplateDir = templateDir; string templateXMLFile = Path.Combine(Path.GetDirectoryName(templateFile), Path.GetFileNameWithoutExtension(templateFile) + ".xml"); if (!File.Exists(templateXMLFile)) { throw new Exception(string.Format("Missing meta infos for template {0}!", templateFile)); } TemplateXML = XElement.Load(templateXMLFile); BitmapFrame icon = null; if (TemplateXML.Element("icon") != null && TemplateXML.Element("icon").Attribute("file") != null) { var iconFile = Path.Combine(Path.GetDirectoryName(templateFile), TemplateXML.Element("icon").Attribute("file").Value); if (iconFile == null || !File.Exists(iconFile)) { iconFile = Path.Combine(Path.GetDirectoryName(templateFile), Path.GetFileNameWithoutExtension(templateFile) + ".png"); } if (File.Exists(iconFile)) { try { icon = BitmapFrame.Create(new BitmapImage(new Uri(iconFile))); Icon = iconFile; } catch (Exception) { icon = null; Icon = ""; } } } var authorElement = XMLHelper.FindLocalizedChildElement(TemplateXML, "author"); if (authorElement != null) { AuthorName = authorElement.Value; } var relevantPlugins = TemplateXML.Element("relevantPlugins"); if (relevantPlugins != null) { RelevantPlugins = new List <string>(); foreach (var plugin in relevantPlugins.Elements("plugin")) { var name = plugin.Attribute("name"); if (name != null) { RelevantPlugins.Add(name.Value); } } } foreach (var title in TemplateXML.Elements("title")) { var langAtt = title.Attribute("lang"); if (langAtt != null && !AvailableLanguages.Contains(langAtt.Value)) { Localizations.Add(langAtt.Value, new LocalizedTemplateDocumentationPage(this, langAtt.Value, icon)); } } if (!Localizations.ContainsKey("en")) { throw new Exception("Documentation should at least support english language!"); } }