Flex,.NET Web服务和数值枚举 [英] Flex, .NET Web Service and Numeric Enums

查看:173
本文介绍了Flex,.NET Web服务和数值枚举的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用Flex 3来使用.NET Web服务。 Web服务使用枚举,我们使用Flex Builder自动生成Web服务对象。这里是.NET的Web服务枚举定义:

  ///< summary> 
///用户类型
///< / summary>
public enum UserTypeEnum
{
Admin = 1,
User = 3,
Manager = 4
}


$ b pre> [Inspectable(category =Generated values,enumeration =Admin,User,Manager,type =String)]
public var _UserTypeEnum:String; public function toString():String
{
return _UserTypeEnum.toString();



$ b $ p
$ b当我们从Web服务获取数据时,使用这个枚举的任何属性是空而不是管理员或1。有什么办法可以做到这一点吗?

解决方案

请注意,枚举和Web服务存在问题。



请参阅此问题


  • 在web服务中应该使用[Serializable,Flags]。
  • 标志应该是2的倍数

  • 枚举定义应该从1开始而不是从0开始。

    We're using Flex 3 to consume a .NET Web Service. The web service uses an enum and we use Flex Builder to automatically generate the web service objects. Here is the .NET web service enum definition:

     /// <summary>
       /// User type
       /// </summary>
       public enum UserTypeEnum
       {
           Admin = 1,
           User = 3,
           Manager = 4
       }
    

    When Flex generates the web service objects, it treats them as strings instead of integer values.

    [Inspectable(category="Generated values", enumeration="Admin, User, Manager", type="String")]
    public var _UserTypeEnum:String;public function toString():String
    {
    return _UserTypeEnum.toString();
    }
    

    When we get data from the web service, any property that uses this enumeration is Null instead of 'admin' or '1'. Is there any way to make this work?

    解决方案

    Be aware that there are issues with enumerations and web services.

    See this question.

    • Should be using [Serializable,Flags] in web service.
    • Flags should be multiples of two
    • The enumeration definition should start from 1 rather than 0.

    这篇关于Flex,.NET Web服务和数值枚举的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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