我在WCF服务中定义了以下struct
:
[Serializable]
[DataContract]
public struct CompositeKey :
IComparable, IComparable<CompositeKey>, IEquatable<CompositeKey>
{
[DataMember]
public long Primary { get; private set; }
[DataMember]
public byte Secondary { get; private set; }
//others
}
用作其他一些数据合同的成员:
[DataContract]
public class PatternFrequencyArgs
{
[DataMember(IsRequired=true, EmitDefaultValue=false)]
public CompositeKey PatternKey { get; set; }
[DataMember(IsRequired = true)]
public CompositeKey SessionStatKey { get; set; }
[DataMember]
public int Frequency { get; set; }
}
在客户端,wsutil.exe
生成此结构:
typedef struct PatternFrequencyArgs
{
int Frequency;
struct CompositeKey* PatternKey; //why pointer?
struct CompositeKey* SessionStatKey; //why pointer?
} PatternFrequencyArgs;
如您所见,CompositeKey
成员生成为指针。我不希望它们成为指针。如何避免这种情况,而是将它们生成为非指针成员?
生成上述结构的相关XSD就是这个(我猜):
<xs:complexType name="PatternFrequencyArgs">
<xs:sequence>
<xs:element minOccurs="0" name="Frequency" type="xs:int" />
<xs:element xmlns:q6="http://schemas.etc..." name="PatternKey" type="q6:CompositeKey">
<xs:annotation>
<xs:appinfo>
<DefaultValue EmitDefaultValue="false" xmlns="http://schemas.etc..." />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element xmlns:q7="http://schemas.etc..." name="SessionStatKey" type="q7:CompositeKey" />
</xs:sequence>
</xs:complexType>