zoukankan      html  css  js  c++  java
  • 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#的分内事情了。

  • 相关阅读:
    第二阶段总结
    傻子都会app与学习通
    天工疼憨仔组项目评审
    第一阶段意见
    冲刺(十)
    冲刺(九)
    冲刺(八)
    冲刺(七)
    后Hadoop时代的大数据架构
    ZooKeeper典型使用场景一览
  • 原文地址:https://www.cnblogs.com/wyqx/p/2113146.html
Copyright © 2011-2022 走看看