public AdapterSpec(AdapterTypeEnum type, string name, ServiceInfoType serviceConfig) { Type = type; Name = name; Adapter = null; ServiceConfig = serviceConfig; }
public static string GetTypeName(AdapterTypeEnum type) { string ret = byType[type]; if (ret != null) { return(ret); } else { throw new NoSuchAdapter("Adapter type invalid"); } }
public static AdapterTypeEnum GetType(string name) { AdapterTypeEnum ret = byName[name]; if (ret != null) { return(ret); } else { throw new NoSuchAdapter("Adapter name invalid"); } }
protected void readConfig(string configFile) { services = new List <ServiceInfoType>(); //adapterTypes = new Dictionary<AdapterTypes,ArrayList>(); adapterNames = new Dictionary <string, AdapterSpec>(); XPathNavigator nav = new XPathDocument(configFile).CreateNavigator(); // Add plain services to list XPathNodeIterator startservices = nav.Select("//StartService"); foreach (XPathNavigator node in startservices) { services.Add(new ServiceInfoType(getChild(node, "Contract"), getChild(node, "Service"))); } // Add adapters to list, and to dictionary XPathNodeIterator adapters = nav.Select("//Adapter"); Console.WriteLine(adapters.Count + " adapters in config"); foreach (XPathNavigator node in adapters) { // Get the relevant info for this adapter // Attributes string sType = node.GetAttribute("type", ""); AdapterTypeEnum type = AdapterFactory.GetType(sType); string name = node.GetAttribute("name", ""); // Children string contract = getChild(node, "Contract", true); string service = getChild(node, "Service"); // Add elements to the service array and dictionary if (adapterNames.ContainsKey(name)) { throw new ConfigException("Duplicate adapter name \"" + name + "\""); } else { // Add a null adapter for now. An adapter will be created when the service is actually started ServiceInfoType serviceInfo = new ServiceInfoType(contract, service); AdapterSpec adapterInfo = new AdapterSpec(type, name, serviceInfo); adapterNames.Add(name, adapterInfo); //adapterServices.Add(service, adapterInfo); //services.Add(serviceInfo); } } }