예제 #1
0
            public T Cache <T>(IRegisterRuleDescriptor rule, ILifetimeScope scope, T @object)
            {
                switch (rule.LifeStyle)
                {
                case ComponentLifeStyle.Transient:
                {
                    this.Push(@object);
                    return(@object);
                }

                case ComponentLifeStyle.Scoped:
                {
                    this.Push(@object);
                    if (this.Scope == null)
                    {
                        return(@object);
                    }

                    return(this.Scope.Cache(rule, @object));
                }

                case ComponentLifeStyle.Singleton:
                {
                    if (this.Singleton == null)
                    {
                        return(@object);
                    }

                    return(this.Singleton.Cache(rule, @object));
                }
                }
                return(@object);
            }
예제 #2
0
            public T Query <T>(IRegisterRuleDescriptor rule, ILifetimeScope scope)
            {
                switch (rule.LifeStyle)
                {
                case ComponentLifeStyle.Transient:
                {
                    return(default(T));
                }

                case ComponentLifeStyle.Scoped:
                {
                    if (this.Scope == null)
                    {
                        return(default(T));
                    }

                    return(this.Scope.Query <T>(rule));
                }

                case ComponentLifeStyle.Singleton:
                {
                    if (this.Singleton == null)
                    {
                        return(default(T));
                    }

                    return(this.Singleton.Query <T>(rule));
                }
                }

                return(default(T));
            }
예제 #3
0
            public T Query <T>(IRegisterRuleDescriptor rule)
            {
                if (rule is RegisterRule)
                {
                    return(this.Query <T>((RegisterRule)rule));
                }

                return(ContextCache == null ? default(T) : ContextCache.Get <T>(rule.ToString()));
            }
예제 #4
0
            public T Cache <T>(IRegisterRuleDescriptor rule, T @object)
            {
                if (ContextCache == null)
                {
                    return(@object);
                }

                ContextCache.Set(rule.ToString(), @object);
                return(@object);
            }