mardi 23 août 2016

Use decorated WCF entity class without referencing service itself

I have a service, which produced a class, let's say OperationDesc in MyProject.Proxy. I want to have my class, that wraps some of the properties of OperationDesc. So I've created a class OperationView in MyProject.Entity and derieved it from OperationDesc.

// just example
public class OperationView : OperationDesc {

    public string DateString {
        get 
        {
            // Created - parent property
            return Created.ToString();
        }
    }    

}

Now I'm trying to use OperationView in MyProject.Web, using reference to MyProject.Entity. But I can't access OperationDesc properties, unless I reference Proxy library, what I don't want to do. Can you suggest any pattern or approach I need to use here? The main goal is to decorate service class with some additional properties, without referencing Proxy library. Ofc I can copy all properties from OperationDesc to OperationView and use AutoMapper, but it looks like antipattern. Thx.

Aucun commentaire:

Enregistrer un commentaire