Exemple #1
0
            protected override bool TrySerializeRoot(TypeModel model, ref ProtoWriter.State state, object value)
            {
                var serializer = TypeModel.TryGetSerializer <T>(model);

                if (serializer == null)
                {
                    return(false);
                }
                // note this null-check is non-trivial; for value-type T it promotes the null to a default
                state.SerializeRoot <T>(TypeHelper <T> .FromObject(value), serializer);
                return(true);
            }
Exemple #2
0
 void Write(DatabaseCompat db, ref ProtoWriter.State state)
 {
     try
     {
         var watch = Stopwatch.StartNew();
         state.SerializeRoot(db);
         state.Close();
         watch.Stop();
         Log?.WriteLine($"Serialized: {watch.ElapsedMilliseconds}ms");
     }
     catch
     {
         state.Abandon();
         throw;
     }
 }