public override string TransformText() { var location = FileMetaData.GetFullLocationPathWithFileName(); var doc = LoadOrCreateImodSpecFile(location); var templatesElement = doc.Element("package").Element("templates"); foreach (var model in Model) { var id = $"{Project.ApplicationName()}.{model.Name}"; var specificTemplate = doc.XPathSelectElement($"package/templates/template[@id=\"{id}\"]"); if (specificTemplate == null) { specificTemplate = new XElement("template", new XAttribute("id", id)); templatesElement.Add(specificTemplate); } if (specificTemplate.Element("role") == null) { specificTemplate.Add(new XElement("role") { Value = id }); } } if (Model.Any(x => x.IsCSharpTemplate()) && doc.XPathSelectElement("package/dependencies/dependency[@id=\"Intent.OutputManager.RoslynWeaver\"]") == null) { var dependencies = doc.XPathSelectElement("package/dependencies"); dependencies.Add(new XElement("dependency", new XAttribute("id", "Intent.OutputManager.RoslynWeaver"), new XAttribute("version", "1.7.0"))); } if (Model.Any(x => x.GetModelerName() == "Domain") && doc.XPathSelectElement("package/dependencies/dependency[@id=\"Intent.Modelers.Domain\"]") == null) { var dependencies = doc.XPathSelectElement("package/dependencies"); dependencies.Add(new XElement("dependency", new XAttribute("id", "Intent.Modelers.Domain"), new XAttribute("version", "1.0.0"))); } if (Model.Any(x => x.GetModelerName() == "Services") && doc.XPathSelectElement("package/dependencies/dependency[@id=\"Intent.Modelers.Services\"]") == null) { var dependencies = doc.XPathSelectElement("package/dependencies"); dependencies.Add(new XElement("dependency", new XAttribute("id", "Intent.Modelers.Services"), new XAttribute("version", "1.0.0"))); } if (Model.Any(x => x.GetModelerName() == "Eventing") && doc.XPathSelectElement("package/dependencies/dependency[@id=\"Intent.Modelers.Eventing\"]") == null) { var dependencies = doc.XPathSelectElement("package/dependencies"); dependencies.Add(new XElement("dependency", new XAttribute("id", "Intent.Modelers.Eventing"), new XAttribute("version", "1.0.0"))); } return(doc.ToStringUTF8()); }
public override string TransformText() { var location = FileMetaData.GetFullLocationPathWithFileName(); var doc = LoadOrCreateWebConfig(location); foreach (var cssHref in BowerCssFiles.Reverse()) { var head = doc.DocumentNode.SelectSingleNode("//html//head"); if (head.SelectSingleNode($"//link[@href='./lib/{cssHref}']") == null) { var cssLink = doc.CreateElement("link"); cssLink.Attributes.Add(doc.CreateAttribute("rel", "stylesheet")); cssLink.Attributes.Add(doc.CreateAttribute("href", $"./lib/{cssHref}")); head.AppendChild(cssLink); head.InsertBefore(HtmlNode.CreateNode(" "), cssLink); } } var body = doc.DocumentNode.SelectSingleNode("//html//body"); //foreach (var jsSrc in BowerJsFiles) //{ // if (body.SelectSingleNode($"//script[@src='./lib/{jsSrc}']") != null) // { // body.RemoveChild(body.SelectSingleNode($"//script[@src='./lib/{jsSrc}']")); // } //} var newLine = HtmlNode.CreateNode("\r\n "); var firstScript = body.SelectSingleNode($"//script[1]"); foreach (var jsSrc in BowerJsFiles) { if (body.SelectSingleNode($"//script[@src='./lib/{jsSrc}']") == null && body.SelectSingleNode($"//comment()[contains(., './lib/{jsSrc}')]") == null) { var jsScript = doc.CreateElement("script"); jsScript.Attributes.Add(doc.CreateAttribute("type", "text/javascript")); jsScript.Attributes.Add(doc.CreateAttribute("src", $"./lib/{jsSrc}")); body.InsertBefore(jsScript, firstScript); body.InsertBefore(newLine, firstScript); } } foreach (var jsSrc in _eventedJsFiles) { if (body.SelectSingleNode($"//script[@src='{jsSrc}']") == null) { var jsScript = doc.CreateElement("script"); jsScript.Attributes.Add(doc.CreateAttribute("type", "text/javascript")); jsScript.Attributes.Add(doc.CreateAttribute("src", $"{jsSrc}")); body.AppendChild(jsScript); } } return(doc.DocumentNode.InnerHtml); }
public override string TransformText() { var location = FileMetaData.GetFullLocationPathWithFileName(); var doc = LoadOrCreateWebConfig(location); foreach (var webConfigDecorator in GetDecorators()) { webConfigDecorator.Install(doc, Project); } return(doc.ToStringUTF8()); }
public override string TransformText() { var location = FileMetaData.GetFullLocationPathWithFileName(); var doc = LoadOrCreateWebConfig(location); var namespaces = new XmlNamespaceManager(new NameTable()); namespaces.AddNamespace("ns", doc.Root.GetDefaultNamespace().NamespaceName); foreach (var appSetting in _appSettings) { var configAppSettings = doc.XPathSelectElement("/ns:configuration/ns:appSettings", namespaces); if (configAppSettings.XPathSelectElement($"//add[@key='{appSetting.Key}']", namespaces) == null) { var setting = new XElement("add"); setting.Add(new XAttribute("key", appSetting.Key)); setting.Add(new XAttribute("value", appSetting.Value)); configAppSettings.Add(setting); } } foreach (var connectionString in _connectionStrings.Values) { var configConnectionStrings = doc.XPathSelectElement("/ns:configuration/ns:connectionStrings", namespaces); if (configConnectionStrings == null) { configConnectionStrings = new XElement("connectionStrings"); var configAppSettings = doc.XPathSelectElement("/ns:configuration/ns:appSettings", namespaces); if (configAppSettings == null) { doc.Root.AddFirst(configConnectionStrings); } else { configAppSettings.AddBeforeSelf(configConnectionStrings); } } if (configConnectionStrings.XPathSelectElement($"//add[@name='{connectionString.Name}']", namespaces) == null) { var setting = new XElement("add"); setting.Add(new XAttribute("name", connectionString.Name)); setting.Add(new XAttribute("providerName", connectionString.ProviderName)); setting.Add(new XAttribute("connectionString", connectionString.ConnectionString)); configConnectionStrings.Add(setting); } } foreach (var webConfigDecorator in GetDecorators()) { webConfigDecorator.Install(doc, Project); } return(doc.ToStringUTF8()); }
public override string RunTemplate() { string fileName = FileMetaData.GetFullLocationPathWithFileName(); if (File.Exists(fileName)) { var result = new StringBuilder(); result.Append(@"//IntentManaged[configs]" + Environment.NewLine); result.Append(string.Join(Environment.NewLine, ConfigItems.Select(x => $" {x.Key}: \"{x.Value}\","))); result.Append(Environment.NewLine + @"//IntentManaged[configs]" + Environment.NewLine); return(result.ToString()); } else { return(TransformText()); } }
public override string RunTemplate() { string fileName = FileMetaData.GetFullLocationPathWithFileName(); if (File.Exists(fileName)) { var result = new StringBuilder(); result.Append(@"//IntentManaged[modules]" + Environment.NewLine); result.Append(string.Join(Environment.NewLine, AngularModules.Select(x => $"\t\t\t, \"{x}\""))); result.Append(Environment.NewLine + @"//IntentManaged[modules]" + Environment.NewLine); return(result.ToString()); } else { return(TransformText()); } }
public override string TransformText() { var location = FileMetaData.GetFullLocationPathWithFileName(); var doc = LoadOrCreate(location); var namespaces = new XmlNamespaceManager(new NameTable()); namespaces.AddNamespace("ns", doc.Root.GetDefaultNamespace().NamespaceName); var generatedNode = doc.XPathSelectElement("/ns:someSchema/ns:generatedSettings", namespaces); generatedNode.RemoveNodes(); foreach (var kvp in Model) { var setting = new XElement(kvp.Key); setting.Value = kvp.Value; generatedNode.Add(setting); } return(doc.ToStringUTF8()); }