OrchestrationRuntimeStatus 枚举序列化或反序列化 [英] OrchestrationRuntimeStatus Enum serialization or deserialization

查看:43
本文介绍了OrchestrationRuntimeStatus 枚举序列化或反序列化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个枚举

 public enum OrchestrationRuntimeStatus
    {
        Unknown = -1,
        Running = 0,
        Completed = 1,
        ContinuedAsNew = 2,
        Failed = 3,
        Canceled = 4,
        Terminated = 5,
        Pending = 6
    }

我的类 status 中有一个 OrchestrationRuntimeStatus 类型的变量.变量是

There is a variable in my class status of the type OrchestrationRuntimeStatus. The variable is

public sealed class status
{
    [JsonConverter(typeof(StringEnumConverter))]
            public OrchestrationRuntimeStatus RuntimeStatus { get; set; }
}

我有另一个返回类型为 OkObjectResultWithHeaders(status, headers) 的函数.

I have another function whose return type is OkObjectResultWithHeaders(status, headers).

当我在上面的函数中看到 status.RuntimeStatus 的值时,它显示为未知,正在运行,我想将其显示为 -1, 0.有没有办法序列化或反序列化将这些字符串显示为整数?

When I see the value of status.RuntimeStatus in the above function it is showing as unknown, running, I want to show it as -1, 0. Is there a way serialize or de-serialize to show those strings as integers?

PS:请随意编辑问题,因为我写得不正确.

PS: Feel free to edit the question as I didn't write it correctly.

推荐答案

[JsonConverter(typeof(StringEnumConverter))] 执行枚举到字符串的序列化.简单地删除它会将序列化默认为 int.

[JsonConverter(typeof(StringEnumConverter))] preforms the serialisation of the enum to string. Simply removing this will default the serialisation to an int.

这篇关于OrchestrationRuntimeStatus 枚举序列化或反序列化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆