@@ -76,7 +76,7 @@ public OLEPropertiesContainer(int codePage, ContainerType containerType)
76
76
Behavior = Behavior . CaseInsensitive
77
77
} ;
78
78
79
- this . ContainerType = containerType ;
79
+ ContainerType = containerType ;
80
80
}
81
81
82
82
internal OLEPropertiesContainer ( CFStream cfStream )
@@ -86,25 +86,18 @@ internal OLEPropertiesContainer(CFStream cfStream)
86
86
this . cfStream = cfStream ;
87
87
pStream . Read ( new BinaryReader ( new StreamDecorator ( cfStream ) ) ) ;
88
88
89
- switch ( pStream . FMTID0 . ToString ( "B" ) . ToUpperInvariant ( ) )
89
+ ContainerType = pStream . FMTID0 . ToString ( "B" ) . ToUpperInvariant ( ) switch
90
90
{
91
- case WellKnownFMTID . FMTID_SummaryInformation :
92
- this . ContainerType = ContainerType . SummaryInfo ;
93
- break ;
94
- case WellKnownFMTID . FMTID_DocSummaryInformation :
95
- this . ContainerType = ContainerType . DocumentSummaryInfo ;
96
- break ;
97
- default :
98
- this . ContainerType = ContainerType . AppSpecific ;
99
- break ;
100
- }
101
-
102
- this . FmtID0 = pStream . FMTID0 ;
91
+ WellKnownFMTID . FMTID_SummaryInformation => ContainerType . SummaryInfo ,
92
+ WellKnownFMTID . FMTID_DocSummaryInformation => ContainerType . DocumentSummaryInfo ,
93
+ _ => ContainerType . AppSpecific ,
94
+ } ;
95
+ FmtID0 = pStream . FMTID0 ;
103
96
104
- this . PropertyNames = ( Dictionary < uint , string > ) pStream . PropertySet0 . Properties
97
+ PropertyNames = ( Dictionary < uint , string > ) pStream . PropertySet0 . Properties
105
98
. Where ( p => p . PropertyType == PropertyType . DictionaryProperty ) . FirstOrDefault ( ) ? . Value ;
106
99
107
- this . Context = new PropertyContext ( )
100
+ Context = new PropertyContext ( )
108
101
{
109
102
CodePage = pStream . PropertySet0 . PropertyContext . CodePage
110
103
} ;
@@ -131,7 +124,7 @@ internal OLEPropertiesContainer(CFStream cfStream)
131
124
if ( pStream . NumPropertySets == 2 )
132
125
{
133
126
UserDefinedProperties = new OLEPropertiesContainer ( pStream . PropertySet1 . PropertyContext . CodePage , ContainerType . UserDefinedProperties ) ;
134
- this . HasUserDefinedProperties = true ;
127
+ HasUserDefinedProperties = true ;
135
128
136
129
UserDefinedProperties . ContainerType = ContainerType . UserDefinedProperties ;
137
130
@@ -144,11 +137,12 @@ internal OLEPropertiesContainer(CFStream cfStream)
144
137
var p = ( ITypedPropertyValue ) pStream . PropertySet1 . Properties [ i ] ;
145
138
var poi = pStream . PropertySet1 . PropertyIdentifierAndOffsets [ i ] ;
146
139
147
- var op = new OLEProperty ( UserDefinedProperties ) ;
148
-
149
- op . VTType = p . VTType ;
150
- op . PropertyIdentifier = pStream . PropertySet1 . PropertyIdentifierAndOffsets [ i ] . PropertyIdentifier ;
151
- op . Value = p . Value ;
140
+ var op = new OLEProperty ( UserDefinedProperties )
141
+ {
142
+ VTType = p . VTType ,
143
+ PropertyIdentifier = pStream . PropertySet1 . PropertyIdentifierAndOffsets [ i ] . PropertyIdentifier ,
144
+ Value = p . Value
145
+ } ;
152
146
153
147
UserDefinedProperties . properties . Add ( op ) ;
154
148
}
@@ -201,9 +195,9 @@ public void RemoveProperty(uint propertyIdentifier)
201
195
public OLEPropertiesContainer CreateUserDefinedProperties ( int codePage )
202
196
{
203
197
// Only the DocumentSummaryInfo stream can contain a UserDefinedProperties
204
- if ( this . ContainerType != ContainerType . DocumentSummaryInfo )
198
+ if ( ContainerType != ContainerType . DocumentSummaryInfo )
205
199
{
206
- throw new CFInvalidOperation ( $ "Only a DocumentSummaryInfo can contain user defined properties. Current container type is { this . ContainerType } ") ;
200
+ throw new CFInvalidOperation ( $ "Only a DocumentSummaryInfo can contain user defined properties. Current container type is { ContainerType } ") ;
207
201
}
208
202
209
203
// Create the container, and add the codepage to the initial set of properties
@@ -220,7 +214,7 @@ public OLEPropertiesContainer CreateUserDefinedProperties(int codePage)
220
214
} ;
221
215
222
216
UserDefinedProperties . properties . Add ( op ) ;
223
- this . HasUserDefinedProperties = true ;
217
+ HasUserDefinedProperties = true ;
224
218
225
219
return UserDefinedProperties ;
226
220
}
@@ -233,7 +227,7 @@ public void Save(CFStream cfStream)
233
227
Stream s = new StreamDecorator ( cfStream ) ;
234
228
BinaryWriter bw = new BinaryWriter ( s ) ;
235
229
236
- Guid fmtId0 = this . FmtID0 ?? ( this . ContainerType == ContainerType . SummaryInfo ? new Guid ( WellKnownFMTID . FMTID_SummaryInformation ) : new Guid ( WellKnownFMTID . FMTID_DocSummaryInformation ) ) ;
230
+ Guid fmtId0 = FmtID0 ?? ( ContainerType == ContainerType . SummaryInfo ? new Guid ( WellKnownFMTID . FMTID_SummaryInformation ) : new Guid ( WellKnownFMTID . FMTID_DocSummaryInformation ) ) ;
237
231
238
232
PropertySetStream ps = new PropertySetStream
239
233
{
@@ -252,26 +246,26 @@ public void Save(CFStream cfStream)
252
246
253
247
PropertySet0 = new PropertySet
254
248
{
255
- NumProperties = ( uint ) this . Properties . Count ( ) ,
249
+ NumProperties = ( uint ) Properties . Count ( ) ,
256
250
PropertyIdentifierAndOffsets = new List < PropertyIdentifierAndOffset > ( ) ,
257
- Properties = new List < Interfaces . IProperty > ( ) ,
258
- PropertyContext = this . Context
251
+ Properties = new List < IProperty > ( ) ,
252
+ PropertyContext = Context
259
253
}
260
254
} ;
261
255
262
256
// If we're writing an AppSpecific property set and have property names, then add a dictionary property
263
- if ( this . ContainerType == ContainerType . AppSpecific && this . PropertyNames != null && this . PropertyNames . Count > 0 )
257
+ if ( ContainerType == ContainerType . AppSpecific && PropertyNames != null && PropertyNames . Count > 0 )
264
258
{
265
- AddDictionaryPropertyToPropertySet ( this . PropertyNames , ps . PropertySet0 ) ;
259
+ AddDictionaryPropertyToPropertySet ( PropertyNames , ps . PropertySet0 ) ;
266
260
ps . PropertySet0 . NumProperties += 1 ;
267
261
}
268
262
269
263
PropertyFactory factory =
270
- this . ContainerType == ContainerType . DocumentSummaryInfo ? DocumentSummaryInfoPropertyFactory . Instance : DefaultPropertyFactory . Instance ;
264
+ ContainerType == ContainerType . DocumentSummaryInfo ? DocumentSummaryInfoPropertyFactory . Instance : DefaultPropertyFactory . Instance ;
271
265
272
- foreach ( var op in this . Properties )
266
+ foreach ( var op in Properties )
273
267
{
274
- ITypedPropertyValue p = factory . NewProperty ( op . VTType , this . Context . CodePage , op . PropertyIdentifier ) ;
268
+ ITypedPropertyValue p = factory . NewProperty ( op . VTType , Context . CodePage , op . PropertyIdentifier ) ;
275
269
p . Value = op . Value ;
276
270
ps . PropertySet0 . Properties . Add ( p ) ;
277
271
ps . PropertySet0 . PropertyIdentifierAndOffsets . Add ( new PropertyIdentifierAndOffset ( ) { PropertyIdentifier = op . PropertyIdentifier , Offset = 0 } ) ;
@@ -284,20 +278,20 @@ public void Save(CFStream cfStream)
284
278
ps . PropertySet1 = new PropertySet
285
279
{
286
280
// Number of user defined properties, plus 1 for the name dictionary
287
- NumProperties = ( uint ) this . UserDefinedProperties . Properties . Count ( ) + 1 ,
281
+ NumProperties = ( uint ) UserDefinedProperties . Properties . Count ( ) + 1 ,
288
282
PropertyIdentifierAndOffsets = new List < PropertyIdentifierAndOffset > ( ) ,
289
- Properties = new List < Interfaces . IProperty > ( ) ,
283
+ Properties = new List < IProperty > ( ) ,
290
284
PropertyContext = UserDefinedProperties . Context
291
285
} ;
292
286
293
287
ps . FMTID1 = new Guid ( WellKnownFMTID . FMTID_UserDefinedProperties ) ;
294
288
ps . Offset1 = 0 ;
295
289
296
290
// Add the dictionary containing the property names
297
- AddDictionaryPropertyToPropertySet ( this . UserDefinedProperties . PropertyNames , ps . PropertySet1 ) ;
291
+ AddDictionaryPropertyToPropertySet ( UserDefinedProperties . PropertyNames , ps . PropertySet1 ) ;
298
292
299
293
// Add the properties themselves
300
- foreach ( var op in this . UserDefinedProperties . Properties )
294
+ foreach ( var op in UserDefinedProperties . Properties )
301
295
{
302
296
ITypedPropertyValue p = DefaultPropertyFactory . Instance . NewProperty ( op . VTType , ps . PropertySet1 . PropertyContext . CodePage , op . PropertyIdentifier ) ;
303
297
p . Value = op . Value ;
0 commit comments