private static void engine_config_finalize_handle_single_mapping(Engine_VerbMapping mapping, Dictionary<string, Engine_Component> components, Dictionary<string, Engine_RestrictionRange> restrictionRanges) { // If the mapping didn't exist, do nothing if (mapping == null) return; // Map the component if ((!String.IsNullOrEmpty(mapping.ComponentId)) && (components.ContainsKey(mapping.ComponentId))) { mapping.Component = components[mapping.ComponentId]; } else { mapping.Component = null; } // Map any restriction range if (!String.IsNullOrEmpty(mapping.RestrictionRangeSetId)) { string[] restrictions = mapping.RestrictionRangeSetId.Split(" |,".ToCharArray()); foreach (string thisRestriction in restrictions) { if (restrictionRanges.ContainsKey(thisRestriction.Trim())) { mapping.Add_RestrictionRange(restrictionRanges[thisRestriction.Trim()]); } } } else { mapping.RestrictionRanges = null; } }
private void add_single_verb_mapping_in_table(Engine_VerbMapping Mapping, TextWriter Output) { // Add the request type ( i.e., GET, POST, PUT, etc.. ) switch (Mapping.RequestType) { case Microservice_Endpoint_RequestType_Enum.GET: Output.WriteLine(" <td>GET</td>"); break; case Microservice_Endpoint_RequestType_Enum.POST: Output.WriteLine(" <td>POST</td>"); break; case Microservice_Endpoint_RequestType_Enum.PUT: Output.WriteLine(" <td>PUT</td>"); break; case Microservice_Endpoint_RequestType_Enum.DELETE: Output.WriteLine(" <td>DELETE</td>"); break; default: Output.WriteLine(" <td>ERROR</td>"); break; } // Add the protocol type ( i.e., XML, JSON, PROTOBUF, etc.. ) switch (Mapping.Protocol) { case Microservice_Endpoint_Protocol_Enum.BINARY: Output.WriteLine(" <td>BINARY</td>"); break; case Microservice_Endpoint_Protocol_Enum.CACHE: Output.WriteLine(" <td>Cache</td>"); break; case Microservice_Endpoint_Protocol_Enum.JSON: Output.WriteLine(" <td>JSON</td>"); break; case Microservice_Endpoint_Protocol_Enum.JSON_P: Output.WriteLine(" <td>JSON-P</td>"); break; case Microservice_Endpoint_Protocol_Enum.PROTOBUF: Output.WriteLine(" <td>ProtoBuf</td>"); break; case Microservice_Endpoint_Protocol_Enum.SOAP: Output.WriteLine(" <td>SOAP</td>"); break; case Microservice_Endpoint_Protocol_Enum.TEXT: Output.WriteLine(" <td>Text</td>"); break; case Microservice_Endpoint_Protocol_Enum.XML: Output.WriteLine(" <td>XML</td>"); break; default: Output.WriteLine(" <td>ERROR</td>"); break; } Output.WriteLine(" <td>" + Mapping.Method + "</td>"); Output.WriteLine(" <td><a href=\"#CO" + Mapping.ComponentId + "\">" + Mapping.ComponentId + "</a></td>"); Output.WriteLine(" <td><a href=\"#RR" + Mapping.RestrictionRangeSetId + "\">" + Mapping.RestrictionRangeSetId + "</a></td>"); }
private static void read_microservices_complex_endpoint_details(XmlReader ReaderXml, Engine_Path_Endpoint Endpoint, bool DisabledAtTop) { while (ReaderXml.Read()) { if (ReaderXml.NodeType == XmlNodeType.Element) { if (String.Compare(ReaderXml.Name, "verbmapping", StringComparison.OrdinalIgnoreCase) == 0) { // Ensure verb is indicated first if (ReaderXml.MoveToAttribute("Verb")) { Microservice_Endpoint_RequestType_Enum verb = Microservice_Endpoint_RequestType_Enum.ERROR; switch (ReaderXml.Value.Trim().ToUpper()) { case "DELETE": verb = Microservice_Endpoint_RequestType_Enum.DELETE; break; case "GET": verb = Microservice_Endpoint_RequestType_Enum.GET; break; case "POST": verb = Microservice_Endpoint_RequestType_Enum.POST; break; case "PUT": verb = Microservice_Endpoint_RequestType_Enum.PUT; break; } // If a valid verb found, continue if (verb != Microservice_Endpoint_RequestType_Enum.ERROR) { // Build the verb mapping Engine_VerbMapping verbMapping = new Engine_VerbMapping(null, !DisabledAtTop, Microservice_Endpoint_Protocol_Enum.JSON, verb); if (ReaderXml.MoveToAttribute("Method")) verbMapping.Method = ReaderXml.Value.Trim(); if ((!DisabledAtTop) && (ReaderXml.MoveToAttribute("Enabled")) && (String.Compare(ReaderXml.Value.Trim(), "false", StringComparison.OrdinalIgnoreCase) == 0)) verbMapping.Enabled = false; if (ReaderXml.MoveToAttribute("Protocol")) { switch (ReaderXml.Value.Trim().ToUpper()) { case "JSON": verbMapping.Protocol = Microservice_Endpoint_Protocol_Enum.JSON; break; case "JSON-P": verbMapping.Protocol = Microservice_Endpoint_Protocol_Enum.JSON_P; break; case "PROTOBUF": verbMapping.Protocol = Microservice_Endpoint_Protocol_Enum.PROTOBUF; break; case "SOAP": verbMapping.Protocol = Microservice_Endpoint_Protocol_Enum.SOAP; break; case "TEXT": verbMapping.Protocol = Microservice_Endpoint_Protocol_Enum.TEXT; break; case "XML": verbMapping.Protocol = Microservice_Endpoint_Protocol_Enum.XML; break; default: verbMapping.Protocol = Microservice_Endpoint_Protocol_Enum.JSON; break; } } // Get the mapping to componentid and restriction id if (ReaderXml.MoveToAttribute("ComponentID")) verbMapping.ComponentId = ReaderXml.Value.Trim(); if (ReaderXml.MoveToAttribute("RestrictionRangeID")) { verbMapping.RestrictionRangeSetId = ReaderXml.Value.Trim(); } // If valid, add to this endpoint if ((!String.IsNullOrEmpty(verbMapping.ComponentId)) && (!String.IsNullOrEmpty(verbMapping.Method))) { // Add the verb mapping to the right spot switch (verbMapping.RequestType) { case Microservice_Endpoint_RequestType_Enum.DELETE: Endpoint.DeleteMapping = verbMapping; break; case Microservice_Endpoint_RequestType_Enum.GET: Endpoint.GetMapping = verbMapping; break; case Microservice_Endpoint_RequestType_Enum.POST: Endpoint.PostMapping = verbMapping; break; case Microservice_Endpoint_RequestType_Enum.PUT: Endpoint.PutMapping = verbMapping; break; } } } } } } } }