private void ProcessService(GXXMLReader reader) { reader.ReadType(1, "Name"); String name = reader.Value; reader.ReadType(1, "Type"); String type = reader.Value; reader.ReadType(1, "ClassName"); String className = reader.Value; String allowMultiple = string.Empty; reader.Read(); if (reader.Name == "AllowMultiple") { allowMultiple = reader.Value; reader.Read(); } GXProperties properties = ProcessProperties(type, name, reader); GXService service = new GXService(); service.Name = name; service.Type = type; service.ClassName = className; service.Properties = properties; service.AllowMultiple = string.IsNullOrEmpty(allowMultiple) ? false : bool.Parse(allowMultiple); if (service.AllowMultiple) { services.Add($"{service.Type}:{service.Name}", service); } else { services.Add(type, service); } }
private GXProperties ProcessProperties(string serviceType, string serviceName, GXXMLReader reader) { GXProperties properties = new GXProperties(); reader.Read(); while (reader.Name == "Property") { reader.ReadType(1, "Name"); string name = reader.Value; reader.ReadType(1, "Value"); string value = reader.Value; if (EnvVarReader.GetEnvironmentValue(serviceType, serviceName, name, out string envVarValue)) { value = envVarValue; } properties.Add(name, value); reader.Read(); reader.Read(); } return(properties); }
public static void LoadFromFile(string fileName, ref GXServices services) { string filePath = ServicesFilePath(fileName); if (File.Exists(filePath)) { try { if (services == null) { services = new GXServices(); } GXLogging.Debug(log, "Loading service:", filePath); GXXMLReader reader = new GXXMLReader(); reader.Open(filePath); reader.ReadType(1, "Services"); reader.Read(); if (reader.ErrCode == 0) { while (reader.Name != "Services") { services.ProcessService(reader); reader.Read(); if (reader.Name == "Service" && reader.NodeType == 2) //</Service> { reader.Read(); } } reader.Close(); } } catch (Exception ex) { GXLogging.Error(log, "Couldn't create service from:", filePath, ex); throw ex; } } }
static public void initLocations(IGxContext context, GXXMLReader oReader) { String sSection; String sName; short nFirstRead; GxLocation oLocation; context.nLocRead = 1; context.colLocations = new GxLocationCollection(); if (oReader.ErrCode == 0) { if (oReader.ReadType(1, "GXLocations") > 0) { oReader.Read(); while (!((StringUtil.StrCmp(oReader.Name, "GXLocations") == 0) && (oReader.NodeType == 2))) { if ((StringUtil.StrCmp(oReader.Name, "GXLocation") == 0) && (oReader.NodeType == 1)) { sName = oReader.GetAttributeByName("name"); oLocation = context.colLocations.GetItem(sName); context.nSOAPErr = 0; if (oLocation == null) { context.nSOAPErr = 1; } if (context.nSOAPErr != 0) { /* Error while reading XML. Code: 4 . Message: Input error . */ oLocation = new GxLocation(); oLocation.Name = sName; oLocation.Host = "localhost"; oLocation.Port = 80; oLocation.BaseUrl = "/"; oLocation.Secure = 0; oLocation.ProxyServerHost = ""; oLocation.ProxyServerPort = 0; oLocation.Timeout = 0; oLocation.CancelOnError = 0; oLocation.Authentication = 0; oLocation.AuthenticationMethod = 0; oLocation.AuthenticationRealm = ""; oLocation.AuthenticationUser = ""; oLocation.AuthenticationPassword = ""; oLocation.GroupLocation = ""; context.colLocations.Add(oLocation, sName); } oLocation.GroupLocation = ""; nFirstRead = 1; oReader.Read(); while (!((StringUtil.StrCmp(oReader.Name, "GXLocation") == 0) && (oReader.NodeType == 2))) { sSection = read_section(context, oReader, oLocation); if (((StringUtil.StrCmp(sSection, "Common") == 0) && (nFirstRead == 1)) || (StringUtil.StrCmp(sSection, "HTTP") == 0)) { nFirstRead = 0; } oReader.Read(); } } oReader.Read(); } } } }