Пример #1
0
            public void Add(IocData data)
            {
                if (data == null)
                {
                    return;
                }

                Validate(data);
                store.AddOrUpdate(data.ServiceType, data, (k, v) => data);
            }
Пример #2
0
            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");
                }
            }
Пример #3
0
 public static void Register <TDef, TImpl>(IoCScope scope = IoCScope.InstancePerLifetimeScope)
     where TImpl : class, TDef
 {
     registerdTypes.Add(IocData.Create <TDef, TImpl>(scope));
 }