zoukankan      html  css  js  c++  java
  • 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);
            }
        }
    }

    附上源码:下载

  • 相关阅读:
    微服务概述
    Airflow 配置celery+rabbitmq和celery+redis
    CentOS7安装Airflow
    Python如何import其它.py文件及其函数
    ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
    CentOS7安装MySQL
    Hadoop完全分布式环境下,DataNode进程正常启动,但是网页上不显示DataNode节点
    <一> windbg简介
    几个资料下载网站
    使用VS2012 C++ 进行单元测试
  • 原文地址:https://www.cnblogs.com/hantianwei/p/2532558.html
Copyright © 2011-2022 走看看