private static void WriteNode(JsonTextWriter j, OperationNode node) { if (node.HitIndex != default) { j.WritePropertyName("h"); j.WriteValue(node.HitIndex); } if (node.Operation.SourceIndex != default) { j.WritePropertyName("s"); j.WriteValue(node.Operation.SourceIndex); } j.WritePropertyName("t"); j.WriteValue((int)node.Operation.Type); switch (node.Operation) { case OperationWithIdVersion operationWithIdVersion: j.WritePropertyName("i"); j.WriteValue(operationWithIdVersion.Id); j.WritePropertyName("v"); j.WriteValue(operationWithIdVersion.Version); break; case OperationWithId operationWithId: j.WritePropertyName("i"); j.WriteValue(operationWithId.Id); break; default: throw new NotImplementedException($"Operation type {node.Operation.Type} is not supported for serialization."); } }
private static string GetNodeLabel(StringBuilder builder, OperationNode node) { builder.Clear(); switch (node.Operation.Type) { case OperationType.PackageBaseAddressIndex: var packageBaseAddressIndex = (OperationWithId)node.Operation; builder.AppendFormat("{0}/index.json", packageBaseAddressIndex.Id); break; case OperationType.PackageBaseAddressNupkg: var packageBaseAddressNupkg = (OperationWithIdVersion)node.Operation; builder.AppendFormat("{0}.{1}.nupkg", packageBaseAddressNupkg.Id, packageBaseAddressNupkg.Version); break; default: throw new NotImplementedException($"Operation type {node.Operation.Type} is not supported for serialization."); } return(builder.ToString()); }