using System.Collections.Generic; using System.Linq; namespace Carbon.Json.Converters { internal sealed class HashSetConverter : JsonConverter> { public override JsonNode ToJson(HashSet value) { return new XSet(value); } public override HashSet FromJson(JsonNode node) { var collection = node as ICollection; if (collection.Count == 0) return null; // TODO: Remove Linq depedency return new HashSet(collection.Cast()); } } }