ツールが何をすべきかを知るために適切なetc 属性を持っている限り、事前にコンパイルされていても機能するはずです。単一のルート オブジェクトを使用することで、もう少し支援できます。CustomClass
[ProtoContract]
precompile.exe
[ProtoContract]
public class SomeWrapper {
[ProtoMember(1)]
public Dictionary<string, CustomClass> Items {get;set;}
}
しかし、これは必須ではありません。たまたま、ルート オブジェクトとしての list/dictionary/etcの出力は、最初のメンバーとして list/dictionary/etc を持つラッパー オブジェクトの出力と100% 同一です[ProtoMember(1)]
( )。
precompile.exe
プリコンパイルするには、Google コードのダウンロードから使用します。
precompile YourApp\Your.dll –o:YourSerializer.dll –t:YourSerializer
次に、アプリケーション レベルのコードは次のようになります。
using (var zipData = new GZipStream(stream, CompressionMode.Decompress, true))
{
var serializer = new YourSerializer();
data = (SomeWrapper)serializer.Deserialize(
zipData, null, typeof(SomeWrapper));
}