/// <summary>
 /// Writes collection as json
 /// </summary>
 /// <param name="collection"></param>
 /// <param name="context"></param>
 /// <param name="formatting"></param>
 /// <param name="ostrm"></param>
 public static void SaveAsJson(this NodeStateCollection collection, Stream ostrm,
                               Newtonsoft.Json.Formatting formatting, ISystemContext context)
 {
     using (var encoder = new JsonEncoderEx(ostrm, context.ToMessageContext(),
                                            JsonEncoderEx.JsonEncoding.Array, formatting)
     {
         UseAdvancedEncoding = true,
         IgnoreDefaultValues = true
     }) {
         foreach (var node in collection.ToNodeModels(context))
         {
             if (node != null)
             {
                 encoder.WriteEncodeable(null, new EncodeableNodeModel(node));
             }
         }
     }
 }
 /// <summary>
 /// Writes the collection to a stream using the Opc.Ua.Schema.UANodeSet schema.
 /// </summary>
 /// <param name="collection"></param>
 /// <param name="ostrm"></param>
 /// <param name="lastModified"></param>
 /// <param name="context"></param>
 /// <param name="model"></param>
 public static void SaveAsNodeSet2(this NodeStateCollection collection, Stream ostrm,
                                   DateTime?lastModified, ISystemContext context, ModelTableEntry model = null) =>
 NodeSet2.Create(collection.ToNodeModels(context), model, lastModified, context).Save(ostrm);