예제 #1
0
        public static void RestoreGlobals(
            [CanBeNull] string input,
            [NotNull] ContextGlobals globals,
            [NotNull] ContextConfiguration configuration)
        {
            foreach (var(name, serializedValue) in ReadProperties(input, configuration.ErrorCallback))
            {
                if (!configuration.DistributedGlobals.TryGetValue(name, out var tuple))
                {
                    continue;
                }

                var value = DeserializeValue(name, serializedValue, tuple.serializer, configuration.ErrorCallback);
                if (value == null)
                {
                    continue;
                }

                globals.Set(tuple.type, value);
            }
        }
예제 #2
0
 public static string SerializeGlobals(
     [NotNull] ContextGlobals globals,
     [NotNull] ContextConfiguration configuration)
 {
     return(SerializeInternal(EnumerateGlobals(globals, configuration), configuration.ErrorCallback));
 }