我开发(重写到WCF)文件解析Web服务接受string[]和返回ISection[]但实际上这是一组嵌套接口:
namespace Project.Contracts // Project.Contracts.dll
{
public interface ISection { }
public interface ISummarySection : ISection { }
public interface IDataSection : ISection { }
}
Run Code Online (Sandbox Code Playgroud)
和班级:
namespace Project.Format.A // Project.Format.A.dll
{
[DataContract]
public class SummarySectionFormatA : ISummarySection { }
[DataContract]
public class DataSectionFormatA : IDataSection { }
}
Run Code Online (Sandbox Code Playgroud)
服务接口及其实现:
[ServiceContract]
public interface IService // Project.Contracts.dll
{
ISection[] Parse(string format, string[] data);
}
[ServiceKnownType(typeof(SummarySectionFormatA))] // tried this also
[ServiceKnownType(typeof(DataSectionFormatA))]
public class Service : IService // Project.Service.dll …Run Code Online (Sandbox Code Playgroud) c# wcf exception-handling datacontractserializer known-types
我想强制svcutil在WCF使用的程序集中生成所有数据协定,无论某个类型是否由给定的操作契约引用.
[DataContract]
public class Foo { }
[DataContract]
public class Bar : Foo { }
[ServiceContract]
public interface IService
{
[OperationContract]
void Get(Foo foo);
}
Run Code Online (Sandbox Code Playgroud)
鉴于此设置,我无法svcutil生成版本,Bar因为目前没有操作合同引用它.有没有办法强制svcutil生成数据合同Bar?