• WCF RIA Services 简单应用


    DomainService1:

    namespace SilverlightApplication3.Web
    {
        using System;
        using System.Collections.Generic;
        using System.ComponentModel;
        using System.ComponentModel.DataAnnotations;
        using System.Linq;
        using System.ServiceModel.DomainServices.Hosting;
        using System.ServiceModel.DomainServices.Server;
    
    
        // TODO: 创建包含应用程序逻辑的方法。
        [EnableClientAccess()]
        public class DomainService1 : DomainService
        {
            [Invoke]
            public string getName()
            {
                return " Jack";
            }
    
    
            [Invoke]
            public Person getPerson()
            {
                Person p = new Person();
    
                p.Name = "jack";
                p.Sex = "male";
                return p;
            }
    
            [Invoke]
            public List<Person> getPersonList()
            {
                List<Person> list = new List<Person>();
                for (int i = 0; i < 10; i++)
                {
                    Person p = new Person();
                    p.Name = "jack" + i;
                    p.Sex = "male" + i;
                    list.Add(p);
                }
    
                return list;
            }
        }
    
        public class Person
        {
            public string Name { get; set; }
            public string Sex { get; set; }
        }
    }

    MainPage:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    using SilverlightApplication3.Web;
    
    namespace SilverlightApplication3
    {
        public partial class MainPage : UserControl
        {
            public MainPage()
            {
                InitializeComponent();
                gert();
            }
    
    
            public void gert()
            {
                DomainService1 ds = new DomainService1();
                ds.getName(o => gethhh(o.Value), null);
    
                ds.getPerson(o => gethhu(o.Value), null);
    
                ds.getPersonList(o => getlist(o.Value), null);
            }
    
            void gethhh(object v)
            {
                //MessageBox.Show((string)v);
            }
    
            void gethhu(object v)
            {
                //Person mm = (Person) v;
                //MessageBox.Show(mm.Name);
            }
    
            void getlist(object l)
            {
                List<Person> kl = (List<Person>)l;
                MessageBox.Show(kl.FirstOrDefault().Name);
            }
        }
    }

    附上源码:下载

  • 相关阅读:
    BNUOJ 19792 Airport Express
    Poor Hanamichi
    BNUOJ 1206 A Plug for UNIX
    HDU 3507 Print Article
    一个程序猿试用有道云笔记VIP功能体验
    Cloud Foundry Session Affinity(Sticky Session)的实现
    SAP成都研究院廖婧:SAP C4C社交媒体集成概述
    SAP订单编排和流程增强概述
    在Kubernetes上运行SAP UI5应用(上)
    Docker入门系列之三:如何将dockerfile制作好的镜像发布到Docker hub上
  • 原文地址:https://www.cnblogs.com/hantianwei/p/2532558.html
Copyright © 2020-2023  润新知