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 3d3c8fe

Browse files
Refactoring.
1 parent e3dbe6c commit 3d3c8fe

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ public virtual void Dispose()
4949
return;
5050
}
5151

52-
for (var i=0;i<_bindableElements.Count;i++)
52+
foreach (var bindableElementin_bindableElements)
5353
{
54-
if (_bindableElements[i] is IDisposable disposable)
54+
if (bindableElement is IDisposable disposable)
5555
{
5656
disposable.Dispose();
5757
}
@@ -85,7 +85,7 @@ public virtual void ResetBindingContext(IObjectProvider objectProvider)
8585
protected virtual void OnSetBindingContext(IBindingContext context, IObjectProvider objectProvider,
8686
PropertyBindingData propertyBindingData)
8787
{
88-
_bindingContextProperty = RentReadOnlyProperty(context, objectProvider, propertyBindingData);
88+
_bindingContextProperty = RentBindingContextProperty(context, objectProvider, propertyBindingData);
8989
_bindingContextProperty.ValueChanged += OnBindingContextPropertyValueChanged;
9090

9191
if (_bindingContextProperty.Value is null)
@@ -103,18 +103,19 @@ protected virtual void OnResetBindingContext(IObjectProvider objectProvider)
103103

104104
objectProvider.ReturnReadOnlyProperty(_bindingContextProperty);
105105

106-
_bindingContextProperty = null;
107-
108106
BindingContext = default;
109107
ResetChildsBindingContext(objectProvider);
108+
109+
_objectProvider = default;
110+
_bindingContextProperty = default;
110111
}
111112

112113
private void OnBindingContextPropertyValueChanged(object sender, TBindingContext bindingContext)
113114
{
114115
SetChildsBindingContext(bindingContext, _objectProvider);
115116
}
116117

117-
protected virtual IReadOnlyProperty<TBindingContext> RentReadOnlyProperty(IBindingContext context,
118+
protected virtual IReadOnlyProperty<TBindingContext> RentBindingContextProperty(IBindingContext context,
118119
IObjectProvider objectProvider, PropertyBindingData propertyBindingData)
119120
{
120121
return objectProvider.RentReadOnlyProperty<TBindingContext>(context, propertyBindingData);
@@ -123,18 +124,18 @@ protected virtual IReadOnlyProperty<TBindingContext> RentReadOnlyProperty(IBindi
123124
[MethodImpl(MethodImplOptions.AggressiveInlining)]
124125
private void SetChildsBindingContext(IBindingContext bindingContext, IObjectProvider objectProvider)
125126
{
126-
for (var i=0;i<_bindableElements.Count;i++)
127+
foreach (var bindableElementin_bindableElements)
127128
{
128-
_bindableElements[i].SetBindingContext(bindingContext, objectProvider);
129+
bindableElement.SetBindingContext(bindingContext, objectProvider);
129130
}
130131
}
131132

132133
[MethodImpl(MethodImplOptions.AggressiveInlining)]
133134
private void ResetChildsBindingContext(IObjectProvider objectProvider)
134135
{
135-
for (var i=0;i<_bindableElements.Count;i++)
136+
foreach (var bindableElementin_bindableElements)
136137
{
137-
_bindableElements[i].ResetBindingContext(objectProvider);
138+
bindableElement.ResetBindingContext(objectProvider);
138139
}
139140
}
140141
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace UnityMvvmToolkit.UITK.BindableUIElements
55
{
66
public partial class BindingContextProvider : BindingContextProvider<IBindingContext>
77
{
8-
protected override IReadOnlyProperty<IBindingContext> RentReadOnlyProperty(IBindingContext context,
8+
protected override IReadOnlyProperty<IBindingContext> RentBindingContextProperty(IBindingContext context,
99
IObjectProvider objectProvider, PropertyBindingData propertyBindingData)
1010
{
1111
return objectProvider.RentReadOnlyPropertyAs<IBindingContext>(context, propertyBindingData);

0 commit comments

Comments
(0)

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