-
Notifications
You must be signed in to change notification settings - Fork 517
/
Copy pathResolver.erb
69 lines (61 loc) · 2.76 KB
/
Resolver.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//
// Resolver.swift
// Swinject
//
// Created by Yoichi Tagaya on 8/18/15.
// Copyright (c) 2015 Swinject Contributors. All rights reserved.
//
//
// NOTICE:
//
// Resolver.swift is generated from Resolver.erb by ERB.
// Do NOT modify Container.Arguments.swift directly.
// Instead, modify Resolver.erb and run `script/gencode` at the project root directory to generate the code.
//
<% arg_count = 9 %>
public protocol Resolver {
/// Retrieves the instance with the specified service type.
///
/// - Parameter serviceType: The service type to resolve.
///
/// - Returns: The resolved service type instance, or nil if no service is found.
func resolve<Service>(_ serviceType: Service.Type) -> Service?
/// Retrieves the instance with the specified service type and registration name.
///
/// - Parameters:
/// - serviceType: The service type to resolve.
/// - name: The registration name.
///
/// - Returns: The resolved service type instance, or nil if no service with the name is found.
func resolve<Service>(_ serviceType: Service.Type, name: String?) -> Service?
<% (1..arg_count).each do |i| %>
<% arg_types = (1..i).map { |n| "Arg#{n}" }.join(", ") %>
<% arg_param = i == 1 ? "argument: Arg1" : "arguments arg1: Arg1, " + (2..i).map{ |n| "_ arg#{n}: Arg#{n}" }.join(", ") %>
<% arg_param_name = i == 1 ? "argument" : "arguments" %>
<% arg_param_description = i == 1 ? "#{i} argument" : "list of #{i} arguments" %>
/// Retrieves the instance with the specified service type and <%= arg_param_description %> to the factory closure.
///
/// - Parameters:
/// - serviceType: The service type to resolve.
/// - <%= arg_param_name %>: <%= arg_param_description.capitalize %> to pass to the factory closure.
///
/// - Returns: The resolved service type instance, or nil if no registration for the service type
/// and <%= arg_param_description %> is found.
func resolve<Service, <%= arg_types %>>(
_ serviceType: Service.Type,
<%= arg_param %>) -> Service?
/// Retrieves the instance with the specified service type, <%= arg_param_description %> to the factory closure and registration name.
///
/// - Parameters:
/// - serviceType: The service type to resolve.
/// - name: The registration name.
/// - <%= arg_param_name %>: <%= arg_param_description.capitalize %> to pass to the factory closure.
///
/// - Returns: The resolved service type instance, or nil if no registration for the service type,
/// <%= arg_param_description %> and name is found.
func resolve<Service, <%= arg_types %>>(
_ serviceType: Service.Type,
name: String?,
<%= arg_param %>) -> Service?
<% end %>
}