Exemple #1
0
        private SimultaneousInjectFrame injectMoreSimultaneously_internal(
            SimultaneousInjectFrame soFar,
            object dependency,
            Type toMatchAgainst,
            bool isWildcard
            )
        {
            if (currentStackLevel != soFar.parentStackLevel + 1)
            {
                throw new InvalidDIStateException(
                          $"Cannot inject another dependency simultaneously as stack level has changed " +
                          $"(object dependency = '{dependency}', Type toMatchAgainst = '{toMatchAgainst}', " +
                          $"current stack level = '{currentStackLevel}', " +
                          $"required stack level (soFar.parentStackLevel + 1) = '{soFar.parentStackLevel + 1}'"
                          );
            }

            currentStackLevel--;
            SimultaneousInjectFrame result;

            try {
                result = injectSimul_internal(
                    soFar.IsEmpty ? ImmutableStack.Create <Type>() : soFar.types,
                    dependency,
                    toMatchAgainst,
                    isWildcard
                    );
            } finally {
                currentStackLevel++;
            }

            return(result);
        }
Exemple #2
0
        internal override void CloseInjectFrame(SimultaneousInjectFrame frame)
        {
            if (frame.IsEmpty)
            {
                return;
            }

            if (frame.layer != this)
            {
                throw new InjectFrameCloseException(
                          $"Cannot close inject frame as it does not belong to the current dependency layer " +
                          $"(current layer = '{this}', {nameof(frame)}.{nameof(InjectFrame.layer)} = '{frame.layer}')"
                          );
            }

            if (frame.parentStackLevel + 1 != currentStackLevel)
            {
                throw new InjectFrameCloseException(
                          $"Cannot close inject frame with parent stack level '{frame.parentStackLevel}' " +
                          $"as it is not exactly one less than the current stack level '{currentStackLevel}'.",
                          DisposeExceptionsManager.WrapLastExceptionThrown()
                          );
            }

            foreach (Type t in frame.types)
            {
                uninjectDependency_internal(t, frame.parentStackLevel);
            }
        }
Exemple #3
0
        private SimultaneousInjectFrame injectSimul_internal(
            ImmutableStack <Type> soFar,
            object dependency,
            Type toMatchAgainst,
            bool isWildcard
            )
        {
            SimultaneousInjectFrame result;

            if (isWildcard)
            {
                ImmutableStack <Type> resStack = soFar;
                foreach (Type t in addWildcardToStack_internal(dependency, toMatchAgainst))
                {
                    resStack = resStack.Push(t);
                }

                result = new SimultaneousInjectFrame(layer: this, currentStackLevel, resStack);
            }
            else
            {
                addToStack_internal(dependency, toMatchAgainst);

                result = new SimultaneousInjectFrame(layer: this, currentStackLevel, soFar.Push(toMatchAgainst));
            }

            currentStackLevel++;
            return(result);
        }
Exemple #4
0
 internal override SimultaneousInjectFrame InjectMoreSimultaneously <T>(
     SimultaneousInjectFrame soFar,
     T dependency,
     bool isWildcard
     )
 {
     return(injectMoreSimultaneously_internal(soFar, dependency, typeof(T), isWildcard));
 }
Exemple #5
0
        internal override SimultaneousInjectFrame InjectMoreSimultaneously(
            SimultaneousInjectFrame soFar,
            object dependency,
            Type toMatchAgainst,
            bool isWildcard
            )
        {
            if (toMatchAgainst == null)
            {
                throw new ArgumentNullException(
                          nameof(toMatchAgainst),
                          $"Cannot inject dependency with a null Type to match against " +
                          $"(dependency object = '{dependency}', isWildcard = {isWildcard})."
                          );
            }
            RequireDependencySubtypeOf(dependency, toMatchAgainst);

            return(injectMoreSimultaneously_internal(soFar, dependency, toMatchAgainst, isWildcard));
        }
Exemple #6
0
 internal override SimultaneousInjectFrame InjectMoreSimultaneously(SimultaneousInjectFrame soFar, object dependency, Type toMatchAgainst, bool isWildcard)
 {
     throw new NotImplementedException();
 }
Exemple #7
0
 internal override SimultaneousInjectFrame InjectMoreSimultaneously <T>(SimultaneousInjectFrame soFar, T dependency, bool isWildcard)
 {
     throw new NotImplementedException();
 }
Exemple #8
0
 internal override void CloseInjectFrame(SimultaneousInjectFrame frame)
 {
     throw new NotImplementedException();
 }