Exemple #1
0
 /// <summary>
 /// see constructor
 /// </summary>
 /// <param name="rootBeanName">see constructor</param>
 /// <param name="rootConstructorName">see constructor</param>
 /// <param name="scope">see constructor</param>
 public void Deconstruct(out string rootBeanName, out string rootConstructorName
                         , out BeanScope scope)
 {
     rootBeanName        = RootBeanName;
     rootConstructorName = RootConstrutorName;
     scope = Scope;
 }
Exemple #2
0
 /// <param name="rootBeanName">pass a bean name in the edge case when an interface
 /// or base class is passed as the root type but has multiple implementations</param>
 /// <param name="rootConstructorName">pass a constructor name in the edge case when
 /// a class is being passed as the root type with multiple constructors</param>
 /// <param name="scope">See links below for an explanation of scope.  The scope passed in will apply to the
 /// root bean only.  It has no effect on the rest of the tree.</param>
 /// <seealso cref="BeanReferenceAttribute">see BeanReference for an explanation of Scope</seealso>
 public RootBeanSpec(string rootBeanName          = Constants.DefaultBeanName
                     , string rootConstructorName = Constants.DefaultConstructorName, BeanScope scope = BeanScope.Singleton)
 {
     RootBeanName       = rootBeanName == null ? throw new ArgumentNullException() : rootBeanName.ToLower();
     RootConstrutorName = rootConstructorName == null ? throw new ArgumentNullException() : rootConstructorName.ToLower();
     Scope = scope;
 }
Exemple #3
0
        CreateAndInjectDependencies(Type rootType, InjectionState injectionState, string rootBeanName
                                    , string rootConstructorName, BeanScope scope)
        {
            try
            {
                Assert(rootType != null);
                Assert(rootBeanName != null);
                object rootObject;

                (rootObject, injectionState) = CreateObjectTree(
                    new BeanSpec(rootType, rootBeanName, rootConstructorName)
                    , injectionState.CreationContext, injectionState, new BeanReferenceDetails(), scope, MakeBean);
                if (rootObject != null && !rootType.IsInstanceOfType(rootObject))
                {
                    throw new DIException(
                              $"object created by IOC container is not {rootType.Name} as expected",
                              injectionState.Diagnostics);
                }

                Assert(rootObject == null ||
                       rootType.IsInstanceOfType(rootObject));
                return(rootObject, injectionState);
            }
            catch (NoArgConstructorException inace) // I suspect this is never executed
            {
                dynamic diagnostic = injectionState.Diagnostics.Groups["MissingNoArgConstructor"].CreateDiagnostic();
                diagnostic.Class = rootType.GetSafeFullName();
                injectionState.Diagnostics.Groups["MissingNoArgConstructor"].Add(diagnostic);
                throw new DIException("Failed to create object tree - see diagnostics for details", inace,
                                      injectionState.Diagnostics);
            }
            finally
            {
                RecordIncompleteAssignments(injectionState);
            }
        }
Exemple #4
0
 private delegate(bool constructionComplete, object beanId) BeanMaker(BeanScope beanScope, BeanSpec beanSpec
                                                                      , Type constructableType
                                                                      , IDictionary <InstantiatedBeanId, object> mapObjectsCreatedSoFar
                                                                      , Diagnostics diagnostics
                                                                      , IReadOnlyList <ChildBeanSpec> constructorParameterSpecs = null, CreationContext creationContext = null);
 public Key(bool deferredInjection, BeanScope beanScope)
 {
     _deferredInjection = deferredInjection;
     _beanScope         = beanScope;
 }
 public RootObjectDecisionTable(bool deferred, BeanScope beanScope)
 {
     _entry = map[new Key(deferred, beanScope)];
 }