English 中文(简体)
通过周转基金通过物体,使服务器能接收客户的变化
原标题:Passing object through WCF so that server receives client changes
  • 时间:2010-05-24 22:17:08
  •  标签:
  • c#
  • wcf

我愿设立一个全球合作框架服务,使客户对我寄送的物体的任何改动也反映在服务器上。 例如,如果A大会有以下内容:

namespace AssemblyA
{

    public class Person
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }
    }

    [ServiceContract]
    public interface IServer
    {
        [OperationContract]
        Person GetPerson();
    }

}

A. 大会

using AssemblyA;

namespace AssemblyB
{
    class Program
    {
        static void Main(string[] args)
        {
            <snip>
            IServer server = factory.CreateChannel();
            Person person = server.GetPerson();
            person.FirstName = "Kilroy";
            person.LastName = "WuzHere";
        }
    }
}

作出这种安排的最容易/最容易的方法是什么,以便把服务复制的个人物品也反映客户所作的改动? 这是否可行?

最佳回答

在服务器上采用<代码>Person作为参数的物体创建一种方法。

[ServiceContract]
public interface IServer
{
    [OperationContract]
    Person GetPerson();

    [OperationContract]
    void UpdatePerson( Person person )
}

并且要求客户在你确定第一Name和最后一个Name财产之后再这样做。

server.UpdatePerson( person );
问题回答

If you are in need for handling events between the client & server, you ought to look for Duplex Contracts with WCF. This is a very good detailed example for you to start with: http://www.codeproject.com/Articles/491844/A-Beginners-Guide-to-Duplex-WCF





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签