0001    //
0002    //  ServiceEntry.swift
0003    //  Swinject
0004    //
0005    //  Created by Yoichi Tagaya on 7/24/15.
0006    //  Copyright © 2015 Swinject Contributors. All rights reserved.
0007    //
0008    
0009    import Foundation
0010    
0011    // A generic-type-free protocol to be the type of values in a strongly-typed collection.
0012    internal typealias ServiceEntryType
Container.swift:30
    private var services = [ServiceKey: ServiceEntryType]()
ServiceEntry.swift:16
public final class ServiceEntry<Service>: ServiceEntryType {
= Any 0013 0014 /// The `ServiceEntry<Service>` class represents an entry of a registered service type. 0015 /// As a returned instance from a `register` method of a `Container`, some configurations can be added. 0016 public final class ServiceEntry
Container.Arguments.swift:37
        factory: (ResolverType, Arg1) -> Service) -> ServiceEntry<Service>
Container.Arguments.swift:57
        factory: (ResolverType, Arg1, Arg2) -> Service) -> ServiceEntry<Service>
Container.Arguments.swift:77
        factory: (ResolverType, Arg1, Arg2, Arg3) -> Service) -> ServiceEntry<Service>
Container.Arguments.swift:97
        factory: (ResolverType, Arg1, Arg2, Arg3, Arg4) -> Service) -> ServiceEntry<Service>
Container.Arguments.swift:117
        factory: (ResolverType, Arg1, Arg2, Arg3, Arg4, Arg5) -> Service) -> ServiceEntry<Service>
Container.Arguments.swift:137
        factory: (ResolverType, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6) -> Service) -> ServiceEntry<Service>
Container.Arguments.swift:157
        factory: (ResolverType, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7) -> Service) -> ServiceEntry<Service>
Container.Arguments.swift:177
        factory: (ResolverType, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8) -> Service) -> ServiceEntry<Service>
Container.Arguments.swift:197
        factory: (ResolverType, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9) -> Service) -> ServiceEntry<Service>
Container.swift:74
        factory: ResolverType -> Service) -> ServiceEntry<Service>
Container.swift:79
    internal func registerImpl<Service, Factory>(serviceType: Service.Type, factory: Factory, name: String?) -> ServiceEntry<Service> {
Container.swift:81
        let entry = ServiceEntry(serviceType: serviceType, factory: factory)
Container.swift:147
        if let (entry, fromParent) = getEntry(key) as (ServiceEntry<Service>, Bool)? {
Container.swift:152
                let ownEntry: ServiceEntry<Service>
Container.swift:174
    private func getEntry<Service>(key: ServiceKey) -> (ServiceEntry<Service>, Bool)? {
Container.swift:176
        var entry = services[key] as? ServiceEntry<Service>
Container.swift:178
            if let (parentEntry, _) = parent.getEntry(key) as (ServiceEntry<Service>, Bool)? {
Container.swift:186
    private func resolveEntry<Service, Factory>(entry: ServiceEntry<Service>, key: ServiceKey, invoker: Factory -> Service) -> Service {
ServiceEntry.swift:29
    internal func copyExceptInstance() -> ServiceEntry<Service> {
ServiceEntry.swift:30
        let copy = ServiceEntry(serviceType: serviceType, factory: factory)
<Service
ServiceEntry.swift:17
    private let serviceType: Service.Type
ServiceEntry.swift:24
    internal init(serviceType: Service.Type, factory: FunctionType) {
ServiceEntry.swift:29
    internal func copyExceptInstance() -> ServiceEntry<Service> {
ServiceEntry.swift:53
    public func initCompleted(completed: (ResolverType, Service) -> ()) -> Self {
>: ServiceEntryType { 0017 private let serviceType
ServiceEntry.swift:25
        self.serviceType = serviceType
ServiceEntry.swift:30
        let copy = ServiceEntry(serviceType: serviceType, factory: factory)
: Service.Type 0018 internal let factory
Container.swift:192
        let resolvedInstance = invoker(entry.factory as! Factory)
ServiceEntry.swift:26
        self.factory = factory
ServiceEntry.swift:30
        let copy = ServiceEntry(serviceType: serviceType, factory: factory)
: FunctionType 0019 0020 internal var objectScope
Container.swift:148
            switch entry.objectScope {
Container.swift:187
        let usesPool = entry.objectScope != .None
ServiceEntry.swift:31
        copy.objectScope = objectScope
ServiceEntry.swift:31
        copy.objectScope = objectScope
ServiceEntry.swift:42
        self.objectScope = objectScope
= ObjectScope.Graph 0021 internal var initCompleted
Container.swift:201
        if let completed = entry.initCompleted as? (ResolverType, Service) -> () {
ServiceEntry.swift:32
        copy.initCompleted = initCompleted
ServiceEntry.swift:32
        copy.initCompleted = initCompleted
ServiceEntry.swift:54
        initCompleted = completed
: FunctionType? 0022 internal var instance
Container.swift:160
                if ownEntry.instance == nil {
Container.swift:161
                    ownEntry.instance = resolveEntry(entry, key: key, invoker: invoker) as Any
Container.swift:163
                resolvedInstance = ownEntry.instance as? Service
Container.swift:165
                if entry.instance == nil {
Container.swift:166
                    entry.instance = resolveEntry(entry, key: key, invoker: invoker) as Any
Container.swift:168
                resolvedInstance = entry.instance as? Service
: Any? 0023 0024 internal init
Container.swift:81
        let entry = ServiceEntry(serviceType: serviceType, factory: factory)
ServiceEntry.swift:30
        let copy = ServiceEntry(serviceType: serviceType, factory: factory)
(serviceType: Service.Type, factory: FunctionType) { 0025 self.serviceType = serviceType 0026 self.factory = factory 0027 } 0028 0029 internal func copyExceptInstance
Container.swift:154
                    ownEntry = entry.copyExceptInstance()
() -> ServiceEntry<Service> { 0030 let copy = ServiceEntry(serviceType: serviceType, factory: factory) 0031 copy.objectScope = objectScope 0032 copy.initCompleted = initCompleted 0033 return copy 0034 } 0035 0036 /// Specifies the object scope to resolve the service. 0037 /// 0038 /// - Parameter scope: The `ObjectScope` value. 0039 /// 0040 /// - Returns: `self` to add another configuration fluently. 0041 public func inObjectScope(objectScope: ObjectScope) -> Self { 0042 self.objectScope = objectScope 0043 return self 0044 } 0045 0046 /// Adds the callback to setup the instance after its `init` completes. 0047 /// *Property or method injections* can be performed in the callback. 0048 /// To resolve *circular dependencies*, `initCompleted` must be used. 0049 /// 0050 /// - Parameter completed: The closure to be called after the instantiation of the registered service. 0051 /// 0052 /// - Returns: `self` to add another configuration fluently. 0053 public func initCompleted(completed: (ResolverType, Service) -> ()) -> Self { 0054 initCompleted = completed 0055 return self 0056 } 0057 } 0058