private static IEnumerable<IBackendServiceLocation> BuildServiceLocationCache() { string fileName = ServiceFactory.BackendConfigurator.Get(ConfigKeyServiceLocation); fileName = Path.Combine(Utilities.GetWorkingDirectory(), fileName); if (!File.Exists(fileName)) { throw new FileNotFoundException(Properties.Resources.ServiceLocationFileNotPresent, fileName); } XDocument doc = XDocument.Load(fileName); doc.ValidateXml(Properties.Resources.BackendServiceLocationSchema); foreach (XElement service in doc.Root.Elements("service")) { BackendServiceLocation item = new BackendServiceLocation(); item.ContractType = Type.GetType(service.Attribute("contract").Value); item.ServiceType = Type.GetType(service.Attribute("service").Value); item.Binding = (SupportedBinding)Enum.Parse(typeof(SupportedBinding), service.TryGetAttributeValue("binding", SupportedBinding.NetTcp.ToString()), false); yield return item; } }
private IEnumerable<IBackendServiceLocation> BuildServiceLocationCache(string fileName) { XDocument doc = XDocument.Load(fileName); doc.ValidateXml(Properties.Resources.BackendServiceLocationSchema); foreach (XElement service in doc.Root.Elements("service")) { BackendServiceLocation item = new BackendServiceLocation(); item.ContractType = Type.GetType(service.Attribute("contract").Value); item.ServiceType = Type.GetType(service.Attribute("service").Value); item.Binding = (SupportedBinding)Enum.Parse(typeof(SupportedBinding), service.TryGetAttributeValue("binding", SupportedBinding.NetTcp.ToString()), false); yield return item; } }