private static void WriteHtmlForScalarNode(StringWriter htmlwriter, YamlScalarNode scalar) { var regex = new Regex(@"(.*)\[(.*?)\]"); var match = regex.Match(scalar.ToString()); string href = null; string caption = scalar.ToString(); if (match.Success) { caption = match.Groups[1].ToString(); href = match.Groups[2] + ".html"; } if (href != null) { htmlwriter.Write("<a href='{0}'>", href); } htmlwriter.Write(caption); if (href != null) { htmlwriter.Write("</a>"); } }
public static string getMessageValue(string key, string filePass) { StreamReader inputFile = new StreamReader(filePass, System.Text.Encoding.UTF8); YamlStream yaml = new YamlStream(); yaml.Load(inputFile); string[] keys = key.Split('.'); int keyCount = keys.Length; YamlMappingNode mapping = (YamlMappingNode)yaml.Documents[0].RootNode; YamlScalarNode node = null; for (int i = 0; i < keyCount; i++) { if (i == keyCount - 1) { node = (YamlScalarNode)mapping.Children[new YamlScalarNode(keys[i])]; } else { mapping = (YamlMappingNode)mapping.Children[new YamlScalarNode(keys[i])]; } } return(node.ToString()); }
public bool MapEntityProperty(YamlScalarNode node, string path) { if (uint.TryParse(node.ToString(), out var uid)) { if (EntityMapFromOtherToOurs.ContainsKey(uid)) { node.Value = EntityMapFromOtherToOurs[uid].ToString(CultureInfo.InvariantCulture); } else { Console.WriteLine($"Error finding UID in MapEntityRecursiveAndBadly {path}. To fix this, the merge driver needs to be improved."); return(false); } } return(true); }
static YamlMappingNode reifyMethod(EA.Repository Repository, EA.Element e, EA.Connector con, EA.Element client) { logger.log("Reify Method:" + e.Name); YamlMappingNode methodProps = new YamlMappingNode(); String description = ""; if (e.Notes != null && e.Notes.Length > 0) { description = e.Notes; } YamlSequenceNode pms = new YamlSequenceNode(); visitOutboundConnectedElements(Repository, e, pms, MetaDataManager.filterPermission, namePermission, reifyPermission); foreach (YamlNode node in pms.Children) { YamlScalarNode pn = (YamlScalarNode)node; String permission = pn.ToString(); if (REIFY_VERSION == APIAddinClass.RAML_0_8) { description += APIAddinClass.MARKDOWN_PARAGRAPH_BREAK + "The permission[" + permission + "] is required to invoke this method."; } else { methodProps.Add("(extensions.permission)", permission); } } methodProps.Add("description", description); Dictionary <string, RunState> rs = ObjectManager.parseRunState(e.RunState); foreach (string key in rs.Keys) { try { methodProps.Add(key, rs[key].value); } catch (Exception) { //ignore on purpose } } //YamlMappingNode responses = new YamlMappingNode(); //visitOutboundConnectedElements(Repository, e, responses, MetaDataManager.filterResponse, nameOfTargetElement, reifyResponse); //if (responses.Children.Count > 0) //{ // methodProps.Add("responses", responses); //} YamlMappingNode queryParameters = new YamlMappingNode(); visitOutboundConnectedElements(Repository, e, queryParameters, MetaDataManager.filterQueryParameter, nameOfTargetElement, reifyQueryParameter); if (queryParameters.Children.Count > 0) { methodProps.Add("queryParameters", queryParameters); } //YamlMappingNode contentTypes = new YamlMappingNode(); //visitOutboundConnectedElements(Repository, e, contentTypes, MetaDataManager.filterContentType, nameOfTargetElement, reifyContentType); //if (contentTypes.Children.Count > 0) //{ // methodProps.Add("body", contentTypes); //} if (REIFY_VERSION > APIAddinClass.RAML_0_8) { logger.log("Reify Examples"); YamlMappingNode responseExamples = new YamlMappingNode(); visitOutboundConnectedElements(Repository, e, responseExamples, MetaDataManager.filterResponseExample, nameOfTargetElement, reifyExamples); logger.log("Reify Response Examples:" + responseExamples.Children.Count); if (responseExamples.Children.Count > 0) { YamlMappingNode responses = new YamlMappingNode(); methodProps.Add("responses", responses); YamlMappingNode status = new YamlMappingNode(); responses.Add("200", status); YamlMappingNode body = new YamlMappingNode(); status.Add("body", body); YamlMappingNode contenttype = new YamlMappingNode(); body.Add("application/json", contenttype); YamlMappingNode exampleMap = new YamlMappingNode(); contenttype.Add("examples", exampleMap); foreach (KeyValuePair <YamlNode, YamlNode> kp in responseExamples) { exampleMap.Add(kp.Key, kp.Value); } } YamlMappingNode requestExamples = new YamlMappingNode(); visitOutboundConnectedElements(Repository, e, requestExamples, MetaDataManager.filterRequestExample, nameOfTargetElement, reifyExamples); if (requestExamples.Children.Count > 0) { YamlMappingNode body = new YamlMappingNode(); methodProps.Add("body", body); YamlMappingNode contenttype = new YamlMappingNode(); body.Add("application/json", contenttype); YamlMappingNode exampleMap = new YamlMappingNode(); contenttype.Add("examples", exampleMap); foreach (KeyValuePair <YamlNode, YamlNode> kp in requestExamples) { exampleMap.Add(kp.Key, kp.Value); } } } String traits = "["; YamlSequenceNode traitsMap = new YamlSequenceNode(); visitOutboundConnectedElements(Repository, e, traitsMap, MetaDataManager.filterTrait, nameTrait, reifyTrait); if (traitsMap.Children.Count > 0) { foreach (YamlNode node in traitsMap.Children) { YamlScalarNode sn = (YamlScalarNode)node; String trait = sn.ToString(); traits += trait + ","; } traits = traits.Substring(0, traits.Length - 1); traits += "]"; YamlScalarNode traitNode = new YamlScalarNode(traits); traitNode.Style = ScalarStyle.Raw; methodProps.Add("is", traitNode); } return(methodProps); }