11using System ;
22using System . Collections . Generic ;
33using System . IO ;
4+ using System . Linq ;
45using System . Xml . Serialization ;
56
6- using NuciXNA . DataAccess . Repositories ;
7+ using NuciDAL . Repositories ;
78
89using SokoGrump . DataAccess . DataObjects ;
910using SokoGrump . Settings ;
@@ -17,6 +18,8 @@ public class BoardRepository : IRepository<string, BoardEntity>
1718 {
1819 readonly string boardsDirectory ;
1920
21+ public int EntitiesCount => GetAll ( ) . Count ( ) ;
22+
2023 /// <summary>
2124 /// Initializes a new instance of the <see cref="BoardRepository"/> class.
2225 /// </summary>
@@ -36,6 +39,10 @@ public void Add(BoardEntity boardEntity)
3639 throw new NotImplementedException ( ) ;
3740 }
3841
42+ public void TryAdd ( BoardEntity boardEntity ) { }
43+
44+ public bool ContainsId ( string id ) => TryGet ( id ) is not null ;
45+
3946 /// <summary>
4047 /// Get the board with the specified identifier.
4148 /// </summary>
@@ -90,6 +97,18 @@ public BoardEntity Get(string id)
9097 return boardEntity ;
9198 }
9299
100+ public BoardEntity TryGet ( string id )
101+ {
102+ try
103+ {
104+ return Get ( id ) ;
105+ }
106+ catch
107+ {
108+ return null ;
109+ }
110+ }
111+
93112 /// <summary>
94113 /// Gets all the boards.
95114 /// </summary>
@@ -127,6 +146,15 @@ public void Update(BoardEntity boardEntity)
127146 // TODO: Save the ProvinceMap and TerrainMap as well
128147 }
129148
149+ public void TryUpdate ( BoardEntity boardEntity )
150+ {
151+ try
152+ {
153+ Update ( boardEntity ) ;
154+ }
155+ catch { }
156+ }
157+
130158 /// <summary>
131159 /// Removes the board with the specified identifier.
132160 /// </summary>
@@ -136,6 +164,15 @@ public void Remove(string id)
136164 Directory . Delete ( Path . Combine ( boardsDirectory , id ) ) ;
137165 }
138166
167+ public void TryRemove ( string id )
168+ {
169+ try
170+ {
171+ Remove ( id ) ;
172+ }
173+ catch { }
174+ }
175+
139176 /// <summary>
140177 /// Removes the specified board.
141178 /// </summary>
@@ -145,6 +182,17 @@ public void Remove(BoardEntity boardEntity)
145182 Remove ( boardEntity . Id ) ;
146183 }
147184
185+ public void TryRemove ( BoardEntity boardEntity )
186+ {
187+ try
188+ {
189+ Remove ( boardEntity ) ;
190+ }
191+ catch { }
192+ }
193+
194+ public void ApplyChanges ( ) { }
195+
148196 Dictionary < int , TileEntity > GetTileEntities ( )
149197 {
150198 Dictionary < int , TileEntity > tiles = new Dictionary < int , TileEntity > ( ) ;
0 commit comments