public static T GetService <T>(string serviceId, bool isNew) where T : class, IAlbianService { if (!isNew) { return(GetService <T>(serviceId)); } IDictionary <string, IAlbianServiceAttrbuite> serviceInfos = FreeServiceConfigParser.ServiceConfigInfo; if (serviceInfos.ContainsKey(serviceId)) { if (null != Logger) { Logger.WarnFormat("There is not {0} serice info.", serviceId); } return(null); } IAlbianServiceAttrbuite serviceInfo = serviceInfos[serviceId]; Type type = Type.GetType(serviceInfo.Type); IAlbianService service = (IAlbianService)Activator.CreateInstance(type); service.BeforeLoading(); service.Loading(); service.AfterLoading(); return((T)service); }
public override IDictionary <string, IAlbianServiceAttrbuite> ServicesParser(XmlNodeList nodes) { if (null == nodes || 0 == nodes.Count) { if (null != Logger) { Logger.Error("There is not 'Service' config item in the service.config."); } throw new ArgumentNullException("nodes"); } IDictionary <string, IAlbianServiceAttrbuite> services = new Dictionary <string, IAlbianServiceAttrbuite>(); foreach (XmlNode node in nodes) { IAlbianServiceAttrbuite serviceAttr = ServiceParser(node); services.Add(serviceAttr.Id, serviceAttr); } return(services); }