Enhanced C#
Loyc library documentation
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
Static Public Member Functions | List of all members
DefaultSynchronizer Class Reference

The "synchronize any T with zero configuration" dispatcher. Given a type T, Supports and Sync try to find some mechanism to serialize it. More...


Source file:

Remarks

The "synchronize any T with zero configuration" dispatcher. Given a type T, Supports and Sync try to find some mechanism to serialize it.

This can be contrasted with SyncDynamicExt, which is meant for composite types, especially cases where the a field's runtime type differs from its static type (subclasses, interfaces).

Why do both exist, Opus?

┌───────────────────────────────┬──────────────────────────────────┬─────────────────────────────────────────┐
│ │ DynamicSync / SyncDyn │ DefaultSynchronizer.Sync │
├───────────────────────────────┼──────────────────────────────────┼─────────────────────────────────────────┤
│ Purpose │ Polymorphic dispatch by runtime │ "Just serialize this T" convenience │
│ │ type │ │
├───────────────────────────────┼──────────────────────────────────┼─────────────────────────────────────────┤
│ Type tags │ Yes — writes/reads them, checks │ No (except via the DynamicSync it may │
│ │ assignability │ delegate to) │
├───────────────────────────────┼──────────────────────────────────┼─────────────────────────────────────────┤
│ Handles │ No (registry-only) │ Yes (the whole PredefinedSynchronizer │
│ primitives/collections/tuples │ │ layer) │
├───────────────────────────────┼──────────────────────────────────┼─────────────────────────────────────────┤
│ Config knobs │ Registry instances, ObjectMode, │ None — fully automatic │
│ │ tag policy │ │
└───────────────────────────────┴──────────────────────────────────┴─────────────────────────────────────────┘

Static Public Member Functions

static bool Supports< T > ()
 
static T Sync< SyncManager, T > (ref SyncManager sync, FieldId name, [AllowNull] T value)