使用android从wcf服务发送和接收通用列表

时间:2016-09-01 08:36:08

标签: java c# android wcf

我是android的新手,正在寻找一个通用的解决方案来从android应用程序中的wcf服务发送和接收c#通用列表。我将在android中拥有Equipment类的副本也想将从GeEquipments返回的列表转换为泛型android中的数组列表,也发送列表设置设备,因为我有更多的对象,我正在寻找可以被任何对象使用的通用解决方案。

[DataContract]
public class Equipment 
{
    [DataMember]
    public long Id { get; set; }

    [DataMember]
    public string Name { get; set; }

    [DataMember]
    public string SerialNo { get; set; }

    [DataMember]
    public string Description { get; set; }

    [DataMember]
    public bool Active { get; set; }
}

[ServiceContract]
public interface IService
{  
    [OperationContract]
    List<Equipment> GetEquipments();

    [OperationContract]
    bool  SetEquipments( List<Equipment> equipments);
}

public class RService : IService
{
    public List<Equipment> GetEquipments()
    {
       var equipments = new List<Equipment>();

       equipments.Add(new Equipment()
       {
           Name = "Equipment 1",
           SerialNo = "E001",
           Description = "New Equipment",
           Active = true
       });

       equipments.Add(new Equipment()
       {
           Name = "Equipment 2",
           SerialNo = "E002",
           Description = "New Equipment",
           Active = true
       });

       return equipments;
    }

    public bool SetEquipments(List<Equipment> equipments)
    {
        return true;
    }
}

0 个答案:

没有答案