public void RegistOneTypeByInterface(Type oneType, CompentAttribute useAttribute) { foreach (var oneInterfaceType in oneType.GetInterfaces()) { //若是单例 if (useAttribute.Singleton) { //若赋名称 if (!string.IsNullOrWhiteSpace(useAttribute.Name)) { m_useContainer.RegisterSingleton(oneInterfaceType, oneType, useAttribute.Name); } else { m_useContainer.RegisterSingleton(oneInterfaceType, oneType); } } //若不是单例 else { //若赋名称 if (!string.IsNullOrWhiteSpace(useAttribute.Name)) { m_useContainer.RegisterType(oneInterfaceType, oneType, useAttribute.Name); } else { m_useContainer.RegisterType(oneInterfaceType, oneType); } } } }
public void RegistOneTypeByClass(Type oneType, CompentAttribute useAttribute) { //若是单例 if (useAttribute.Singleton) { //若赋名称 if (!string.IsNullOrWhiteSpace(useAttribute.Name)) { m_useContainer.RegisterSingleton(oneType, useAttribute.Name); } else { m_useContainer.RegisterSingleton(oneType); } } //若不是单例 else { //若赋名称 if (!string.IsNullOrWhiteSpace(useAttribute.Name)) { m_useContainer.RegisterType(oneType, useAttribute.Name); } else { m_useContainer.RegisterType(oneType); } } }