@@ -21,18 +21,21 @@ public sealed partial class ModelSaveContext : IDisposable
21
21
/// When in repository mode, this is the repository we're writing to. It is null when
22
22
/// in single-stream mode.
23
23
/// </summary>
24
- public readonly RepositoryWriter Repository ;
24
+ [ BestFriend ]
25
+ internal readonly RepositoryWriter Repository ;
25
26
26
27
/// <summary>
27
28
/// When in repository mode, this is the directory we're reading from. Null means the root
28
29
/// of the repository. It is always null in single-stream mode.
29
30
/// </summary>
30
- public readonly string Directory ;
31
+ [ BestFriend ]
32
+ internal readonly string Directory ;
31
33
32
34
/// <summary>
33
35
/// The main stream writer.
34
36
/// </summary>
35
- public readonly BinaryWriter Writer ;
37
+ [ BestFriend ]
38
+ internal readonly BinaryWriter Writer ;
36
39
37
40
/// <summary>
38
41
/// The strings that will be saved in the main stream's string table.
@@ -49,7 +52,8 @@ public sealed partial class ModelSaveContext : IDisposable
49
52
/// <summary>
50
53
/// The min file position of the main stream.
51
54
/// </summary>
52
- public readonly long FpMin ;
55
+ [ BestFriend ]
56
+ internal readonly long FpMin ;
53
57
54
58
/// <summary>
55
59
/// The wrapped entry.
@@ -69,7 +73,8 @@ public sealed partial class ModelSaveContext : IDisposable
69
73
/// <summary>
70
74
/// Returns whether this context is in repository mode (true) or single-stream mode (false).
71
75
/// </summary>
72
- public bool InRepository { get { return Repository != null ; } }
76
+ [ BestFriend ]
77
+ internal bool InRepository => Repository != null ;
73
78
74
79
/// <summary>
75
80
/// Create a <see cref="ModelSaveContext"/> supporting saving to a repository, for implementors of <see cref="ICanSaveModel"/>.
@@ -125,7 +130,8 @@ internal ModelSaveContext(BinaryWriter writer, IExceptionContext ectx = null)
125
130
ModelHeader . BeginWrite ( Writer , out FpMin , out Header ) ;
126
131
}
127
132
128
- public void CheckAtModel ( )
133
+ [ BestFriend ]
134
+ internal void CheckAtModel ( )
129
135
{
130
136
_ectx . Check ( Writer . BaseStream . Position == FpMin + Header . FpModel ) ;
131
137
}
@@ -135,13 +141,15 @@ public void CheckAtModel()
135
141
/// <see cref="Done"/> is called.
136
142
/// </summary>
137
143
/// <param name="ver"></param>
138
- public void SetVersionInfo ( VersionInfo ver )
144
+ [ BestFriend ]
145
+ internal void SetVersionInfo ( VersionInfo ver )
139
146
{
140
147
ModelHeader . SetVersionInfo ( ref Header , ver ) ;
141
148
_loaderAssemblyName = ver . LoaderAssemblyName ;
142
149
}
143
150
144
- public void SaveTextStream ( string name , Action < TextWriter > action )
151
+ [ BestFriend ]
152
+ internal void SaveTextStream ( string name , Action < TextWriter > action )
145
153
{
146
154
_ectx . Check ( InRepository , "Can't save a text stream when writing to a single stream" ) ;
147
155
_ectx . CheckNonEmpty ( name , nameof ( name ) ) ;
@@ -156,7 +164,8 @@ public void SaveTextStream(string name, Action<TextWriter> action)
156
164
}
157
165
}
158
166
159
- public void SaveBinaryStream ( string name , Action < BinaryWriter > action )
167
+ [ BestFriend ]
168
+ internal void SaveBinaryStream ( string name , Action < BinaryWriter > action )
160
169
{
161
170
_ectx . Check ( InRepository , "Can't save a text stream when writing to a single stream" ) ;
162
171
_ectx . CheckNonEmpty ( name , nameof ( name ) ) ;
@@ -175,7 +184,8 @@ public void SaveBinaryStream(string name, Action<BinaryWriter> action)
175
184
/// Puts a string into the context pool, and writes the integer code of the string ID
176
185
/// to the write stream. If str is null, this writes -1 and doesn't add it to the pool.
177
186
/// </summary>
178
- public void SaveStringOrNull ( string str )
187
+ [ BestFriend ]
188
+ internal void SaveStringOrNull ( string str )
179
189
{
180
190
if ( str == null )
181
191
Writer . Write ( - 1 ) ;
@@ -187,13 +197,15 @@ public void SaveStringOrNull(string str)
187
197
/// Puts a string into the context pool, and writes the integer code of the string ID
188
198
/// to the write stream. Checks that str is not null.
189
199
/// </summary>
190
- public void SaveString ( string str )
200
+ [ BestFriend ]
201
+ internal void SaveString ( string str )
191
202
{
192
203
_ectx . CheckValue ( str , nameof ( str ) ) ;
193
204
Writer . Write ( Strings . Add ( str ) . Id ) ;
194
205
}
195
206
196
- public void SaveString ( ReadOnlyMemory < char > str )
207
+ [ BestFriend ]
208
+ internal void SaveString ( ReadOnlyMemory < char > str )
197
209
{
198
210
Writer . Write ( Strings . Add ( str ) . Id ) ;
199
211
}
@@ -202,13 +214,15 @@ public void SaveString(ReadOnlyMemory<char> str)
202
214
/// Puts a string into the context pool, and writes the integer code of the string ID
203
215
/// to the write stream.
204
216
/// </summary>
205
- public void SaveNonEmptyString ( string str )
217
+ [ BestFriend ]
218
+ internal void SaveNonEmptyString ( string str )
206
219
{
207
220
_ectx . CheckParam ( ! string . IsNullOrEmpty ( str ) , nameof ( str ) ) ;
208
221
Writer . Write ( Strings . Add ( str ) . Id ) ;
209
222
}
210
223
211
- public void SaveNonEmptyString ( ReadOnlyMemory < Char > str )
224
+ [ BestFriend ]
225
+ internal void SaveNonEmptyString ( ReadOnlyMemory < char > str )
212
226
{
213
227
Writer . Write ( Strings . Add ( str ) . Id ) ;
214
228
}
@@ -217,7 +231,8 @@ public void SaveNonEmptyString(ReadOnlyMemory<Char> str)
217
231
/// Commit the save operation. This completes writing of the main stream. When in repository
218
232
/// mode, it disposes <see cref="Writer"/> (but not <see cref="Repository"/>).
219
233
/// </summary>
220
- public void Done ( )
234
+ [ BestFriend ]
235
+ internal void Done ( )
221
236
{
222
237
_ectx . Check ( Header . ModelSignature != 0 , "ModelSignature not specified!" ) ;
223
238
ModelHeader . EndWrite ( Writer , FpMin , ref Header , Strings , _loaderAssemblyName ) ;
0 commit comments