コード例 #1
0
ファイル: TypeInjector.cs プロジェクト: tmilar/encuentrame
        public TypeInjector(Type type, IObjectFactory objectFactory)
        {
            lemming = Lemming.From(type);
            CreatePropertiesCache();

            this.objectFactory = objectFactory;
        }
コード例 #2
0
 private void Add(Lemming lemming)
 {
     if (!lemming.IsGenericDefinition)
     {
         preparedLemmings.Add(lemming);
     }
     else
     {
         genericLemmings.Add(lemming);
     }
 }
コード例 #3
0
        /// <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);
        }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
 private void RegisterGenericLemming(Lemming lemming)
 {
     AddToContext(lemming);
 }
コード例 #6
0
 protected abstract void AddToContext(Lemming lemming);
コード例 #7
0
        private static Lemming LemmingsCollection(Type type)
        {
            var lemmingType = typeof(LemmingsCollection <>).MakeGenericType(type);

            return(Lemming.From(lemmingType));
        }
コード例 #8
0
 private static IEnumerable <ReferenceInjection> UnnamedReferences(Lemming lemming)
 {
     return
         (lemming.Injections.OfType <ReferenceInjection>().Where(
              x => string.IsNullOrWhiteSpace(x.ReferencedLemming) && !x.IsGeneric));
 }