コード例 #1
0
        public override object Resolve(ResolveContext context, DependencyRegistration registration)
        {
            object instance;

            if (!_instances.TryGetValue(registration.Key, out instance))
                lock (_instances)
                {
                    if (!_instances.TryGetValue(registration.Key, out instance))
                        _instances.Add(registration.Key, instance = base.Resolve(context, registration));
                }
            return instance;
        }
コード例 #2
0
        public override object Resolve(ResolveContext context, DependencyRegistration registration)
        {
            CheckContextStoreAvailable();

            object instance;
            var contextStore = Resolver.Resolve<IContextStore>();

            if ((instance = contextStore[registration.Key]) == null)
            {
                if (registration.IsInstanceRegistration)
                    throw new DependencyResolutionException("A dependency registered as an instance wasn't found. The registration was removed.");

                instance = base.Resolve(context, registration);

                StoreInstanceInContext(contextStore, registration.Key, instance);
            }
            return instance;
        }
コード例 #3
0
 public ObjectBuilder(ResolveContext context, ILogger log)
 {
     ResolveContext = context;
     Log = log;
 }
コード例 #4
0
 public virtual object Resolve(ResolveContext context, DependencyRegistration registration)
 {
     return context.Builder.CreateObject(registration);
 }