DefinitionsOf returns a slice of component definitions that are assignable to the specified type.
(typ reflect.Type)
| 175 | |
| 176 | // DefinitionsOf returns a slice of component definitions that are assignable to the specified type. |
| 177 | func (d *DefaultContainer) DefinitionsOf(typ reflect.Type) []*Definition { |
| 178 | muComponents.RLock() |
| 179 | defer muComponents.RUnlock() |
| 180 | |
| 181 | matches := make([]*Definition, 0) |
| 182 | |
| 183 | for _, def := range d.definitions { |
| 184 | sourceType := def.Type() |
| 185 | if convertibleTo(sourceType, typ) { |
| 186 | matches = append(matches, def) |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | return matches |
| 191 | } |
| 192 | |
| 193 | // RegisterSingleton registers a singleton instance with the given name. |
| 194 | // Returns an error if a singleton with the same name already exists. |