Modding:Network API: Difference between revisions

From Vintage Story Wiki
Line 37: Line 37:


<syntaxhighlight lang="c#">
<syntaxhighlight lang="c#">
[ProtoContract(ImplicitFields = ImplicitFields.AllPublic)]
    [ProtoContract(ImplicitFields = ImplicitFields.AllPublic)]
     public class NetworkApiTestMessage
     public class NetworkApiTestMessage
     {
     {
Line 52: Line 52:
The argument we pass to <code>ProtoContract</code> makes it so all <code>public</code> fields will be serialized; without this, we'd declare fields for serialization by using <code>ProtoMember</code> attributes. If we chose this approach, we'd write our classes like so:
The argument we pass to <code>ProtoContract</code> makes it so all <code>public</code> fields will be serialized; without this, we'd declare fields for serialization by using <code>ProtoMember</code> attributes. If we chose this approach, we'd write our classes like so:
<syntaxhighlight lang="c#">
<syntaxhighlight lang="c#">
[ProtoContract]
    [ProtoContract]
     public class NetworkApiTestMessage
     public class NetworkApiTestMessage
     {
     {
Line 59: Line 59:
     }
     }


     [ProtoContract()]
     [ProtoContract]
     public class NetworkApiTestResponse
     public class NetworkApiTestResponse
     {
     {