Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 72d43ee

Browse files
Resolve #48. Add common BindingContextProvider.
1 parent 40e7c5b commit 72d43ee

File tree

5 files changed

+55
-7
lines changed

5 files changed

+55
-7
lines changed

‎src/UnityMvvmToolkit.UnityPackage/Assets/Plugins/UnityMvvmToolkit/Runtime/UITK/BindableUIElements/BindingContextProvider.T.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,10 @@ public virtual void ResetBindingContext(IObjectProvider objectProvider)
8282
}
8383
}
8484

85-
private void OnBindingContextPropertyValueChanged(object sender, TBindingContext bindingContext)
86-
{
87-
SetChildsBindingContext(bindingContext, _objectProvider);
88-
}
89-
9085
protected virtual void OnSetBindingContext(IBindingContext context, IObjectProvider objectProvider,
9186
PropertyBindingData propertyBindingData)
9287
{
93-
_bindingContextProperty =
94-
objectProvider.RentReadOnlyProperty<TBindingContext>(context, propertyBindingData);
88+
_bindingContextProperty = RentReadOnlyProperty(context, objectProvider, propertyBindingData);
9589
_bindingContextProperty.ValueChanged += OnBindingContextPropertyValueChanged;
9690

9791
if (_bindingContextProperty.Value is null)
@@ -115,6 +109,17 @@ protected virtual void OnResetBindingContext(IObjectProvider objectProvider)
115109
ResetChildsBindingContext(objectProvider);
116110
}
117111

112+
private void OnBindingContextPropertyValueChanged(object sender, TBindingContext bindingContext)
113+
{
114+
SetChildsBindingContext(bindingContext, _objectProvider);
115+
}
116+
117+
protected virtual IReadOnlyProperty<TBindingContext> RentReadOnlyProperty(IBindingContext context,
118+
IObjectProvider objectProvider, PropertyBindingData propertyBindingData)
119+
{
120+
return objectProvider.RentReadOnlyProperty<TBindingContext>(context, propertyBindingData);
121+
}
122+
118123
[MethodImpl(MethodImplOptions.AggressiveInlining)]
119124
private void SetChildsBindingContext(IBindingContext bindingContext, IObjectProvider objectProvider)
120125
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using UnityMvvmToolkit.Core;
2+
using UnityMvvmToolkit.Core.Interfaces;
3+
4+
namespace UnityMvvmToolkit.UITK.BindableUIElements
5+
{
6+
public partial class BindingContextProvider : BindingContextProvider<IBindingContext>
7+
{
8+
protected override IReadOnlyProperty<IBindingContext> RentReadOnlyProperty(IBindingContext context,
9+
IObjectProvider objectProvider, PropertyBindingData propertyBindingData)
10+
{
11+
return objectProvider.RentReadOnlyPropertyAs<IBindingContext>(context, propertyBindingData);
12+
}
13+
}
14+
}

‎src/UnityMvvmToolkit.UnityPackage/Assets/Plugins/UnityMvvmToolkit/Runtime/UITK/BindableUIElements/BindingContextProvider.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using UnityEngine.UIElements;
2+
using UnityMvvmToolkit.Core.Interfaces;
3+
4+
namespace UnityMvvmToolkit.UITK.BindableUIElements
5+
{
6+
partial class BindingContextProvider
7+
{
8+
public new class UxmlFactory : UxmlFactory<BindingContextProvider, UxmlTraits>
9+
{
10+
}
11+
12+
#if UNITY_2023_2_OR_NEWER
13+
[System.Serializable]
14+
public new class UxmlSerializedData : BindingContextProvider<IBindingContext>.UxmlSerializedData
15+
{
16+
}
17+
#else
18+
public new class UxmlTraits : BindingContextProvider<IBindingContext>.UxmlTraits
19+
{
20+
}
21+
#endif
22+
}
23+
}

‎src/UnityMvvmToolkit.UnityPackage/Assets/Plugins/UnityMvvmToolkit/Runtime/UITK/BindableUIElements/Uxmls/BindingContextProvider.Uxml.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /