示例#1
0
 public static void RegisterClass <T>(
     Action <NetOutgoingMessage, object> customSerializer   = null,
     Action <NetIncomingMessage, object> customDeserializer = null)
     where T : class, new()
 {
     SynchronizingInfo.RegisterSyncInfo(new SynchronizingInfo
     {
         Type               = typeof(T),
         IsIdentifiable     = false,
         ObjectConstructor  = () => new T(),
         CustomSerializer   = customSerializer,
         CustomDeserializer = customDeserializer
     });
     ObjectSync.Sync.RegisterClass <T>(() => new T());
 }
示例#2
0
 public static void RegisterIdentifiable <T>(
     Func <long, object> idToObject,
     Func <object, long> objectToId,
     Action <NetOutgoingMessage, object> customSerializer   = null,
     Action <NetIncomingMessage, object> customDeserializer = null)
     where T : class, new()
 {
     SynchronizingInfo.RegisterSyncInfo(new SynchronizingInfo
     {
         Type               = typeof(T),
         IsIdentifiable     = true,
         ObjectConstructor  = () => new T(),
         IdToObject         = idToObject,
         ObjectToId         = objectToId,
         CustomSerializer   = customSerializer,
         CustomDeserializer = customDeserializer
     });
     ObjectSync.Sync.RegisterClass <T>(() => new T());
 }