Beispiel #1
0
        public JObject ToJson()
        {
            var json = new JObject();

            json["replicas"] = new JArray(Replicas.Select(p => p.ToJson()));
            json["containerBackupFactor"] = ContainerBackupFactor;
            json["selectors"]             = new JArray(Selectors.Select(p => p.ToJson()));
            json["filters"] = new JArray(Filters.Select(p => p.ToJson()));
            return(json);
        }
        /// <summary>
        ///     Returns a JSON representation of the PartitionMetadata object.
        /// </summary>
        /// <returns>
        ///     A JSON representation the PartitionMetadata object.
        /// </returns>
        public override string ToString()
        {
            var result = new StringBuilder();

            result.Append($"{{ \"PartitionId\": {PartitionId}, \"Leader\": {Leader}, \"Replicas\": [");
            result.Append(string.Join(",", Replicas.Select(r => $" {r.ToString()}")));
            result.Append(" ], \"InSyncReplicas\": [");
            result.Append(string.Join(",", InSyncReplicas.Select(r => $" {r.ToString()}")));
            result.Append($" ], \"Error\": \"{Error.Code.ToString()}\" }}");
            return(result.ToString());
        }