// SPDX-License-Identifier: BSD-3-Clause
//
// Copyright 2020 Raritan Inc. All rights reserved.
//
// This file was generated by IdlC from Log.idl.

using System;
using System.Linq;
using LightJson;
using Com.Raritan.Idl;
using Com.Raritan.JsonRpc;
using Com.Raritan.Util;

#pragma warning disable 0108, 0219, 0414, 1591

namespace Com.Raritan.Idl.logging {

  public class LogChunk : ICloneable {
    public object Clone() {
      LogChunk copy = new LogChunk();
      copy.logCreationTime = this.logCreationTime;
      copy.idFirst = this.idFirst;
      copy.allEntryCnt = this.allEntryCnt;
      copy.selEntries = this.selEntries;
      return copy;
    }

    public LightJson.JsonObject Encode() {
      LightJson.JsonObject json = new LightJson.JsonObject();
      json["logCreationTime"] = this.logCreationTime;
      json["idFirst"] = this.idFirst;
      json["allEntryCnt"] = this.allEntryCnt;
      json["selEntries"] = new JsonArray(this.selEntries.Select(
        _value => (JsonValue)(_value.Encode())));
      return json;
    }

    public static LogChunk Decode(LightJson.JsonObject json, Agent agent) {
      LogChunk inst = new LogChunk();
      inst.logCreationTime = (long)json["logCreationTime"];
      inst.idFirst = (int)json["idFirst"];
      inst.allEntryCnt = (int)json["allEntryCnt"];
      inst.selEntries = new System.Collections.Generic.List<Com.Raritan.Idl.logging.LogEntry>(json["selEntries"].AsJsonArray.Select(
        _value => Com.Raritan.Idl.logging.LogEntry.Decode(_value, agent)));
      return inst;
    }

    public long logCreationTime = 0;
    public int idFirst = 0;
    public int allEntryCnt = 0;
    public System.Collections.Generic.IEnumerable<Com.Raritan.Idl.logging.LogEntry> selEntries = new System.Collections.Generic.List<Com.Raritan.Idl.logging.LogEntry>();
  }
}
