public TypeInjector(Type type, IObjectFactory objectFactory) { lemming = Lemming.From(type); CreatePropertiesCache(); this.objectFactory = objectFactory; }
private void Add(Lemming lemming) { if (!lemming.IsGenericDefinition) { preparedLemmings.Add(lemming); } else { genericLemmings.Add(lemming); } }
/// <summary> /// Adds the lemming to the current context /// </summary> /// <param name = "lemming">The lemming to add</param> protected override void AddToContext(Lemming lemming) { var builder = ObjectDefinitionBuilder.RootObjectDefinition(new DefaultObjectDefinitionFactory(), lemming.ConcreteType); builder.SetAutowireMode(AutoWiringMode.ByName); builder.SetSingleton(lemming.Singleton); foreach (var injection in lemming.Injections) { injection.Accept(new SpringInjector(injection.Property.Name, builder)); } objectDefinitionRegistry.RegisterObjectDefinition(lemming.UniqueName, builder.ObjectDefinition); }
private void ValidateGenericInjections(Lemming lemming) { var refereneces = GetGenericInjections(lemming.Injections); PrepareGenericTypes(refereneces, true); foreach (var preparedLemming in preparedLemmings) { if (addedLemmings.Contains(preparedLemming)) { continue; } NameUnnamedInjections(UnnamedReferences(preparedLemming)); RegisterGenericLemming(preparedLemming); addedLemmings.Add(preparedLemming); addedGenericLemmings.Add(preparedLemming); } }
private void RegisterGenericLemming(Lemming lemming) { AddToContext(lemming); }
protected abstract void AddToContext(Lemming lemming);
private static Lemming LemmingsCollection(Type type) { var lemmingType = typeof(LemmingsCollection <>).MakeGenericType(type); return(Lemming.From(lemmingType)); }
private static IEnumerable <ReferenceInjection> UnnamedReferences(Lemming lemming) { return (lemming.Injections.OfType <ReferenceInjection>().Where( x => string.IsNullOrWhiteSpace(x.ReferencedLemming) && !x.IsGeneric)); }