public void MapServices(Object servicesHolder) { MethodInfo[] methods = servicesHolder.GetType().GetMethods(); foreach (MethodInfo method in methods) { if (!method.IsPublic) { continue; } Object[] attributes = method.GetCustomAttributes(false); foreach (Object attribute in attributes) { if (attribute is Service) { Service service = (Service)attribute; MappedService mapped = new MappedService(); mapped.Source = servicesHolder; mapped.MethodInfo = method; _mappedServices.Add(service.Name, mapped); break; } //TODO: Thow exception: duplicated service mapping } } }
} // GetMappedServices protected MappedService GetMappedService(BroadcastList item, UiBroadcastService service, IDictionary <string, MappedService> mappedServices, IDictionary <string, ServiceLogoMappings.ReplacementDomain> domainMappings) { MappedService mappedService; var domain = item.Provider.DomainName; while (domain != null) { ServiceLogoMappings.ReplacementDomain replacement; var key = MappedService.GetKey(service.ServiceName, domain); if (mappedServices.TryGetValue(key, out mappedService)) { return(mappedService); } // if if (!domainMappings.TryGetValue(domain.ToLowerInvariant(), out replacement)) { return(null); } // if domain = replacement.Replacement; } // while return(null); } // GetMappedService
private MethodInfo GetServiceMethodInfo(String name, out Object target) { MappedService service = null; if (_mappedServices.ContainsKey(name)) { _mappedServices.TryGetValue(name, out service); } if (service == null) { //TODO: Throw NonMappedServiceException if method is null target = null; return(null); } target = service.Source; return(service.MethodInfo); }