public void Add(IocData data) { if (data == null) { return; } Validate(data); store.AddOrUpdate(data.ServiceType, data, (k, v) => data); }
private void Validate(IocData data) { if (data == null) { throw new ArgumentNullException(nameof(data)); } if (!data.ServiceType.IsInterface) { throw new ArgumentException("service type should be interface"); } if (!data.ImplType.IsClass || data.ImplType.IsAbstract) { throw new ArgumentException("implement type should be non abstract class"); } }
public static void Register <TDef, TImpl>(IoCScope scope = IoCScope.InstancePerLifetimeScope) where TImpl : class, TDef { registerdTypes.Add(IocData.Create <TDef, TImpl>(scope)); }