1- // Copyright 2019-2025 Chris Mohan, Jaben Cargman
1+ // Copyright 2019-2025 Chris Mohan, Jaben Cargman
22// and GotenbergSharpApiClient Contributors
33//
44// Licensed under the Apache License, Version 2.0 (the "License");
1313// See the License for the specific language governing permissions and
1414// limitations under the License.
1515
16-
17-
1816namespace Gotenberg . Sharp . API . Client . Domain . Builders . Faceted
1917{
2018 public sealed class AssetBuilder
@@ -26,12 +24,10 @@ internal AssetBuilder(AssetDictionary assets)
2624 this . _assets = assets ;
2725 }
2826
29-
3027 public AssetBuilder AddItem ( string name , ContentItem value )
3128 {
3229 // ReSharper disable once ComplexConditionExpression
33- if ( name . IsNotSet ( ) || new FileInfo ( name ) . Extension . IsNotSet ( )
34- || name . LastIndexOf ( '/' ) >= 0 )
30+ if ( name . IsNotSet ( ) || new FileInfo ( name ) . Extension . IsNotSet ( ) || name . LastIndexOf ( '/' ) >= 0 )
3531 {
3632 throw new ArgumentOutOfRangeException (
3733 nameof ( name ) ,
@@ -43,23 +39,16 @@ public AssetBuilder AddItem(string name, ContentItem value)
4339 return this ;
4440 }
4541
46-
47- public AssetBuilder AddItem ( string name , string value ) =>
48- AddItem ( name , new ContentItem ( value ) ) ;
42+ public AssetBuilder AddItem ( string name , string value ) => AddItem ( name , new ContentItem ( value ) ) ;
4943
50-
51- public AssetBuilder AddItem ( string name , byte [ ] value ) =>
52- AddItem ( name , new ContentItem ( value ) ) ;
44+ public AssetBuilder AddItem ( string name , byte [ ] value ) => AddItem ( name , new ContentItem ( value ) ) ;
5345
54-
55- public AssetBuilder AddItem ( string name , Stream value ) =>
56- AddItem ( name , new ContentItem ( value ) ) ;
46+ public AssetBuilder AddItem ( string name , Stream value ) => AddItem ( name , new ContentItem ( value ) ) ;
5747
5848 #region 'n' assets
5949
6050 #region from dictionaries
6151
62-
6352 public AssetBuilder AddItems ( Dictionary < string , ContentItem > ? items )
6453 {
6554 foreach ( var item in items . IfNullEmpty ( ) )
@@ -70,47 +59,39 @@ public AssetBuilder AddItems(Dictionary<string, ContentItem>? items)
7059 return this ;
7160 }
7261
73-
7462 public AssetBuilder AddItems ( Dictionary < string , string > ? assets ) =>
7563 AddItems ( assets ? . ToDictionary ( a => a . Key , a => new ContentItem ( a . Value ) ) ) ;
7664
77-
7865 public AssetBuilder AddItems ( Dictionary < string , byte [ ] > ? assets ) =>
7966 AddItems ( assets ? . ToDictionary ( a => a . Key , a => new ContentItem ( a . Value ) ) ) ;
8067
81-
8268 public AssetBuilder AddItems ( Dictionary < string , Stream > ? assets ) =>
8369 AddItems ( assets ? . ToDictionary ( a => a . Key , a => new ContentItem ( a . Value ) ) ) ;
8470
8571 #endregion
8672
8773 #region from KVP enumerables
8874
89-
9075 public AssetBuilder AddItems ( IEnumerable < KeyValuePair < string , ContentItem > > assets ) =>
9176 AddItems (
9277 new Dictionary < string , ContentItem > (
93- assets ? . ToDictionary ( a => a . Key , a => a . Value ) ??
94- throw new ArgumentNullException ( nameof ( assets ) ) ) ) ;
78+ assets ? . ToDictionary ( a => a . Key , a => a . Value ) ?? throw new ArgumentNullException ( nameof ( assets ) ) ) ) ;
9579
96-
9780 public AssetBuilder AddItems ( IEnumerable < KeyValuePair < string , string > > assets ) =>
9881 AddItems (
9982 new Dictionary < string , ContentItem > (
100- assets ? . ToDictionary ( a => a . Key , a => new ContentItem ( a . Value ) ) ??
101- throw new ArgumentNullException ( nameof ( assets ) ) ) ) ;
83+ assets ? . ToDictionary ( a => a . Key , a => new ContentItem ( a . Value ) )
84+ ?? throw new ArgumentNullException ( nameof ( assets ) ) ) ) ;
10285
103-
10486 public AssetBuilder AddItems ( IEnumerable < KeyValuePair < string , byte [ ] > > assets ) =>
10587 AddItems (
106- assets ? . ToDictionary ( a => a . Key , a => new ContentItem ( a . Value ) ) ??
107- throw new ArgumentNullException ( nameof ( assets ) ) ) ;
88+ assets ? . ToDictionary ( a => a . Key , a => new ContentItem ( a . Value ) )
89+ ?? throw new ArgumentNullException ( nameof ( assets ) ) ) ;
10890
109-
11091 public AssetBuilder AddItems ( IEnumerable < KeyValuePair < string , Stream > > assets ) =>
11192 AddItems (
112- assets ? . ToDictionary ( s => s . Key , a => new ContentItem ( a . Value ) ) ??
113- throw new ArgumentNullException ( nameof ( assets ) ) ) ;
93+ assets ? . ToDictionary ( s => s . Key , a => new ContentItem ( a . Value ) )
94+ ?? throw new ArgumentNullException ( nameof ( assets ) ) ) ;
11495
11596 #endregion
11697
0 commit comments