ここから次のコードを見てください。
これは、wcfでシリアル化するときに、データコントラクト(オブジェクトモデル、オブジェクトグラフ、ドメインモデル)で循環参照を保持することです。
class ReferencePreservingDataContractSerializerOperationBehavior
:DataContractSerializerOperationBehavior
{
public ReferencePreservingDataContractSerializerOperationBehavior(
OperationDescription operationDescription)
: base(operationDescription) { }
public override XmlObjectSerializer CreateSerializer(
Type type, string name, string ns, IList<Type> knownTypes)
{
return CreateDataContractSerializer(type, name, ns, knownTypes);
}
private static XmlObjectSerializer CreateDataContractSerializer(
Type type, string name, string ns, IList<Type> knownTypes)
{
return CreateDataContractSerializer(type, name, ns, knownTypes);
}
public override XmlObjectSerializer CreateSerializer(
Type type, XmlDictionaryString name, XmlDictionaryString ns,
IList<Type> knownTypes)
{
return new DataContractSerializer(type, name, ns, knownTypes,
0x7FFF /*maxItemsInObjectGraph*/,
false/*ignoreExtensionDataObject*/,
true/*preserveObjectReferences*/,
null/*dataContractSurrogate*/);
}
}
CreateDataContractSerializer
無限ループ(stackoverflow)を生成していませんか?したがって、前述のCreateSerializer
メソッドも生成していませんか?
private static XmlObjectSerializer CreateDataContractSerializer(
Type type, string name, string ns, IList<Type> knownTypes)
{
return CreateDataContractSerializer(type, name, ns, knownTypes);
}
今、これらの方法は使用されていないのでしょうか?ここで何が欠けていますか?