Skip to content

Commit b961d82

Browse files
author
TimGameDev
committed
Goal: support standard ObservableCollection instead of custom ObservableList to avoid tight coupling with UnityWeld.
Discussion: Real-Serious-Games#36 Done: - Remove support of .net3.5 (it's deprecated in Unity since 2018 version) - Remove custom ObservableList, INotifyCollectionChanged, NotifyCollectionChangedEventArgs - Replace refs to ObservableList with ObservableCollection
1 parent 781a4fd commit b961d82

9 files changed

+12
-397
lines changed

Unity-Weld.nuspec

-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
<tags>C# Unity Unity3D UI MVVM data binding databinding</tags>
1717
</metadata>
1818
<files>
19-
<file src="UnityWeld/bin/Release/net35/UnityWeld.dll" target="lib\net35"/>
20-
<file src="UnityWeld_Editor/bin/Release/net35/UnityWeld_Editor.dll" target="lib\net35"/>
2119
<file src="UnityWeld/bin/Release/netstandard2.0/UnityWeld.dll" target="lib\netstandard2.0"/>
2220
<file src="UnityWeld_Editor/bin/Release/netstandard2.0/UnityWeld_Editor.dll" target="lib\netstandard2.0"/>
2321
</files>

UnityWeld/Binding/BoundObservableList.cs

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
3+
using System.Collections.ObjectModel;
4+
using System.Collections.Specialized;
35
using System.Linq;
46

57

@@ -8,12 +10,12 @@ namespace UnityWeld.Binding
810
/// <summary>
911
/// An observable list that is bound to source list.
1012
/// </summary>
11-
public class BoundObservableList<DestT, SourceT> : ObservableList<DestT>, IDisposable
13+
public class BoundObservableList<DestT, SourceT> : ObservableCollection<DestT>, IDisposable
1214
{
1315
/// <summary>
1416
/// The source list.
1517
/// </summary>
16-
private readonly ObservableList<SourceT> source;
18+
private readonly ObservableCollection<SourceT> source;
1719

1820
/// <summary>
1921
/// Function that maps source items to dest items.
@@ -43,7 +45,7 @@ public class BoundObservableList<DestT, SourceT> : ObservableList<DestT>, IDispo
4345

4446
private bool disposed;
4547

46-
public BoundObservableList(ObservableList<SourceT> source, Func<SourceT, DestT> itemMap) :
48+
public BoundObservableList(ObservableCollection<SourceT> source, Func<SourceT, DestT> itemMap) :
4749
base(source.Select(itemMap))
4850
{
4951
this.itemMap = itemMap;
@@ -55,7 +57,7 @@ public BoundObservableList(ObservableList<SourceT> source, Func<SourceT, DestT>
5557
cache = new List<DestT>(this);
5658
}
5759

58-
public BoundObservableList(ObservableList<SourceT> source, Func<SourceT, DestT> itemMap, Action<DestT> added, Action<DestT> removed) :
60+
public BoundObservableList(ObservableCollection<SourceT> source, Func<SourceT, DestT> itemMap, Action<DestT> added, Action<DestT> removed) :
5961
base(source.Select(itemMap))
6062
{
6163
if (added == null)
@@ -82,7 +84,7 @@ public BoundObservableList(ObservableList<SourceT> source, Func<SourceT, DestT>
8284
cache = new List<DestT>(this);
8385
}
8486

85-
public BoundObservableList(ObservableList<SourceT> source, Func<SourceT, DestT> itemMap, Action<DestT> added, Action<DestT> removed, Action changed) :
87+
public BoundObservableList(ObservableCollection<SourceT> source, Func<SourceT, DestT> itemMap, Action<DestT> added, Action<DestT> removed, Action changed) :
8688
base(source.Select(itemMap))
8789
{
8890
if (added == null)

UnityWeld/Binding/CollectionBinding.cs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections;
3+
using System.Collections.Specialized;
34
using System.Linq;
45
using UnityEngine;
56
using UnityWeld.Binding.Exceptions;

UnityWeld/Binding/INotifyCollectionChanged.cs

-15
This file was deleted.

UnityWeld/Binding/ITypedList.cs

-17
This file was deleted.

UnityWeld/Binding/NotifyCollectionChangedEventArgs.cs

-93
This file was deleted.

0 commit comments

Comments
 (0)