flex4,在.NET环境下通过FluorineFx传送Arraycollection的对象到后台

首先直接传送Arraycollection到后台是,后台不能获取Arraycollection的各种数据。只有在后台将其转换为IList<T>泛型来 操作。

一定要注意,生成的类在NEW时一定要将所有的属性都赋值。

1.现在Flex中编写类,如下:

  

package source.Model
{
	import mx.charts.DateTimeAxis;
	
	//此句不能少,用于对应服务端对象,将对象进行序列化
	//规则: 命名空间.类名
	[RemoteClass(alias="ServiceLibrary.aa")]
	public class aa
	{
		public function aa(label:String,id:String)
		{
			_label = label;
			_id = id;
		}
		
		private var _label:String;

		public function get label():String
		{
			return _label;
		}

		public function set label(value:String):void
		{
			_label = value;
		}

		
		private var _id:String;

		public function get id():String
		{
			return _id;
		}

		public function set id(value:String):void
		{
			_id = value;
		}

	}
}


2.在.net后台建相对于的类

using System;
using System.Collections.Generic;
using System.Text;

namespace ServiceLibrary
{
    public class aa
    {
        private string _label;
        public string label
        {
            get { return _label; }
            set { _label = value; }
        }

        private string _id;
        public string id
        {
            get { return _id; }
            set { _id = value; }
        }
    }
}

3.在flex中建立Arraycollection并传送到后台:

var CustomersList1:ArrayCollection = new ArrayCollection();
				CustomersList1.addItem(new aa("xiaoming","01"));
				CustomersList1.addItem(new aa("zou","01"));
				Service.getArrayCollection(CustomersList1);

4.在后天将接受到的Arraycollection转换为IList<aa>:

        public string getArrayCollection(ArrayCollection cc)
        {
            IList<aa> accoutList;
            accoutList = (cc.List).OfType<aa>().ToList();
            return accoutList[0].label;
            
        }

5.接下来就是C#的分内事情了。

转载于:https://www.cnblogs.com/wyqx/archive/2011/07/21/2113146.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值