private object CreateType(ITypeRegistration registration) { var packageManager = (NiPackageManager)GetService(typeof(INiPackageManager)); var package = packageManager.Packages[registration.Package]; return(package.CreateInstanceAndUnwrap(registration.Type)); }
public override void OnRegisterModel(ITypeRegistration registration) { registration.RegisterType<Passport>().RegisterType<Profile>(); registration.RegisterType<Nationality>().RegisterType<GlobalRegion>().RegisterType<NativePlace>(); registration.RegisterType<UserIcon>().RegisterType<Level>(); registration.RegisterType<LoginHistory>(); }
public static ITypeRegistration BasedOn(this ITypeRegistration registration, Type type) { var context = registration.Context; context.BasedOn = type; return(registration); }
public override void OnRegisterModel(ITypeRegistration registration) { registration.RegisterType<Tripper>(); registration.RegisterType<TripperLife>().RegisterType<TripPlan>().RegisterType<TripPoint>(); registration.RegisterType<Continent>().RegisterType<Nation>().RegisterType<City>().RegisterType<Spot>(); //registration.RegisterType<LocationRefer>().RegisterType<LocationSnapshoot>(); }
public override void OnRegisterModel(ITypeRegistration registration) { registration.RegisterType <Tripper>(); registration.RegisterType <TripperLife>().RegisterType <TripPlan>().RegisterType <TripPoint>(); registration.RegisterType <Continent>().RegisterType <Nation>().RegisterType <City>().RegisterType <Spot>(); //registration.RegisterType<LocationRefer>().RegisterType<LocationSnapshoot>(); }
/// <summary> /// Add a custom component IoC registration into Bootstrapper for IoC component. /// </summary> /// <param name="registration">Registration to add.</param> /// <returns>Instance of the boostrapper</returns> public Bootstrapper AddIoCRegistration(ITypeRegistration registration) { if (registration == null) { throw new ArgumentNullException(nameof(registration)); } _iocRegistrations.Add(registration); return(this); }
public T Resolve <T>() { ITypeRegistration typeRegistration = this.registration.Get <T>(); if (typeRegistration != null) { return((T)(typeRegistration as BaseRegistrationInfo).GetImplementation()); } return(default(T)); }
internal void Dispose(Type type) { ITypeRegistration reg = this.registration.Get(type.FullName); if (reg == null) { return; } (reg as BaseRegistrationInfo).Dispose(); }
public static TInterface Resolve <TInterface>(TypeResolverContext context) { ITypeRegistration registration = context.RegisteredTypes.FirstOrDefault(tr => tr.InterfaceType == typeof(TInterface)); if (null == registration) { throw new InvalidOperationException("Unregistered interfaces cannot be resolved to a concrete type."); } TypeConstructor typeConstructor = ResolveDependencies(context, registration); return((TInterface)typeConstructor.Constructor.Invoke(typeConstructor.Parameters)); }
public TInterface Resolve <TInterface>() where TInterface : class { ITypeRegistration registration = TypeRegistry.Select(kvp => kvp.Value) .Where(tr => tr.InterfaceType == typeof(TInterface)).FirstOrDefault(); if (null == registration) { throw new InvalidOperationException("Unregistered interfaces cannot be resolved to a concrete type."); } return((TInterface)TypeResolver.ResolveWithLifeStyle <TInterface>(new TypeResolverContext() { RegisteredTypes = (IList <ITypeRegistration>)TypeRegistry.Values.ToList() }, registration.LifeStyle)); }
private static TypeConstructor ResolveDependencies(TypeResolverContext context, ITypeRegistration registration) { ConstructorInfo defaultConstructor = null; foreach (ConstructorInfo constructor in registration.ConcreteType.GetConstructors(BindingFlags.Instance | BindingFlags.Public)) { IList <ParameterInfo> parameters = constructor.GetParameters(); if (parameters.Count == 0) { defaultConstructor = constructor; continue; } if (!parameters.All(p => context.RegisteredTypes.Any(r => r.InterfaceType == p.ParameterType))) { continue; } List <object> resolvedDependencies = new List <object>(parameters.Count); foreach (ParameterInfo parameter in parameters) { ITypeRegistration parameterType = context.RegisteredTypes.First(r => r.InterfaceType == parameter.ParameterType); resolvedDependencies.Add(Resolve(parameterType.InterfaceType, context, parameterType.LifeStyle)); } return(new TypeConstructor() { Constructor = constructor, Parameters = resolvedDependencies.ToArray() }); } return(new TypeConstructor() { Constructor = defaultConstructor, Parameters = null }); }
public override void OnRegisterModel(ITypeRegistration registration) { registration.RegisterType<PassPhrase>().RegisterType<Profile>(); registration.RegisterType<Group>().RegisterType<Organization>().RegisterType<Community>(); registration.RegisterType<SnapProfile>(); }
public override void OnRegisterModel(ITypeRegistration registration) { registration.RegisterType <PassPhrase>().RegisterType <Profile>(); registration.RegisterType <Group>().RegisterType <Organization>().RegisterType <Community>(); registration.RegisterType <SnapProfile>(); }
public override void OnRegisterModel(ITypeRegistration registration) { registration.RegisterType <Person>().RegisterType <Group>().RegisterType <Organization>().RegisterType <Community>(); registration.RegisterType <Application>(); }
public override void OnRegisterModel(ITypeRegistration registration) { registration.RegisterType <One>(); }
public override void OnRegisterModel(ITypeRegistration registration) { registration.RegisterType<Factory>().RegisterType<Worker>(); }
public override void OnRegisterModel(ITypeRegistration registration) { registration.RegisterType <Company>().RegisterType <Employee>().RegisterType <Factory>(); }
public abstract void OnRegisterModel(ITypeRegistration registration);
public override void OnRegisterModel(ITypeRegistration registration) { registration.RegisterType <Factory>().RegisterType <Worker>(); }
public override void OnRegisterModel(ITypeRegistration registration) { registration.RegisterType<One>(); }
public override void OnRegisterModel(ITypeRegistration registration) { registration.RegisterType<iTripPackage>().RegisterType<Content>(); registration.RegisterType<Holder>().RegisterType<PackageHolding>(); }
public static ITypeRegistration BasedOn <T>(this ITypeRegistration registration) { return(registration.BasedOn(typeof(T))); }
public override void OnRegisterModel(ITypeRegistration registration) { registration.RegisterType<Passport>().RegisterType<Profile>(); }
public override void OnRegisterModel(ITypeRegistration registration) { registration.RegisterType<Person>().RegisterType<Group>().RegisterType<Organization>().RegisterType<Community>(); registration.RegisterType<Application>(); }
public override void OnRegisterModel(ITypeRegistration registration) { registration.RegisterType <Models.DocModel>(); }
public override void OnRegisterModel(ITypeRegistration registration) { registration.RegisterType <Passport>().RegisterType <Profile>(); }
public override void OnRegisterModel(ITypeRegistration registration) { registration.RegisterType<Company>().RegisterType<Employee>().RegisterType<Factory>(); }
public override void OnRegisterModel(ITypeRegistration registration) { registration.RegisterType <Student>().RegisterType <Teacher>().RegisterType <Grade>().RegisterType <MyFile>(); registration.RegisterType <School>(); registration.RegisterType <TypeTest>(); }
public override void OnRegisterModel(ITypeRegistration registration) { registration.RegisterType<Student>().RegisterType<Teacher>().RegisterType<Grade>().RegisterType<MyFile>(); registration.RegisterType<School>(); registration.RegisterType<TypeTest>(); }
public static void AsCustomResolvingStrategy(this ITypeRegistration typeRegistration) { var currentItemRegistration = typeRegistration as TypeRegistration; currentItemRegistration.Container.Register(currentItemRegistration, byte.MaxValue); }