예제 #1
0
        private object GetUnscoped(Type type, bool isRequired)
        {
            var retry = false;

            while (true)
            {
                object result;
                if (TryGetProperty(type, out result))
                {
                    return(result);
                }

                if (_parent != null)
                {
                    return(_parent.Get(type, null, isRequired));
                }

                if (!isRequired)
                {
                    return(null);
                }

                if (retry)
                {
                    throw RetryFailedException(type);
                }

                DataContextBuilder.AddMissingData(_renderContext, _dataDependencyFactory.Create(type));
                retry = true;
            }
        }
예제 #2
0
        private object GetScoped(Type type, string scopeName, bool isRequired)
        {
            var retry = false;

            while (true)
            {
                object result;
                if (TryGetProperty(type, scopeName, out result))
                {
                    return(result);
                }

                var dependency = _dataDependencyFactory.Create(type, scopeName);
                var isInScope  = DataContextBuilder.IsInScope(dependency);

                if (!isInScope)
                {
                    if (_parent == null)
                    {
                        if (!isRequired)
                        {
                            return(null);
                        }
                        throw ScopeSearchFailedException(type, scopeName);
                    }

                    return(_parent.Get(type, scopeName, isRequired));
                }

                if (!isRequired)
                {
                    return(null);
                }

                if (retry)
                {
                    throw RetryFailedException(type);
                }

                DataContextBuilder.AddMissingData(_renderContext, dependency);
                retry = true;
            }
        }