@@ -84,14 +84,13 @@ public ITermDictionary<JsonNode> ReplaceContent(string searchPattern, string rep
8484 var result = new Dictionary < string , JsonNode > ( ) ;
8585 foreach ( var ( key , value ) in this )
8686 {
87- if ( value is JsonValue jsonValue
88- && jsonValue . TryGetValue < string > ( out var stringValue ) )
87+ if ( value . GetValueKind ( ) == JsonValueKind . String )
8988 {
90- var replaced = Regex . Replace ( stringValue ,
89+ var replaced = Regex . Replace ( value . GetValue < string > ( ) ,
9190 searchPattern ,
9291 replacement ,
9392 RegexOptions . Singleline ) ;
94- result . Add ( key , JsonValue . Create ( replaced ) ! ) ; // 我猜不会null罢
93+ result . Add ( key , JsonValue . Create ( replaced ) ) ; // 我猜不会null罢
9594 continue ;
9695 }
9796 result . Add ( key , value ) ;
@@ -101,12 +100,8 @@ public ITermDictionary<JsonNode> ReplaceContent(string searchPattern, string rep
101100
102101 public static ITermDictionary < JsonNode > Create ( IDictionary < string , string > nominalMapping )
103102 {
104- var query = from pair in nominalMapping
105- let key = pair . Key
106- let value = pair . Value
107- let node = JsonValue . Create ( value ) !
108- select ( key , node ) ;
109- var transformed = query . ToDictionary ( _ => _ . key , _ => _ . node as JsonNode ) ;
103+ var transformed = nominalMapping
104+ . ToDictionary ( p => p . Key , p => JsonValue . Create ( p . Value ) as JsonNode ) ;
110105 return new JsonDictionaryWrapper ( transformed ) ;
111106 }
112107 }
@@ -145,7 +140,8 @@ public TermMappingProvider(ITermDictionary<TValue> map, string destination)
145140 /// <inheritdoc/>
146141 public IResourceFileProvider ApplyTo ( IResourceFileProvider ? baseProvider , ApplyOptions options )
147142 {
148- if ( baseProvider is null ) return this ;
143+ if ( baseProvider is null )
144+ return this ;
149145
150146 if ( baseProvider is not TermMappingProvider < TValue > baseMapping )
151147 throw new ArgumentException ( $ "Argument not an instance of { typeof ( TermMappingProvider < TValue > ) } .",
@@ -190,7 +186,7 @@ public IResourceFileProvider ReplaceDestination(string searchPattern, string rep
190186 RegexOptions . Singleline ) ) ;
191187
192188 /// <inheritdoc/>
193- public async Task WriteToArchive ( ZipArchive archive )
189+ public async Task WriteToArchiveAsync ( ZipArchive archive )
194190 {
195191 var destination = Destination . NormalizePath ( ) ;
196192 Log . Debug ( "[TermMappingProvider`1]写入路径 {0}" , destination ) ;
@@ -287,7 +283,8 @@ internal static Dictionary<string, string> DeserializeFromLang(string content)
287283 var splitPosition = line . IndexOf ( '=' ) ;
288284
289285 // https://github.com/CFPAOrg/Minecraft-Mod-Language-Package/pull/3272/files#r1461545452
290- if ( splitPosition == - 1 ) continue ;
286+ if ( splitPosition == - 1 )
287+ continue ;
291288
292289 var key = line [ ..splitPosition ] ;
293290 var value = splitPosition + 1 < line . Length
0 commit comments