diff --git a/Runtime/Core/Context/DIContainer.cs b/Runtime/Core/Context/DIContainer.cs index 5a5cd3d..4fd6e85 100644 --- a/Runtime/Core/Context/DIContainer.cs +++ b/Runtime/Core/Context/DIContainer.cs @@ -94,6 +94,32 @@ public T Resolve(Type type = null, string id = "") where T : class return bindedObject.CreatedObject as T; } + public T[] ResolveAll(Type type = null, string id = "") where T : class + { + type ??= typeof(T); + + Predicate predicate = string.IsNullOrEmpty(id) + ? x => x.Type == type || x.InterfaceType == type + : x => x.Id == id && (x.Type == type || x.InterfaceType == type); + + OptimizedList bindedObjects = _bindedObjects.FindAll(predicate); + if (bindedObjects == null || bindedObjects.Count == 0) + { + return _parentDIContainer?.ResolveAll(type, id); + } + + T[] createdObjects = new T[bindedObjects.Count]; + + for (int index = 0; index < bindedObjects.Count; index++) + { + TryCreateBindedObject(bindedObjects[index]); + + createdObjects[index] = bindedObjects[index].CreatedObject as T; + } + + return createdObjects; + } + private void TryCreateBindedObject(BindedObject bindedObject) { if (bindedObject.CreatedObject != null || !bindedObject.Type.TryGetDependencies(out object[] objects, this)) diff --git a/Runtime/Utility/InjectionHelper.cs b/Runtime/Utility/InjectionHelper.cs index c39670f..fba8b87 100644 --- a/Runtime/Utility/InjectionHelper.cs +++ b/Runtime/Utility/InjectionHelper.cs @@ -26,16 +26,40 @@ public static bool TryGetDependencies(this Type type, out object[] objects, DICo Type parameterType = parameter.ParameterType; InjectAttribute injectAttribute = parameter.GetCustomAttribute(); - - object parameterObject = container.Resolve(parameterType, injectAttribute?.Id); - if (parameterObject == null) + + if (!parameterType.IsArray) { - Debug.LogError($"Can not resolve depenceny! Type: {type} --- DependencyType: {parameterType}"); - return false; + object parameterObject = container.Resolve(parameterType, injectAttribute?.Id); + if (parameterObject == null) + { + Debug.LogError($"Can not resolve depenceny! Type: {type} --- DependencyType: {parameterType}"); + return false; + } + + Array.Resize(ref objects, objects.Length + 1); + objects[^1] = parameterObject; } + else + { + Type elementType = parameterType.GetElementType(); + + object[] parameterObjects = container.ResolveAll(elementType, injectAttribute?.Id); + if (parameterObjects == null) + { + Debug.LogError($"Can not resolve depenceny! Type: {type} --- DependencyType: {elementType}"); + return false; + } - Array.Resize(ref objects, objects.Length + 1); - objects[^1] = parameterObject; + Array parameterArray = Array.CreateInstance(elementType, parameterObjects.Length); + + for (int index = 0; index < parameterObjects.Length; index++) + { + parameterArray.SetValue(parameterObjects[index], index); + } + + Array.Resize(ref objects, objects.Length + 1); + objects[^1] = parameterArray; + } } return true; diff --git a/Samples/Scenes/TarjectDemoScene.unity b/Samples/Scenes/TarjectDemoScene.unity index 4f5234a..941eefd 100644 --- a/Samples/Scenes/TarjectDemoScene.unity +++ b/Samples/Scenes/TarjectDemoScene.unity @@ -218,6 +218,7 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: - {fileID: 1627664611} + - {fileID: 205853188} m_Father: {fileID: 0} m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -226,6 +227,128 @@ RectTransform: m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0, y: 0} +--- !u!1 &70788082 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 70788083} + - component: {fileID: 70788086} + - component: {fileID: 70788085} + - component: {fileID: 70788084} + m_Layer: 5 + m_Name: LoadButton + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &70788083 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 70788082} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 1067038178} + m_Father: {fileID: 205853188} + m_RootOrder: -1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: -100} + m_SizeDelta: {x: 300, y: 75} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &70788084 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 70788082} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_WrapAround: 0 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 70788085} + m_OnClick: + m_PersistentCalls: + m_Calls: [] +--- !u!114 &70788085 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 70788082} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &70788086 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 70788082} + m_CullTransparentMesh: 1 --- !u!1 &171617526 GameObject: m_ObjectHideFlags: 0 @@ -294,6 +417,68 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &205853187 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 205853188} + - component: {fileID: 205853190} + - component: {fileID: 205853189} + m_Layer: 5 + m_Name: GameSaveDataPanel + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &205853188 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 205853187} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 1396488130} + - {fileID: 70788083} + m_Father: {fileID: 30659987} + m_RootOrder: -1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0.5} + m_AnchorMax: {x: 0, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 550, y: 1080} + m_Pivot: {x: 0, y: 0.5} +--- !u!114 &205853189 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 205853187} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 441ad85dffc0d2d46aa54cf235cd1dd6, type: 3} + m_Name: + m_EditorClassIdentifier: + _saveButton: {fileID: 1396488131} + _loadButton: {fileID: 70788084} +--- !u!222 &205853190 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 205853187} + m_CullTransparentMesh: 1 --- !u!1 &513493097 GameObject: m_ObjectHideFlags: 0 @@ -638,6 +823,86 @@ MonoBehaviour: m_Spacing: {x: 50, y: 50} m_Constraint: 0 m_ConstraintCount: 2 +--- !u!1 &1067038177 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1067038178} + - component: {fileID: 1067038180} + - component: {fileID: 1067038179} + m_Layer: 5 + m_Name: Text (Legacy) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1067038178 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1067038177} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 70788083} + m_RootOrder: -1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1067038179 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1067038177} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0, g: 0, b: 0, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 25 + m_FontStyle: 0 + m_BestFit: 1 + m_MinSize: 2 + m_MaxSize: 75 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Load +--- !u!222 &1067038180 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1067038177} + m_CullTransparentMesh: 1 --- !u!1 &1153543991 stripped GameObject: m_CorrespondingSourceObject: {fileID: 8284720718150885568, guid: 74854f95be164b346b912a17638c0561, type: 3} @@ -700,6 +965,128 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1396488129 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1396488130} + - component: {fileID: 1396488133} + - component: {fileID: 1396488132} + - component: {fileID: 1396488131} + m_Layer: 5 + m_Name: SaveButton + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1396488130 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1396488129} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 1927445145} + m_Father: {fileID: 205853188} + m_RootOrder: -1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 100} + m_SizeDelta: {x: 300, y: 75} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1396488131 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1396488129} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_WrapAround: 0 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 1396488132} + m_OnClick: + m_PersistentCalls: + m_Calls: [] +--- !u!114 &1396488132 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1396488129} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1396488133 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1396488129} + m_CullTransparentMesh: 1 --- !u!1 &1627664610 GameObject: m_ObjectHideFlags: 0 @@ -793,6 +1180,86 @@ MonoBehaviour: m_FillOrigin: 0 m_UseSpriteMesh: 0 m_PixelsPerUnitMultiplier: 1 +--- !u!1 &1927445144 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1927445145} + - component: {fileID: 1927445147} + - component: {fileID: 1927445146} + m_Layer: 5 + m_Name: Text (Legacy) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1927445145 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1927445144} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1396488130} + m_RootOrder: -1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1927445146 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1927445144} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0, g: 0, b: 0, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 25 + m_FontStyle: 0 + m_BestFit: 1 + m_MinSize: 2 + m_MaxSize: 75 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Save +--- !u!222 &1927445147 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1927445144} + m_CullTransparentMesh: 1 --- !u!1001 &1814933660727048575 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Samples/Scripts/Runtime/GameSaveDataModule.meta b/Samples/Scripts/Runtime/GameSaveDataModule.meta new file mode 100644 index 0000000..4402b51 --- /dev/null +++ b/Samples/Scripts/Runtime/GameSaveDataModule.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ecff4acd522024643aa7fea123bce44f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Samples/Scripts/Runtime/GameSaveDataModule/Controller.meta b/Samples/Scripts/Runtime/GameSaveDataModule/Controller.meta new file mode 100644 index 0000000..8e9ee8e --- /dev/null +++ b/Samples/Scripts/Runtime/GameSaveDataModule/Controller.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1bd031978adbd374081721159a32b1cb +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Samples/Scripts/Runtime/GameSaveDataModule/Controller/GameSaveDataController.cs b/Samples/Scripts/Runtime/GameSaveDataModule/Controller/GameSaveDataController.cs new file mode 100644 index 0000000..c44147d --- /dev/null +++ b/Samples/Scripts/Runtime/GameSaveDataModule/Controller/GameSaveDataController.cs @@ -0,0 +1,41 @@ +using Tarject.Runtime.Core.Injecter; +using Tarject.Runtime.SignalBus.Controller; +using Tarject.Samples.Scripts.Runtime.GameSaveDataModule.Service; +using Tarject.Samples.Scripts.Runtime.Signal; + +namespace Tarject.Samples.Scripts.Runtime.GameSaveDataModule.Controller +{ + public class GameSaveDataController + { + private readonly IGameSaveDataService[] _gameSaveDataServices; + + private readonly SignalController _signalController; + + [Inject] + public GameSaveDataController(IGameSaveDataService[] gameSaveDataServices, SignalController signalController) + { + _gameSaveDataServices = gameSaveDataServices; + _signalController = signalController; + } + + public void Save() + { + for (int index = 0; index < _gameSaveDataServices.Length; index++) + { + _gameSaveDataServices[index].Save(); + } + + _signalController.Fire(new GameDataSavedSignal(_gameSaveDataServices)); + } + + public void Load() + { + for (int index = 0; index < _gameSaveDataServices.Length; index++) + { + _gameSaveDataServices[index].Load(); + } + + _signalController.Fire(new GameDataLoadedSignal(_gameSaveDataServices)); + } + } +} diff --git a/Samples/Scripts/Runtime/GameSaveDataModule/Controller/GameSaveDataController.cs.meta b/Samples/Scripts/Runtime/GameSaveDataModule/Controller/GameSaveDataController.cs.meta new file mode 100644 index 0000000..ceb17c7 --- /dev/null +++ b/Samples/Scripts/Runtime/GameSaveDataModule/Controller/GameSaveDataController.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 33afece384193244aac5f143d696ccd7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Samples/Scripts/Runtime/GameSaveDataModule/Installer.meta b/Samples/Scripts/Runtime/GameSaveDataModule/Installer.meta new file mode 100644 index 0000000..6b59144 --- /dev/null +++ b/Samples/Scripts/Runtime/GameSaveDataModule/Installer.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0c205905d640ff1439222f570f3ac059 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Samples/Scripts/Runtime/GameSaveDataModule/Installer/GameSaveDataInstaller.cs b/Samples/Scripts/Runtime/GameSaveDataModule/Installer/GameSaveDataInstaller.cs new file mode 100644 index 0000000..7a0af16 --- /dev/null +++ b/Samples/Scripts/Runtime/GameSaveDataModule/Installer/GameSaveDataInstaller.cs @@ -0,0 +1,18 @@ +using Tarject.Runtime.Core.Context; +using Tarject.Runtime.Core.Installer; +using Tarject.Samples.Scripts.Runtime.GameSaveDataModule.Controller; +using Tarject.Samples.Scripts.Runtime.GameSaveDataModule.Service; + +namespace Tarject.Samples.Scripts.Runtime.GameSaveDataModule.Installer +{ + public class GameSaveDataInstaller : ObjectInstaller + { + public override void Install(DIContainer container) + { + container.Bind().ToInterface(); + container.Bind().ToInterface(); + + container.Bind(); + } + } +} diff --git a/Samples/Scripts/Runtime/GameSaveDataModule/Installer/GameSaveDataInstaller.cs.meta b/Samples/Scripts/Runtime/GameSaveDataModule/Installer/GameSaveDataInstaller.cs.meta new file mode 100644 index 0000000..740ab04 --- /dev/null +++ b/Samples/Scripts/Runtime/GameSaveDataModule/Installer/GameSaveDataInstaller.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fd689478da8657b4aba11b10e9c6a409 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Samples/Scripts/Runtime/GameSaveDataModule/Service.meta b/Samples/Scripts/Runtime/GameSaveDataModule/Service.meta new file mode 100644 index 0000000..17d489b --- /dev/null +++ b/Samples/Scripts/Runtime/GameSaveDataModule/Service.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e4e97c07821842241aa6f9efc3cbbf69 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Samples/Scripts/Runtime/GameSaveDataModule/Service/IGameSaveDataService.cs b/Samples/Scripts/Runtime/GameSaveDataModule/Service/IGameSaveDataService.cs new file mode 100644 index 0000000..f8491e0 --- /dev/null +++ b/Samples/Scripts/Runtime/GameSaveDataModule/Service/IGameSaveDataService.cs @@ -0,0 +1,9 @@ +namespace Tarject.Samples.Scripts.Runtime.GameSaveDataModule.Service +{ + public interface IGameSaveDataService + { + void Save(); + + void Load(); + } +} diff --git a/Samples/Scripts/Runtime/GameSaveDataModule/Service/IGameSaveDataService.cs.meta b/Samples/Scripts/Runtime/GameSaveDataModule/Service/IGameSaveDataService.cs.meta new file mode 100644 index 0000000..ded446b --- /dev/null +++ b/Samples/Scripts/Runtime/GameSaveDataModule/Service/IGameSaveDataService.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a4a11987571a1354fa52285529e2b7fe +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Samples/Scripts/Runtime/GameSaveDataModule/Service/LocalGameSaveDataService.cs b/Samples/Scripts/Runtime/GameSaveDataModule/Service/LocalGameSaveDataService.cs new file mode 100644 index 0000000..917b9cc --- /dev/null +++ b/Samples/Scripts/Runtime/GameSaveDataModule/Service/LocalGameSaveDataService.cs @@ -0,0 +1,17 @@ +using UnityEngine; + +namespace Tarject.Samples.Scripts.Runtime.GameSaveDataModule.Service +{ + public class LocalGameSaveDataService : IGameSaveDataService + { + public void Load() + { + Debug.Log($"[PROOF] - LocalGameSaveDataService --> Called LocalGameSaveData Load func"); + } + + public void Save() + { + Debug.Log($"[PROOF] - LocalGameSaveDataService --> Called LocalGameSaveData Save func"); + } + } +} diff --git a/Samples/Scripts/Runtime/GameSaveDataModule/Service/LocalGameSaveDataService.cs.meta b/Samples/Scripts/Runtime/GameSaveDataModule/Service/LocalGameSaveDataService.cs.meta new file mode 100644 index 0000000..c038ed1 --- /dev/null +++ b/Samples/Scripts/Runtime/GameSaveDataModule/Service/LocalGameSaveDataService.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: dacdcc0440752b749bf736d5f81abf57 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Samples/Scripts/Runtime/GameSaveDataModule/Service/RemoteGameSaveDataService.cs b/Samples/Scripts/Runtime/GameSaveDataModule/Service/RemoteGameSaveDataService.cs new file mode 100644 index 0000000..4856159 --- /dev/null +++ b/Samples/Scripts/Runtime/GameSaveDataModule/Service/RemoteGameSaveDataService.cs @@ -0,0 +1,17 @@ +using UnityEngine; + +namespace Tarject.Samples.Scripts.Runtime.GameSaveDataModule.Service +{ + public class RemoteGameSaveDataService : IGameSaveDataService + { + public void Load() + { + Debug.Log($"[PROOF] - RemoteGameSaveDataService --> Called RemoteGameSaveDataService Load func"); + } + + public void Save() + { + Debug.Log($"[PROOF] - RemoteGameSaveDataService --> Called RemoteGameSaveDataService Save func"); + } + } +} diff --git a/Samples/Scripts/Runtime/GameSaveDataModule/Service/RemoteGameSaveDataService.cs.meta b/Samples/Scripts/Runtime/GameSaveDataModule/Service/RemoteGameSaveDataService.cs.meta new file mode 100644 index 0000000..f7619ae --- /dev/null +++ b/Samples/Scripts/Runtime/GameSaveDataModule/Service/RemoteGameSaveDataService.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7af755b2b3d1aae409ce8b67eac58b12 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Samples/Scripts/Runtime/GameSaveDataModule/View.meta b/Samples/Scripts/Runtime/GameSaveDataModule/View.meta new file mode 100644 index 0000000..3baefd5 --- /dev/null +++ b/Samples/Scripts/Runtime/GameSaveDataModule/View.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f5860238e4da40d449ca34e9422f5947 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Samples/Scripts/Runtime/GameSaveDataModule/View/GameSaveDataPanel.cs b/Samples/Scripts/Runtime/GameSaveDataModule/View/GameSaveDataPanel.cs new file mode 100644 index 0000000..624dd4e --- /dev/null +++ b/Samples/Scripts/Runtime/GameSaveDataModule/View/GameSaveDataPanel.cs @@ -0,0 +1,52 @@ +using Tarject.Runtime.Core.Injecter; +using Tarject.Samples.Scripts.Runtime.GameSaveDataModule.Controller; +using UnityEngine; +using UnityEngine.UI; + +namespace Tarject.Samples.Scripts.Runtime.GameSaveDataModule.View +{ + public class GameSaveDataPanel : MonoInjecter + { + [Inject] + private readonly GameSaveDataController _gameSaveDataController; + + [SerializeField] + private Button _saveButton; + [SerializeField] + private Button _loadButton; + + protected override void Awake() + { + base.Awake(); + + SubscribeEvents(); + } + + private void SubscribeEvents() + { + _saveButton.onClick.AddListener(OnSaveButtonClicked); + _loadButton.onClick.AddListener(OnLoadButtonClicked); + } + + private void OnSaveButtonClicked() + { + _gameSaveDataController.Save(); + } + + private void OnLoadButtonClicked() + { + _gameSaveDataController.Load(); + } + + private void UnsubscribeEvents() + { + _saveButton.onClick.RemoveListener(OnSaveButtonClicked); + _loadButton.onClick.RemoveListener(OnLoadButtonClicked); + } + + private void OnDestroy() + { + UnsubscribeEvents(); + } + } +} \ No newline at end of file diff --git a/Samples/Scripts/Runtime/GameSaveDataModule/View/GameSaveDataPanel.cs.meta b/Samples/Scripts/Runtime/GameSaveDataModule/View/GameSaveDataPanel.cs.meta new file mode 100644 index 0000000..47d9cf5 --- /dev/null +++ b/Samples/Scripts/Runtime/GameSaveDataModule/View/GameSaveDataPanel.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 441ad85dffc0d2d46aa54cf235cd1dd6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Samples/Scripts/Runtime/Installers/AppInstaller.cs b/Samples/Scripts/Runtime/Installers/AppInstaller.cs index c4bcae0..345d0d2 100644 --- a/Samples/Scripts/Runtime/Installers/AppInstaller.cs +++ b/Samples/Scripts/Runtime/Installers/AppInstaller.cs @@ -3,6 +3,7 @@ using Tarject.Runtime.Core.Context; using Tarject.Runtime.Core.Installer; using Tarject.Runtime.SignalBus.Controller; +using Tarject.Samples.Scripts.Runtime.GameSaveDataModule.Installer; namespace Tarject.Samples.Scripts.Runtime.Installers { @@ -15,6 +16,8 @@ public override void Install(DIContainer container) UserInstaller.CreateAndInstall(container); ConfigurationModuleInstaller.CreateAndInstall(container); + + GameSaveDataInstaller.CreateAndInstall(container); } } } \ No newline at end of file diff --git a/Samples/Scripts/Runtime/InventoryModule/UI.meta b/Samples/Scripts/Runtime/InventoryModule/View.meta similarity index 100% rename from Samples/Scripts/Runtime/InventoryModule/UI.meta rename to Samples/Scripts/Runtime/InventoryModule/View.meta diff --git a/Samples/Scripts/Runtime/InventoryModule/UI/InventoryPanel.cs b/Samples/Scripts/Runtime/InventoryModule/View/InventoryPanel.cs similarity index 96% rename from Samples/Scripts/Runtime/InventoryModule/UI/InventoryPanel.cs rename to Samples/Scripts/Runtime/InventoryModule/View/InventoryPanel.cs index ccaa2cf..2d317f3 100644 --- a/Samples/Scripts/Runtime/InventoryModule/UI/InventoryPanel.cs +++ b/Samples/Scripts/Runtime/InventoryModule/View/InventoryPanel.cs @@ -5,7 +5,7 @@ using Tarject.Runtime.SignalBus.Controller; using UnityEngine; -namespace Tarject.Samples.Scripts.Runtime.InventoryModule.UI +namespace Tarject.Samples.Scripts.Runtime.InventoryModule.View { public class InventoryPanel : MonoInjecter { diff --git a/Samples/Scripts/Runtime/InventoryModule/UI/InventoryPanel.cs.meta b/Samples/Scripts/Runtime/InventoryModule/View/InventoryPanel.cs.meta similarity index 100% rename from Samples/Scripts/Runtime/InventoryModule/UI/InventoryPanel.cs.meta rename to Samples/Scripts/Runtime/InventoryModule/View/InventoryPanel.cs.meta diff --git a/Samples/Scripts/Runtime/InventoryModule/UI/InventoryUIItem.cs b/Samples/Scripts/Runtime/InventoryModule/View/InventoryUIItem.cs similarity index 92% rename from Samples/Scripts/Runtime/InventoryModule/UI/InventoryUIItem.cs rename to Samples/Scripts/Runtime/InventoryModule/View/InventoryUIItem.cs index 710c4e6..40d82c5 100644 --- a/Samples/Scripts/Runtime/InventoryModule/UI/InventoryUIItem.cs +++ b/Samples/Scripts/Runtime/InventoryModule/View/InventoryUIItem.cs @@ -3,7 +3,7 @@ using UnityEngine; using UnityEngine.UI; -namespace Tarject.Samples.Scripts.Runtime.InventoryModule.UI +namespace Tarject.Samples.Scripts.Runtime.InventoryModule.View { public class InventoryUIItem : MonoBehaviour, IFactorable { diff --git a/Samples/Scripts/Runtime/InventoryModule/UI/InventoryUIItem.cs.meta b/Samples/Scripts/Runtime/InventoryModule/View/InventoryUIItem.cs.meta similarity index 100% rename from Samples/Scripts/Runtime/InventoryModule/UI/InventoryUIItem.cs.meta rename to Samples/Scripts/Runtime/InventoryModule/View/InventoryUIItem.cs.meta diff --git a/Samples/Scripts/Runtime/Signal/GameDataLoadedSignal.cs b/Samples/Scripts/Runtime/Signal/GameDataLoadedSignal.cs new file mode 100644 index 0000000..35ed1af --- /dev/null +++ b/Samples/Scripts/Runtime/Signal/GameDataLoadedSignal.cs @@ -0,0 +1,14 @@ +using Tarject.Samples.Scripts.Runtime.GameSaveDataModule.Service; + +namespace Tarject.Samples.Scripts.Runtime.Signal +{ + public readonly struct GameDataLoadedSignal + { + public readonly IGameSaveDataService[] GameSaveDataServices; + + public GameDataLoadedSignal(IGameSaveDataService[] gameSaveDataServices) + { + GameSaveDataServices = gameSaveDataServices; + } + } +} diff --git a/Samples/Scripts/Runtime/Signal/GameDataLoadedSignal.cs.meta b/Samples/Scripts/Runtime/Signal/GameDataLoadedSignal.cs.meta new file mode 100644 index 0000000..a48e8e5 --- /dev/null +++ b/Samples/Scripts/Runtime/Signal/GameDataLoadedSignal.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6cf17a7f4de25fe4990c957ca5a4acd0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Samples/Scripts/Runtime/Signal/GameDataSavedSignal.cs b/Samples/Scripts/Runtime/Signal/GameDataSavedSignal.cs new file mode 100644 index 0000000..57f61e0 --- /dev/null +++ b/Samples/Scripts/Runtime/Signal/GameDataSavedSignal.cs @@ -0,0 +1,14 @@ +using Tarject.Samples.Scripts.Runtime.GameSaveDataModule.Service; + +namespace Tarject.Samples.Scripts.Runtime.Signal +{ + public readonly struct GameDataSavedSignal + { + public readonly IGameSaveDataService[] GameSaveDataServices; + + public GameDataSavedSignal(IGameSaveDataService[] gameSaveDataServices) + { + GameSaveDataServices = gameSaveDataServices; + } + } +} diff --git a/Samples/Scripts/Runtime/Signal/GameDataSavedSignal.cs.meta b/Samples/Scripts/Runtime/Signal/GameDataSavedSignal.cs.meta new file mode 100644 index 0000000..136a698 --- /dev/null +++ b/Samples/Scripts/Runtime/Signal/GameDataSavedSignal.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 145cf22293303234cba96b2b3f590ffe +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Samples/Scripts/Tests/GameSaveDataModule.meta b/Samples/Scripts/Tests/GameSaveDataModule.meta new file mode 100644 index 0000000..b3597a3 --- /dev/null +++ b/Samples/Scripts/Tests/GameSaveDataModule.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f4d2dbd619eadb44dbbbcaca6d9d85d7 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Samples/Scripts/Tests/GameSaveDataModule/GameSaveDataControllerTest.cs b/Samples/Scripts/Tests/GameSaveDataModule/GameSaveDataControllerTest.cs new file mode 100644 index 0000000..a971abf --- /dev/null +++ b/Samples/Scripts/Tests/GameSaveDataModule/GameSaveDataControllerTest.cs @@ -0,0 +1,56 @@ +using NUnit.Framework; +using Tarject.Editor.TestFramework.UnitTest; +using Tarject.Runtime.SignalBus.Controller; +using Tarject.Samples.Scripts.Runtime.GameSaveDataModule.Controller; +using Tarject.Samples.Scripts.Runtime.GameSaveDataModule.Service; +using Tarject.Samples.Scripts.Runtime.Signal; + +namespace Tarject.Samples.Scripts.Tests.GameSaveDataModule +{ + internal class GameSaveDataControllerTest : TarjectUnitTestFixture + { + protected override void Setup() + { + Container.Bind(); + Container.Bind().ToInterface(); + Container.Bind().ToInterface(); + Container.Bind(); + } + + [Test] + public void SaveData() + { + SignalController signalController = Container.Resolve(); + GameSaveDataController gameSaveDataController = Container.Resolve(); + + signalController.Subscribe(Action); + + gameSaveDataController.Save(); + void Action(GameDataSavedSignal signal) + { + Assert.IsNotNull(signal); + Assert.IsTrue(signal.GameSaveDataServices.Length > 0); + } + + Assert.IsNotNull(gameSaveDataController); + } + + [Test] + public void LoadData() + { + SignalController signalController = Container.Resolve(); + GameSaveDataController gameSaveDataController = Container.Resolve(); + + signalController.Subscribe(Action); + + gameSaveDataController.Load(); + void Action(GameDataLoadedSignal signal) + { + Assert.IsNotNull(signal); + Assert.IsTrue(signal.GameSaveDataServices.Length > 0); + } + + Assert.IsNotNull(gameSaveDataController); + } + } +} diff --git a/Samples/Scripts/Tests/GameSaveDataModule/GameSaveDataControllerTest.cs.meta b/Samples/Scripts/Tests/GameSaveDataModule/GameSaveDataControllerTest.cs.meta new file mode 100644 index 0000000..88fb2cf --- /dev/null +++ b/Samples/Scripts/Tests/GameSaveDataModule/GameSaveDataControllerTest.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b8ae1a8f2e861f24aa4b60d5510b6312 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Samples/Scripts/Tests/InventoryModule/InventoryControllerTest.cs b/Samples/Scripts/Tests/InventoryModule/InventoryControllerTest.cs index 6a9d046..141f576 100644 --- a/Samples/Scripts/Tests/InventoryModule/InventoryControllerTest.cs +++ b/Samples/Scripts/Tests/InventoryModule/InventoryControllerTest.cs @@ -8,7 +8,6 @@ namespace Tarject.Samples.Scripts.Tests.InventoryModule { - [TestFixture] public class InventoryControllerTest : TarjectUnitTestFixture { protected override void Setup() diff --git a/Tests/Editor/Core/ContainerTest.cs b/Tests/Editor/Core/ContainerTest.cs index cb50b03..ea75650 100644 --- a/Tests/Editor/Core/ContainerTest.cs +++ b/Tests/Editor/Core/ContainerTest.cs @@ -14,7 +14,10 @@ protected override void Setup() Container.Bind().WithId("testId"); - Container.Bind().ToInterface(); + Container.Bind().ToInterface(); + Container.Bind().ToInterface(); + + Container.Bind(); } [Test] @@ -49,6 +52,15 @@ public void Resolve_Bind_ToInterface() Assert.IsNotNull(bindToInterfaceTestInterface); } + [Test] + public void Resolve_All_Bind_ToInterface() + { + BindToInterfaceConcreteClass bindToInterfaceConcreteClass = Container.Resolve(); + + Assert.IsNotNull(bindToInterfaceConcreteClass); + Assert.IsTrue(bindToInterfaceConcreteClass.GetInterfaceLength == 2); + } + private class BindTestClass { } @@ -57,7 +69,11 @@ private class BindWithIdTestClass { } - private class BindToInterfaceTestClass : IBindToInterfaceTestInterface + private class BindToInterfaceTestFirstClass : IBindToInterfaceTestInterface + { + } + + private class BindToInterfaceTestSecondClass : IBindToInterfaceTestInterface { } @@ -65,6 +81,18 @@ private interface IBindToInterfaceTestInterface { } + private class BindToInterfaceConcreteClass + { + private readonly IBindToInterfaceTestInterface[] _interfaces; + + public BindToInterfaceConcreteClass(IBindToInterfaceTestInterface[] interfaces) + { + _interfaces = interfaces; + } + + public int GetInterfaceLength => _interfaces.Length; + } + private class BindFromInstanceTestClass { public readonly string Name; diff --git a/package.json b/package.json index eee0a1d..efeb1e5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.tariksavas.tarject", - "version": "1.0.2", + "version": "1.0.3", "displayName": "Tarject", "description": "This is a Dependency Injection Framework for Unity", "unity": "2019.1",