private MongoNode AddBsonValueNode(string key, BsonValue v, MongoNode parent) { MongoNode node = new MongoNode { Key = key }; if (v.IsBsonNull) { node = AddTreeNode(key, null, parent); } else if (v.IsBoolean) { node = AddTreeNode(key, v.ToBoolean(), parent); } else if (v.IsInt32) { node = AddTreeNode(key, v.ToInt32(), parent); } else if (v.IsInt32 || v.IsInt64) { node = AddTreeNode(key, v.ToInt64(), parent); } else if (v.IsDouble) { node = AddTreeNode(key, v.ToDouble(), parent); } else if (v.IsDecimal128 || v.IsNumeric) { node = AddTreeNode(key, v.ToDecimal(), parent); } else if (v.IsObjectId) { node = AddTreeNode(key, v.AsObjectId, parent); } else if (v.IsString || v.IsGuid) { node = AddTreeNode(key, v.ToString(), parent); } else if (v.IsValidDateTime || v.IsBsonDateTime) { node = AddTreeNode(key, v.ToLocalTime(), parent); } else if (v.IsString) { node = AddTreeNode(key, v.ToString(), parent); } else if (v.IsValidDateTime) { node = AddTreeNode(key, v.ToLocalTime(), parent); } else if (v.IsBsonArray) { var array = v.AsBsonArray; node.Value = $"[{array.Count}]"; node.Type = "Array"; node.ImagePath = ResourcesBase + @"/Images/arr.png"; var i = 0; foreach (var item in array) { AddBsonValueNode($"[{i}]", item, node); i++; } } else { node = AddTreeNode(key, v.ToString(), parent); } return(node); }