mirror of
https://github.com/InsanusMokrassar/SDI.git
synced 2024-12-28 03:27:23 +00:00
now Module is not serializable and instead of Serializer was created ModuleDeserializationStrategy
This commit is contained in:
parent
cee263adb6
commit
2748c3f861
@ -3,7 +3,8 @@
|
|||||||
## 0.1.2
|
## 0.1.2
|
||||||
|
|
||||||
* All reflection support methods are internal
|
* All reflection support methods are internal
|
||||||
* Added `lodModule` functions for more useful working with modules loading
|
* Added `loadModule` functions for more useful working with modules loading
|
||||||
|
* `Module` now is not serializable and can be created only via `loadModule` functions
|
||||||
|
|
||||||
## 0.1.1
|
## 0.1.1
|
||||||
|
|
||||||
|
@ -4,4 +4,4 @@ import kotlinx.serialization.ImplicitReflectionSerializer
|
|||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
|
|
||||||
@ImplicitReflectionSerializer
|
@ImplicitReflectionSerializer
|
||||||
fun loadModule(json: String): Module = Json.nonstrict.parse(Module.serializer(), json)
|
fun loadModule(json: String): Module = Json.nonstrict.parse(ModuleDeserializerStrategy, json)
|
||||||
|
@ -6,13 +6,10 @@ import kotlinx.serialization.internal.HashMapSerializer
|
|||||||
import kotlinx.serialization.internal.StringSerializer
|
import kotlinx.serialization.internal.StringSerializer
|
||||||
import kotlinx.serialization.json.*
|
import kotlinx.serialization.json.*
|
||||||
|
|
||||||
@ImplicitReflectionSerializer
|
class Module internal constructor(base: Map<String, @ContextualSerialization Any>) : Map<String, Any> by base
|
||||||
@Serializable(ModuleSerializer::class)
|
|
||||||
class Module(base: Map<String, @ContextualSerialization Any>) : Map<String, Any> by base
|
|
||||||
|
|
||||||
@ImplicitReflectionSerializer
|
@ImplicitReflectionSerializer
|
||||||
@Serializer(Module::class)
|
internal object ModuleDeserializerStrategy : DeserializationStrategy<Module> {
|
||||||
internal object ModuleSerializer : KSerializer<Module> {
|
|
||||||
private val internalSerializer = HashMapSerializer(StringSerializer, ContextSerializer(Any::class))
|
private val internalSerializer = HashMapSerializer(StringSerializer, ContextSerializer(Any::class))
|
||||||
override val descriptor: SerialDescriptor
|
override val descriptor: SerialDescriptor
|
||||||
get() = internalSerializer.descriptor
|
get() = internalSerializer.descriptor
|
||||||
@ -27,7 +24,5 @@ internal object ModuleSerializer : KSerializer<Module> {
|
|||||||
return Module(map)
|
return Module(map)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun serialize(encoder: Encoder, obj: Module) {
|
override fun patch(decoder: Decoder, old: Module): Module = throw UpdateNotSupportedException("Module")
|
||||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user