Skip to content

Commit a0cb568

Browse files
Merge pull request #22 from CoderGamester/develop
Release 0.13.1
2 parents 73496f6 + 6e7195e commit a0cb568

File tree

3 files changed

+29
-89
lines changed

3 files changed

+29
-89
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this package will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [0.13.1] - 2024-11-04
8+
9+
**Fixed**:
10+
- Fixed the *IInstaller* when trying to bind multiple interfaces at the same time
11+
712
## [0.13.0] - 2024-11-04
813

914
**Changed**:

Runtime/Installer.cs

Lines changed: 23 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ public interface IInstaller
3636
/// <returns>
3737
/// This installer reference to allow chain calls if necessayr
3838
/// </returns>
39-
IInstaller Bind<T1, T2>(T1 instance) where T1 : class, T2;
39+
IInstaller Bind<T, T1, T2>(T instance)
40+
where T : class, T1, T2
41+
where T1 : class
42+
where T2 : class;
4043

4144
/// <summary>
4245
/// Binds the interface multiple type interefaces to the given <paramref name="instance"/>
@@ -47,18 +50,11 @@ public interface IInstaller
4750
/// <returns>
4851
/// This installer reference to allow chain calls if necessayr
4952
/// </returns>
50-
IInstaller Bind<T1, T2, T3>(T1 instance) where T1 : class, T2, T3;
51-
52-
/// <summary>
53-
/// Binds the interface multiple type interefaces to the given <paramref name="instance"/>
54-
/// </summary>
55-
/// <exception cref="ArgumentException">
56-
/// Thrown if the given <paramref name="instance"/> doesn't implement all type interface
57-
/// </exception>
58-
/// <returns>
59-
/// This installer reference to allow chain calls if necessayr
60-
/// </returns>
61-
IInstaller Bind<T1, T2, T3, T4>(T1 instance) where T1 : class, T2, T3, T4;
53+
IInstaller Bind<T, T1, T2, T3>(T instance)
54+
where T : class, T1, T2, T3
55+
where T1 : class
56+
where T2 : class
57+
where T3 : class;
6258

6359
/// <summary>
6460
/// Tries requesting the instance binded to the type <typeparamref name="T"/>
@@ -109,88 +105,27 @@ public IInstaller Bind<T>(T instance) where T : class
109105
}
110106

111107
/// <inheritdoc />
112-
public IInstaller Bind<T1, T2>(T1 instance) where T1 : class, T2
113-
{
114-
var type1 = typeof(T1);
115-
var type2 = typeof(T2);
116-
117-
if (!type1.IsInterface)
118-
{
119-
throw new ArgumentException($"Cannot bind {instance} because {type1} is not an interface");
120-
}
121-
122-
if (!type2.IsInterface)
123-
{
124-
throw new ArgumentException($"Cannot bind {instance} because {type1} is not an interface");
125-
}
126-
127-
_bindings.Add(type1, instance);
128-
_bindings.Add(type2, instance);
129-
130-
return this;
131-
}
132-
133-
/// <inheritdoc />
134-
public IInstaller Bind<T1, T2, T3>(T1 instance) where T1 : class, T2, T3
108+
public IInstaller Bind<T, T1, T2>(T instance)
109+
where T : class, T1, T2
110+
where T1 : class
111+
where T2 : class
135112
{
136-
var type1 = typeof(T1);
137-
var type2 = typeof(T2);
138-
var type3 = typeof(T3);
139-
140-
if (!type1.IsInterface)
141-
{
142-
throw new ArgumentException($"Cannot bind {instance} because {type1} is not an interface");
143-
}
144-
145-
if (!type2.IsInterface)
146-
{
147-
throw new ArgumentException($"Cannot bind {instance} because {type2} is not an interface");
148-
}
149-
150-
if (!type3.IsInterface)
151-
{
152-
throw new ArgumentException($"Cannot bind {instance} because {type3} is not an interface");
153-
}
154-
155-
_bindings.Add(type1, instance);
156-
_bindings.Add(type2, instance);
157-
_bindings.Add(type3, instance);
113+
Bind<T1>(instance);
114+
Bind<T2>(instance);
158115

159116
return this;
160117
}
161118

162119
/// <inheritdoc />
163-
public IInstaller Bind<T1, T2, T3, T4>(T1 instance) where T1 : class, T2, T3, T4
120+
public IInstaller Bind<T, T1, T2, T3>(T instance)
121+
where T : class, T1, T2, T3
122+
where T1 : class
123+
where T2 : class
124+
where T3 : class
164125
{
165-
var type1 = typeof(T1);
166-
var type2 = typeof(T2);
167-
var type3 = typeof(T3);
168-
var type4 = typeof(T4);
169-
170-
if (!type1.IsInterface)
171-
{
172-
throw new ArgumentException($"Cannot bind {instance} because {type1} is not an interface");
173-
}
174-
175-
if (!type2.IsInterface)
176-
{
177-
throw new ArgumentException($"Cannot bind {instance} because {type2} is not an interface");
178-
}
179-
180-
if (!type3.IsInterface)
181-
{
182-
throw new ArgumentException($"Cannot bind {instance} because {type3} is not an interface");
183-
}
184-
185-
if (!type4.IsInterface)
186-
{
187-
throw new ArgumentException($"Cannot bind {instance} because {type4} is not an interface");
188-
}
189-
190-
_bindings.Add(type1, instance);
191-
_bindings.Add(type2, instance);
192-
_bindings.Add(type3, instance);
193-
_bindings.Add(type4, instance);
126+
Bind<T1>(instance);
127+
Bind<T2>(instance);
128+
Bind<T3>(instance);
194129

195130
return this;
196131
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "com.gamelovers.services",
33
"displayName": "Services",
44
"author": "Miguel Tomas",
5-
"version": "0.13.0",
5+
"version": "0.13.1",
66
"unity": "2022.3",
77
"license": "MIT",
88
"description": "The purpose of this package is to provide a set of services to ease the development of a basic game architecture",

0 commit comments

Comments
 (0)